001    /**
002     * Copyright (c) 2000-2010 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.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.service.persistence.BatchSessionUtil;
040    import com.liferay.portal.service.persistence.CompanyPersistence;
041    import com.liferay.portal.service.persistence.GroupPersistence;
042    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
043    import com.liferay.portal.service.persistence.ResourcePersistence;
044    import com.liferay.portal.service.persistence.SubscriptionPersistence;
045    import com.liferay.portal.service.persistence.UserPersistence;
046    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
047    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048    
049    import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
050    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
051    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
052    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
053    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
054    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
055    import com.liferay.portlet.social.service.persistence.SocialEquityLogPersistence;
056    import com.liferay.portlet.wiki.NoSuchPageException;
057    import com.liferay.portlet.wiki.model.WikiPage;
058    import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
059    import com.liferay.portlet.wiki.model.impl.WikiPageModelImpl;
060    
061    import java.io.Serializable;
062    
063    import java.util.ArrayList;
064    import java.util.Collections;
065    import java.util.List;
066    
067    /**
068     * The persistence implementation for the wiki page service.
069     *
070     * <p>
071     * 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.
072     * </p>
073     *
074     * <p>
075     * Caching information and settings can be found in <code>portal.properties</code>
076     * </p>
077     *
078     * @author Brian Wing Shun Chan
079     * @see WikiPagePersistence
080     * @see WikiPageUtil
081     * @generated
082     */
083    public class WikiPagePersistenceImpl extends BasePersistenceImpl<WikiPage>
084            implements WikiPagePersistence {
085            public static final String FINDER_CLASS_NAME_ENTITY = WikiPageImpl.class.getName();
086            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
087                    ".List";
088            public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
089                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
090                            "findByUuid",
091                            new String[] {
092                                    String.class.getName(),
093                                    
094                            "java.lang.Integer", "java.lang.Integer",
095                                    "com.liferay.portal.kernel.util.OrderByComparator"
096                            });
097            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
098                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
099                            "countByUuid", new String[] { String.class.getName() });
100            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
101                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
102                            "fetchByUUID_G",
103                            new String[] { String.class.getName(), Long.class.getName() });
104            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
105                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
106                            "countByUUID_G",
107                            new String[] { String.class.getName(), Long.class.getName() });
108            public static final FinderPath FINDER_PATH_FIND_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
109                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110                            "findByNodeId",
111                            new String[] {
112                                    Long.class.getName(),
113                                    
114                            "java.lang.Integer", "java.lang.Integer",
115                                    "com.liferay.portal.kernel.util.OrderByComparator"
116                            });
117            public static final FinderPath FINDER_PATH_COUNT_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
118                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119                            "countByNodeId", new String[] { Long.class.getName() });
120            public static final FinderPath FINDER_PATH_FIND_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
121                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
122                            "findByFormat",
123                            new String[] {
124                                    String.class.getName(),
125                                    
126                            "java.lang.Integer", "java.lang.Integer",
127                                    "com.liferay.portal.kernel.util.OrderByComparator"
128                            });
129            public static final FinderPath FINDER_PATH_COUNT_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
130                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131                            "countByFormat", new String[] { String.class.getName() });
132            public static final FinderPath FINDER_PATH_FIND_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
133                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134                            "findByR_N",
135                            new String[] {
136                                    Long.class.getName(), Long.class.getName(),
137                                    
138                            "java.lang.Integer", "java.lang.Integer",
139                                    "com.liferay.portal.kernel.util.OrderByComparator"
140                            });
141            public static final FinderPath FINDER_PATH_COUNT_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
142                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
143                            "countByR_N",
144                            new String[] { Long.class.getName(), Long.class.getName() });
145            public static final FinderPath FINDER_PATH_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
146                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
147                            "findByN_T",
148                            new String[] {
149                                    Long.class.getName(), String.class.getName(),
150                                    
151                            "java.lang.Integer", "java.lang.Integer",
152                                    "com.liferay.portal.kernel.util.OrderByComparator"
153                            });
154            public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
155                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
156                            "countByN_T",
157                            new String[] { Long.class.getName(), String.class.getName() });
158            public static final FinderPath FINDER_PATH_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
159                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
160                            "findByN_H",
161                            new String[] {
162                                    Long.class.getName(), Boolean.class.getName(),
163                                    
164                            "java.lang.Integer", "java.lang.Integer",
165                                    "com.liferay.portal.kernel.util.OrderByComparator"
166                            });
167            public static final FinderPath FINDER_PATH_COUNT_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
168                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
169                            "countByN_H",
170                            new String[] { Long.class.getName(), Boolean.class.getName() });
171            public static final FinderPath FINDER_PATH_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
172                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
173                            "findByN_P",
174                            new String[] {
175                                    Long.class.getName(), String.class.getName(),
176                                    
177                            "java.lang.Integer", "java.lang.Integer",
178                                    "com.liferay.portal.kernel.util.OrderByComparator"
179                            });
180            public static final FinderPath FINDER_PATH_COUNT_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
181                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
182                            "countByN_P",
183                            new String[] { Long.class.getName(), String.class.getName() });
184            public static final FinderPath FINDER_PATH_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
185                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
186                            "findByN_R",
187                            new String[] {
188                                    Long.class.getName(), String.class.getName(),
189                                    
190                            "java.lang.Integer", "java.lang.Integer",
191                                    "com.liferay.portal.kernel.util.OrderByComparator"
192                            });
193            public static final FinderPath FINDER_PATH_COUNT_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
194                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
195                            "countByN_R",
196                            new String[] { Long.class.getName(), String.class.getName() });
197            public static final FinderPath FINDER_PATH_FIND_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
198                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
199                            "findByN_S",
200                            new String[] {
201                                    Long.class.getName(), Integer.class.getName(),
202                                    
203                            "java.lang.Integer", "java.lang.Integer",
204                                    "com.liferay.portal.kernel.util.OrderByComparator"
205                            });
206            public static final FinderPath FINDER_PATH_COUNT_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
207                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
208                            "countByN_S",
209                            new String[] { Long.class.getName(), Integer.class.getName() });
210            public static final FinderPath FINDER_PATH_FETCH_BY_R_N_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
211                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
212                            "fetchByR_N_V",
213                            new String[] {
214                                    Long.class.getName(), Long.class.getName(),
215                                    Double.class.getName()
216                            });
217            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
218                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
219                            "countByR_N_V",
220                            new String[] {
221                                    Long.class.getName(), Long.class.getName(),
222                                    Double.class.getName()
223                            });
224            public static final FinderPath FINDER_PATH_FIND_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
225                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
226                            "findByR_N_S",
227                            new String[] {
228                                    Long.class.getName(), Long.class.getName(),
229                                    Integer.class.getName(),
230                                    
231                            "java.lang.Integer", "java.lang.Integer",
232                                    "com.liferay.portal.kernel.util.OrderByComparator"
233                            });
234            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
235                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
236                            "countByR_N_S",
237                            new String[] {
238                                    Long.class.getName(), Long.class.getName(),
239                                    Integer.class.getName()
240                            });
241            public static final FinderPath FINDER_PATH_FIND_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
242                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
243                            "findByU_N_S",
244                            new String[] {
245                                    Long.class.getName(), Long.class.getName(),
246                                    Integer.class.getName(),
247                                    
248                            "java.lang.Integer", "java.lang.Integer",
249                                    "com.liferay.portal.kernel.util.OrderByComparator"
250                            });
251            public static final FinderPath FINDER_PATH_COUNT_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
252                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
253                            "countByU_N_S",
254                            new String[] {
255                                    Long.class.getName(), Long.class.getName(),
256                                    Integer.class.getName()
257                            });
258            public static final FinderPath FINDER_PATH_FETCH_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
259                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
260                            "fetchByN_T_V",
261                            new String[] {
262                                    Long.class.getName(), String.class.getName(),
263                                    Double.class.getName()
264                            });
265            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
266                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
267                            "countByN_T_V",
268                            new String[] {
269                                    Long.class.getName(), String.class.getName(),
270                                    Double.class.getName()
271                            });
272            public static final FinderPath FINDER_PATH_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
273                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
274                            "findByN_T_H",
275                            new String[] {
276                                    Long.class.getName(), String.class.getName(),
277                                    Boolean.class.getName(),
278                                    
279                            "java.lang.Integer", "java.lang.Integer",
280                                    "com.liferay.portal.kernel.util.OrderByComparator"
281                            });
282            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
283                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
284                            "countByN_T_H",
285                            new String[] {
286                                    Long.class.getName(), String.class.getName(),
287                                    Boolean.class.getName()
288                            });
289            public static final FinderPath FINDER_PATH_FIND_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
290                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
291                            "findByN_T_S",
292                            new String[] {
293                                    Long.class.getName(), String.class.getName(),
294                                    Integer.class.getName(),
295                                    
296                            "java.lang.Integer", "java.lang.Integer",
297                                    "com.liferay.portal.kernel.util.OrderByComparator"
298                            });
299            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
300                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
301                            "countByN_T_S",
302                            new String[] {
303                                    Long.class.getName(), String.class.getName(),
304                                    Integer.class.getName()
305                            });
306            public static final FinderPath FINDER_PATH_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
307                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
308                            "findByN_H_P",
309                            new String[] {
310                                    Long.class.getName(), Boolean.class.getName(),
311                                    String.class.getName(),
312                                    
313                            "java.lang.Integer", "java.lang.Integer",
314                                    "com.liferay.portal.kernel.util.OrderByComparator"
315                            });
316            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
317                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
318                            "countByN_H_P",
319                            new String[] {
320                                    Long.class.getName(), Boolean.class.getName(),
321                                    String.class.getName()
322                            });
323            public static final FinderPath FINDER_PATH_FIND_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
324                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
325                            "findByN_H_S",
326                            new String[] {
327                                    Long.class.getName(), Boolean.class.getName(),
328                                    Integer.class.getName(),
329                                    
330                            "java.lang.Integer", "java.lang.Integer",
331                                    "com.liferay.portal.kernel.util.OrderByComparator"
332                            });
333            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
334                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
335                            "countByN_H_S",
336                            new String[] {
337                                    Long.class.getName(), Boolean.class.getName(),
338                                    Integer.class.getName()
339                            });
340            public static final FinderPath FINDER_PATH_FIND_BY_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
341                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
342                            "findByN_H_P_S",
343                            new String[] {
344                                    Long.class.getName(), Boolean.class.getName(),
345                                    String.class.getName(), Integer.class.getName(),
346                                    
347                            "java.lang.Integer", "java.lang.Integer",
348                                    "com.liferay.portal.kernel.util.OrderByComparator"
349                            });
350            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
351                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
352                            "countByN_H_P_S",
353                            new String[] {
354                                    Long.class.getName(), Boolean.class.getName(),
355                                    String.class.getName(), Integer.class.getName()
356                            });
357            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
358                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
359                            "findAll", new String[0]);
360            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
361                            WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
362                            "countAll", new String[0]);
363    
364            /**
365             * Caches the wiki page in the entity cache if it is enabled.
366             *
367             * @param wikiPage the wiki page to cache
368             */
369            public void cacheResult(WikiPage wikiPage) {
370                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
371                            WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
372    
373                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
374                            new Object[] { wikiPage.getUuid(), new Long(wikiPage.getGroupId()) },
375                            wikiPage);
376    
377                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
378                            new Object[] {
379                                    new Long(wikiPage.getResourcePrimKey()),
380                                    new Long(wikiPage.getNodeId()),
381                                    new Double(wikiPage.getVersion())
382                            }, wikiPage);
383    
384                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
385                            new Object[] {
386                                    new Long(wikiPage.getNodeId()),
387                                    
388                            wikiPage.getTitle(), new Double(wikiPage.getVersion())
389                            }, wikiPage);
390            }
391    
392            /**
393             * Caches the wiki pages in the entity cache if it is enabled.
394             *
395             * @param wikiPages the wiki pages to cache
396             */
397            public void cacheResult(List<WikiPage> wikiPages) {
398                    for (WikiPage wikiPage : wikiPages) {
399                            if (EntityCacheUtil.getResult(
400                                                    WikiPageModelImpl.ENTITY_CACHE_ENABLED,
401                                                    WikiPageImpl.class, wikiPage.getPrimaryKey(), this) == null) {
402                                    cacheResult(wikiPage);
403                            }
404                    }
405            }
406    
407            /**
408             * Clears the cache for all wiki pages.
409             *
410             * <p>
411             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
412             * </p>
413             */
414            public void clearCache() {
415                    CacheRegistryUtil.clear(WikiPageImpl.class.getName());
416                    EntityCacheUtil.clearCache(WikiPageImpl.class.getName());
417                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
418                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
419            }
420    
421            /**
422             * Clears the cache for the wiki page.
423             *
424             * <p>
425             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
426             * </p>
427             */
428            public void clearCache(WikiPage wikiPage) {
429                    EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
430                            WikiPageImpl.class, wikiPage.getPrimaryKey());
431    
432                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
433                            new Object[] { wikiPage.getUuid(), new Long(wikiPage.getGroupId()) });
434    
435                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V,
436                            new Object[] {
437                                    new Long(wikiPage.getResourcePrimKey()),
438                                    new Long(wikiPage.getNodeId()),
439                                    new Double(wikiPage.getVersion())
440                            });
441    
442                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
443                            new Object[] {
444                                    new Long(wikiPage.getNodeId()),
445                                    
446                            wikiPage.getTitle(), new Double(wikiPage.getVersion())
447                            });
448            }
449    
450            /**
451             * Creates a new wiki page with the primary key. Does not add the wiki page to the database.
452             *
453             * @param pageId the primary key for the new wiki page
454             * @return the new wiki page
455             */
456            public WikiPage create(long pageId) {
457                    WikiPage wikiPage = new WikiPageImpl();
458    
459                    wikiPage.setNew(true);
460                    wikiPage.setPrimaryKey(pageId);
461    
462                    String uuid = PortalUUIDUtil.generate();
463    
464                    wikiPage.setUuid(uuid);
465    
466                    return wikiPage;
467            }
468    
469            /**
470             * Removes the wiki page with the primary key from the database. Also notifies the appropriate model listeners.
471             *
472             * @param primaryKey the primary key of the wiki page to remove
473             * @return the wiki page that was removed
474             * @throws com.liferay.portal.NoSuchModelException if a wiki page with the primary key could not be found
475             * @throws SystemException if a system exception occurred
476             */
477            public WikiPage remove(Serializable primaryKey)
478                    throws NoSuchModelException, SystemException {
479                    return remove(((Long)primaryKey).longValue());
480            }
481    
482            /**
483             * Removes the wiki page with the primary key from the database. Also notifies the appropriate model listeners.
484             *
485             * @param pageId the primary key of the wiki page to remove
486             * @return the wiki page that was removed
487             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
488             * @throws SystemException if a system exception occurred
489             */
490            public WikiPage remove(long pageId)
491                    throws NoSuchPageException, SystemException {
492                    Session session = null;
493    
494                    try {
495                            session = openSession();
496    
497                            WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
498                                            new Long(pageId));
499    
500                            if (wikiPage == null) {
501                                    if (_log.isWarnEnabled()) {
502                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + pageId);
503                                    }
504    
505                                    throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
506                                            pageId);
507                            }
508    
509                            return remove(wikiPage);
510                    }
511                    catch (NoSuchPageException nsee) {
512                            throw nsee;
513                    }
514                    catch (Exception e) {
515                            throw processException(e);
516                    }
517                    finally {
518                            closeSession(session);
519                    }
520            }
521    
522            protected WikiPage removeImpl(WikiPage wikiPage) throws SystemException {
523                    wikiPage = toUnwrappedModel(wikiPage);
524    
525                    Session session = null;
526    
527                    try {
528                            session = openSession();
529    
530                            if (wikiPage.isCachedModel() || BatchSessionUtil.isEnabled()) {
531                                    Object staleObject = session.get(WikiPageImpl.class,
532                                                    wikiPage.getPrimaryKeyObj());
533    
534                                    if (staleObject != null) {
535                                            session.evict(staleObject);
536                                    }
537                            }
538    
539                            session.delete(wikiPage);
540    
541                            session.flush();
542                    }
543                    catch (Exception e) {
544                            throw processException(e);
545                    }
546                    finally {
547                            closeSession(session);
548                    }
549    
550                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
551    
552                    WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
553    
554                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
555                            new Object[] {
556                                    wikiPageModelImpl.getOriginalUuid(),
557                                    new Long(wikiPageModelImpl.getOriginalGroupId())
558                            });
559    
560                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V,
561                            new Object[] {
562                                    new Long(wikiPageModelImpl.getOriginalResourcePrimKey()),
563                                    new Long(wikiPageModelImpl.getOriginalNodeId()),
564                                    new Double(wikiPageModelImpl.getOriginalVersion())
565                            });
566    
567                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
568                            new Object[] {
569                                    new Long(wikiPageModelImpl.getOriginalNodeId()),
570                                    
571                            wikiPageModelImpl.getOriginalTitle(),
572                                    new Double(wikiPageModelImpl.getOriginalVersion())
573                            });
574    
575                    EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
576                            WikiPageImpl.class, wikiPage.getPrimaryKey());
577    
578                    return wikiPage;
579            }
580    
581            public WikiPage updateImpl(
582                    com.liferay.portlet.wiki.model.WikiPage wikiPage, boolean merge)
583                    throws SystemException {
584                    wikiPage = toUnwrappedModel(wikiPage);
585    
586                    boolean isNew = wikiPage.isNew();
587    
588                    WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
589    
590                    if (Validator.isNull(wikiPage.getUuid())) {
591                            String uuid = PortalUUIDUtil.generate();
592    
593                            wikiPage.setUuid(uuid);
594                    }
595    
596                    Session session = null;
597    
598                    try {
599                            session = openSession();
600    
601                            BatchSessionUtil.update(session, wikiPage, merge);
602    
603                            wikiPage.setNew(false);
604                    }
605                    catch (Exception e) {
606                            throw processException(e);
607                    }
608                    finally {
609                            closeSession(session);
610                    }
611    
612                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
613    
614                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
615                            WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
616    
617                    if (!isNew &&
618                                    (!Validator.equals(wikiPage.getUuid(),
619                                            wikiPageModelImpl.getOriginalUuid()) ||
620                                    (wikiPage.getGroupId() != wikiPageModelImpl.getOriginalGroupId()))) {
621                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
622                                    new Object[] {
623                                            wikiPageModelImpl.getOriginalUuid(),
624                                            new Long(wikiPageModelImpl.getOriginalGroupId())
625                                    });
626                    }
627    
628                    if (isNew ||
629                                    (!Validator.equals(wikiPage.getUuid(),
630                                            wikiPageModelImpl.getOriginalUuid()) ||
631                                    (wikiPage.getGroupId() != wikiPageModelImpl.getOriginalGroupId()))) {
632                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
633                                    new Object[] { wikiPage.getUuid(), new Long(
634                                                    wikiPage.getGroupId()) }, wikiPage);
635                    }
636    
637                    if (!isNew &&
638                                    ((wikiPage.getResourcePrimKey() != wikiPageModelImpl.getOriginalResourcePrimKey()) ||
639                                    (wikiPage.getNodeId() != wikiPageModelImpl.getOriginalNodeId()) ||
640                                    (wikiPage.getVersion() != wikiPageModelImpl.getOriginalVersion()))) {
641                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V,
642                                    new Object[] {
643                                            new Long(wikiPageModelImpl.getOriginalResourcePrimKey()),
644                                            new Long(wikiPageModelImpl.getOriginalNodeId()),
645                                            new Double(wikiPageModelImpl.getOriginalVersion())
646                                    });
647                    }
648    
649                    if (isNew ||
650                                    ((wikiPage.getResourcePrimKey() != wikiPageModelImpl.getOriginalResourcePrimKey()) ||
651                                    (wikiPage.getNodeId() != wikiPageModelImpl.getOriginalNodeId()) ||
652                                    (wikiPage.getVersion() != wikiPageModelImpl.getOriginalVersion()))) {
653                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
654                                    new Object[] {
655                                            new Long(wikiPage.getResourcePrimKey()),
656                                            new Long(wikiPage.getNodeId()),
657                                            new Double(wikiPage.getVersion())
658                                    }, wikiPage);
659                    }
660    
661                    if (!isNew &&
662                                    ((wikiPage.getNodeId() != wikiPageModelImpl.getOriginalNodeId()) ||
663                                    !Validator.equals(wikiPage.getTitle(),
664                                            wikiPageModelImpl.getOriginalTitle()) ||
665                                    (wikiPage.getVersion() != wikiPageModelImpl.getOriginalVersion()))) {
666                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
667                                    new Object[] {
668                                            new Long(wikiPageModelImpl.getOriginalNodeId()),
669                                            
670                                    wikiPageModelImpl.getOriginalTitle(),
671                                            new Double(wikiPageModelImpl.getOriginalVersion())
672                                    });
673                    }
674    
675                    if (isNew ||
676                                    ((wikiPage.getNodeId() != wikiPageModelImpl.getOriginalNodeId()) ||
677                                    !Validator.equals(wikiPage.getTitle(),
678                                            wikiPageModelImpl.getOriginalTitle()) ||
679                                    (wikiPage.getVersion() != wikiPageModelImpl.getOriginalVersion()))) {
680                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
681                                    new Object[] {
682                                            new Long(wikiPage.getNodeId()),
683                                            
684                                    wikiPage.getTitle(), new Double(wikiPage.getVersion())
685                                    }, wikiPage);
686                    }
687    
688                    return wikiPage;
689            }
690    
691            protected WikiPage toUnwrappedModel(WikiPage wikiPage) {
692                    if (wikiPage instanceof WikiPageImpl) {
693                            return wikiPage;
694                    }
695    
696                    WikiPageImpl wikiPageImpl = new WikiPageImpl();
697    
698                    wikiPageImpl.setNew(wikiPage.isNew());
699                    wikiPageImpl.setPrimaryKey(wikiPage.getPrimaryKey());
700    
701                    wikiPageImpl.setUuid(wikiPage.getUuid());
702                    wikiPageImpl.setPageId(wikiPage.getPageId());
703                    wikiPageImpl.setResourcePrimKey(wikiPage.getResourcePrimKey());
704                    wikiPageImpl.setGroupId(wikiPage.getGroupId());
705                    wikiPageImpl.setCompanyId(wikiPage.getCompanyId());
706                    wikiPageImpl.setUserId(wikiPage.getUserId());
707                    wikiPageImpl.setUserName(wikiPage.getUserName());
708                    wikiPageImpl.setCreateDate(wikiPage.getCreateDate());
709                    wikiPageImpl.setModifiedDate(wikiPage.getModifiedDate());
710                    wikiPageImpl.setNodeId(wikiPage.getNodeId());
711                    wikiPageImpl.setTitle(wikiPage.getTitle());
712                    wikiPageImpl.setVersion(wikiPage.getVersion());
713                    wikiPageImpl.setMinorEdit(wikiPage.isMinorEdit());
714                    wikiPageImpl.setContent(wikiPage.getContent());
715                    wikiPageImpl.setSummary(wikiPage.getSummary());
716                    wikiPageImpl.setFormat(wikiPage.getFormat());
717                    wikiPageImpl.setHead(wikiPage.isHead());
718                    wikiPageImpl.setParentTitle(wikiPage.getParentTitle());
719                    wikiPageImpl.setRedirectTitle(wikiPage.getRedirectTitle());
720                    wikiPageImpl.setStatus(wikiPage.getStatus());
721                    wikiPageImpl.setStatusByUserId(wikiPage.getStatusByUserId());
722                    wikiPageImpl.setStatusByUserName(wikiPage.getStatusByUserName());
723                    wikiPageImpl.setStatusDate(wikiPage.getStatusDate());
724    
725                    return wikiPageImpl;
726            }
727    
728            /**
729             * Finds the wiki page with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
730             *
731             * @param primaryKey the primary key of the wiki page to find
732             * @return the wiki page
733             * @throws com.liferay.portal.NoSuchModelException if a wiki page with the primary key could not be found
734             * @throws SystemException if a system exception occurred
735             */
736            public WikiPage findByPrimaryKey(Serializable primaryKey)
737                    throws NoSuchModelException, SystemException {
738                    return findByPrimaryKey(((Long)primaryKey).longValue());
739            }
740    
741            /**
742             * Finds the wiki page with the primary key or throws a {@link com.liferay.portlet.wiki.NoSuchPageException} if it could not be found.
743             *
744             * @param pageId the primary key of the wiki page to find
745             * @return the wiki page
746             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
747             * @throws SystemException if a system exception occurred
748             */
749            public WikiPage findByPrimaryKey(long pageId)
750                    throws NoSuchPageException, SystemException {
751                    WikiPage wikiPage = fetchByPrimaryKey(pageId);
752    
753                    if (wikiPage == null) {
754                            if (_log.isWarnEnabled()) {
755                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + pageId);
756                            }
757    
758                            throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
759                                    pageId);
760                    }
761    
762                    return wikiPage;
763            }
764    
765            /**
766             * Finds the wiki page with the primary key or returns <code>null</code> if it could not be found.
767             *
768             * @param primaryKey the primary key of the wiki page to find
769             * @return the wiki page, or <code>null</code> if a wiki page with the primary key could not be found
770             * @throws SystemException if a system exception occurred
771             */
772            public WikiPage fetchByPrimaryKey(Serializable primaryKey)
773                    throws SystemException {
774                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
775            }
776    
777            /**
778             * Finds the wiki page with the primary key or returns <code>null</code> if it could not be found.
779             *
780             * @param pageId the primary key of the wiki page to find
781             * @return the wiki page, or <code>null</code> if a wiki page with the primary key could not be found
782             * @throws SystemException if a system exception occurred
783             */
784            public WikiPage fetchByPrimaryKey(long pageId) throws SystemException {
785                    WikiPage wikiPage = (WikiPage)EntityCacheUtil.getResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
786                                    WikiPageImpl.class, pageId, this);
787    
788                    if (wikiPage == null) {
789                            Session session = null;
790    
791                            try {
792                                    session = openSession();
793    
794                                    wikiPage = (WikiPage)session.get(WikiPageImpl.class,
795                                                    new Long(pageId));
796                            }
797                            catch (Exception e) {
798                                    throw processException(e);
799                            }
800                            finally {
801                                    if (wikiPage != null) {
802                                            cacheResult(wikiPage);
803                                    }
804    
805                                    closeSession(session);
806                            }
807                    }
808    
809                    return wikiPage;
810            }
811    
812            /**
813             * Finds all the wiki pages where uuid = &#63;.
814             *
815             * @param uuid the uuid to search with
816             * @return the matching wiki pages
817             * @throws SystemException if a system exception occurred
818             */
819            public List<WikiPage> findByUuid(String uuid) throws SystemException {
820                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
821            }
822    
823            /**
824             * Finds a range of all the wiki pages where uuid = &#63;.
825             *
826             * <p>
827             * 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.
828             * </p>
829             *
830             * @param uuid the uuid to search with
831             * @param start the lower bound of the range of wiki pages to return
832             * @param end the upper bound of the range of wiki pages to return (not inclusive)
833             * @return the range of matching wiki pages
834             * @throws SystemException if a system exception occurred
835             */
836            public List<WikiPage> findByUuid(String uuid, int start, int end)
837                    throws SystemException {
838                    return findByUuid(uuid, start, end, null);
839            }
840    
841            /**
842             * Finds an ordered range of all the wiki pages where uuid = &#63;.
843             *
844             * <p>
845             * 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.
846             * </p>
847             *
848             * @param uuid the uuid to search with
849             * @param start the lower bound of the range of wiki pages to return
850             * @param end the upper bound of the range of wiki pages to return (not inclusive)
851             * @param orderByComparator the comparator to order the results by
852             * @return the ordered range of matching wiki pages
853             * @throws SystemException if a system exception occurred
854             */
855            public List<WikiPage> findByUuid(String uuid, int start, int end,
856                    OrderByComparator orderByComparator) throws SystemException {
857                    Object[] finderArgs = new Object[] {
858                                    uuid,
859                                    
860                                    String.valueOf(start), String.valueOf(end),
861                                    String.valueOf(orderByComparator)
862                            };
863    
864                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
865                                    finderArgs, this);
866    
867                    if (list == null) {
868                            Session session = null;
869    
870                            try {
871                                    session = openSession();
872    
873                                    StringBundler query = null;
874    
875                                    if (orderByComparator != null) {
876                                            query = new StringBundler(3 +
877                                                            (orderByComparator.getOrderByFields().length * 3));
878                                    }
879                                    else {
880                                            query = new StringBundler(3);
881                                    }
882    
883                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
884    
885                                    if (uuid == null) {
886                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
887                                    }
888                                    else {
889                                            if (uuid.equals(StringPool.BLANK)) {
890                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
891                                            }
892                                            else {
893                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
894                                            }
895                                    }
896    
897                                    if (orderByComparator != null) {
898                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
899                                                    orderByComparator);
900                                    }
901    
902                                    else {
903                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
904                                    }
905    
906                                    String sql = query.toString();
907    
908                                    Query q = session.createQuery(sql);
909    
910                                    QueryPos qPos = QueryPos.getInstance(q);
911    
912                                    if (uuid != null) {
913                                            qPos.add(uuid);
914                                    }
915    
916                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
917                                                    end);
918                            }
919                            catch (Exception e) {
920                                    throw processException(e);
921                            }
922                            finally {
923                                    if (list == null) {
924                                            list = new ArrayList<WikiPage>();
925                                    }
926    
927                                    cacheResult(list);
928    
929                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
930                                            list);
931    
932                                    closeSession(session);
933                            }
934                    }
935    
936                    return list;
937            }
938    
939            /**
940             * Finds the first wiki page in the ordered set where uuid = &#63;.
941             *
942             * <p>
943             * 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.
944             * </p>
945             *
946             * @param uuid the uuid to search with
947             * @param orderByComparator the comparator to order the set by
948             * @return the first matching wiki page
949             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
950             * @throws SystemException if a system exception occurred
951             */
952            public WikiPage findByUuid_First(String uuid,
953                    OrderByComparator orderByComparator)
954                    throws NoSuchPageException, SystemException {
955                    List<WikiPage> list = findByUuid(uuid, 0, 1, orderByComparator);
956    
957                    if (list.isEmpty()) {
958                            StringBundler msg = new StringBundler(4);
959    
960                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
961    
962                            msg.append("uuid=");
963                            msg.append(uuid);
964    
965                            msg.append(StringPool.CLOSE_CURLY_BRACE);
966    
967                            throw new NoSuchPageException(msg.toString());
968                    }
969                    else {
970                            return list.get(0);
971                    }
972            }
973    
974            /**
975             * Finds the last wiki page in the ordered set where uuid = &#63;.
976             *
977             * <p>
978             * 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.
979             * </p>
980             *
981             * @param uuid the uuid to search with
982             * @param orderByComparator the comparator to order the set by
983             * @return the last matching wiki page
984             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
985             * @throws SystemException if a system exception occurred
986             */
987            public WikiPage findByUuid_Last(String uuid,
988                    OrderByComparator orderByComparator)
989                    throws NoSuchPageException, SystemException {
990                    int count = countByUuid(uuid);
991    
992                    List<WikiPage> list = findByUuid(uuid, count - 1, count,
993                                    orderByComparator);
994    
995                    if (list.isEmpty()) {
996                            StringBundler msg = new StringBundler(4);
997    
998                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
999    
1000                            msg.append("uuid=");
1001                            msg.append(uuid);
1002    
1003                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1004    
1005                            throw new NoSuchPageException(msg.toString());
1006                    }
1007                    else {
1008                            return list.get(0);
1009                    }
1010            }
1011    
1012            /**
1013             * Finds the wiki pages before and after the current wiki page in the ordered set where uuid = &#63;.
1014             *
1015             * <p>
1016             * 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.
1017             * </p>
1018             *
1019             * @param pageId the primary key of the current wiki page
1020             * @param uuid the uuid to search with
1021             * @param orderByComparator the comparator to order the set by
1022             * @return the previous, current, and next wiki page
1023             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1024             * @throws SystemException if a system exception occurred
1025             */
1026            public WikiPage[] findByUuid_PrevAndNext(long pageId, String uuid,
1027                    OrderByComparator orderByComparator)
1028                    throws NoSuchPageException, SystemException {
1029                    WikiPage wikiPage = findByPrimaryKey(pageId);
1030    
1031                    Session session = null;
1032    
1033                    try {
1034                            session = openSession();
1035    
1036                            WikiPage[] array = new WikiPageImpl[3];
1037    
1038                            array[0] = getByUuid_PrevAndNext(session, wikiPage, uuid,
1039                                            orderByComparator, true);
1040    
1041                            array[1] = wikiPage;
1042    
1043                            array[2] = getByUuid_PrevAndNext(session, wikiPage, uuid,
1044                                            orderByComparator, false);
1045    
1046                            return array;
1047                    }
1048                    catch (Exception e) {
1049                            throw processException(e);
1050                    }
1051                    finally {
1052                            closeSession(session);
1053                    }
1054            }
1055    
1056            protected WikiPage getByUuid_PrevAndNext(Session session,
1057                    WikiPage wikiPage, String uuid, OrderByComparator orderByComparator,
1058                    boolean previous) {
1059                    StringBundler query = null;
1060    
1061                    if (orderByComparator != null) {
1062                            query = new StringBundler(6 +
1063                                            (orderByComparator.getOrderByFields().length * 6));
1064                    }
1065                    else {
1066                            query = new StringBundler(3);
1067                    }
1068    
1069                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1070    
1071                    if (uuid == null) {
1072                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1073                    }
1074                    else {
1075                            if (uuid.equals(StringPool.BLANK)) {
1076                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1077                            }
1078                            else {
1079                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1080                            }
1081                    }
1082    
1083                    if (orderByComparator != null) {
1084                            String[] orderByFields = orderByComparator.getOrderByFields();
1085    
1086                            if (orderByFields.length > 0) {
1087                                    query.append(WHERE_AND);
1088                            }
1089    
1090                            for (int i = 0; i < orderByFields.length; i++) {
1091                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1092                                    query.append(orderByFields[i]);
1093    
1094                                    if ((i + 1) < orderByFields.length) {
1095                                            if (orderByComparator.isAscending() ^ previous) {
1096                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1097                                            }
1098                                            else {
1099                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1100                                            }
1101                                    }
1102                                    else {
1103                                            if (orderByComparator.isAscending() ^ previous) {
1104                                                    query.append(WHERE_GREATER_THAN);
1105                                            }
1106                                            else {
1107                                                    query.append(WHERE_LESSER_THAN);
1108                                            }
1109                                    }
1110                            }
1111    
1112                            query.append(ORDER_BY_CLAUSE);
1113    
1114                            for (int i = 0; i < orderByFields.length; i++) {
1115                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1116                                    query.append(orderByFields[i]);
1117    
1118                                    if ((i + 1) < orderByFields.length) {
1119                                            if (orderByComparator.isAscending() ^ previous) {
1120                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1121                                            }
1122                                            else {
1123                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1124                                            }
1125                                    }
1126                                    else {
1127                                            if (orderByComparator.isAscending() ^ previous) {
1128                                                    query.append(ORDER_BY_ASC);
1129                                            }
1130                                            else {
1131                                                    query.append(ORDER_BY_DESC);
1132                                            }
1133                                    }
1134                            }
1135                    }
1136    
1137                    else {
1138                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1139                    }
1140    
1141                    String sql = query.toString();
1142    
1143                    Query q = session.createQuery(sql);
1144    
1145                    q.setFirstResult(0);
1146                    q.setMaxResults(2);
1147    
1148                    QueryPos qPos = QueryPos.getInstance(q);
1149    
1150                    if (uuid != null) {
1151                            qPos.add(uuid);
1152                    }
1153    
1154                    if (orderByComparator != null) {
1155                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
1156    
1157                            for (Object value : values) {
1158                                    qPos.add(value);
1159                            }
1160                    }
1161    
1162                    List<WikiPage> list = q.list();
1163    
1164                    if (list.size() == 2) {
1165                            return list.get(1);
1166                    }
1167                    else {
1168                            return null;
1169                    }
1170            }
1171    
1172            /**
1173             * Finds the wiki page where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.wiki.NoSuchPageException} if it could not be found.
1174             *
1175             * @param uuid the uuid to search with
1176             * @param groupId the group id to search with
1177             * @return the matching wiki page
1178             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1179             * @throws SystemException if a system exception occurred
1180             */
1181            public WikiPage findByUUID_G(String uuid, long groupId)
1182                    throws NoSuchPageException, SystemException {
1183                    WikiPage wikiPage = fetchByUUID_G(uuid, groupId);
1184    
1185                    if (wikiPage == null) {
1186                            StringBundler msg = new StringBundler(6);
1187    
1188                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1189    
1190                            msg.append("uuid=");
1191                            msg.append(uuid);
1192    
1193                            msg.append(", groupId=");
1194                            msg.append(groupId);
1195    
1196                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1197    
1198                            if (_log.isWarnEnabled()) {
1199                                    _log.warn(msg.toString());
1200                            }
1201    
1202                            throw new NoSuchPageException(msg.toString());
1203                    }
1204    
1205                    return wikiPage;
1206            }
1207    
1208            /**
1209             * Finds the wiki page where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1210             *
1211             * @param uuid the uuid to search with
1212             * @param groupId the group id to search with
1213             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
1214             * @throws SystemException if a system exception occurred
1215             */
1216            public WikiPage fetchByUUID_G(String uuid, long groupId)
1217                    throws SystemException {
1218                    return fetchByUUID_G(uuid, groupId, true);
1219            }
1220    
1221            /**
1222             * Finds 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.
1223             *
1224             * @param uuid the uuid to search with
1225             * @param groupId the group id to search with
1226             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
1227             * @throws SystemException if a system exception occurred
1228             */
1229            public WikiPage fetchByUUID_G(String uuid, long groupId,
1230                    boolean retrieveFromCache) throws SystemException {
1231                    Object[] finderArgs = new Object[] { uuid, groupId };
1232    
1233                    Object result = null;
1234    
1235                    if (retrieveFromCache) {
1236                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1237                                            finderArgs, this);
1238                    }
1239    
1240                    if (result == null) {
1241                            Session session = null;
1242    
1243                            try {
1244                                    session = openSession();
1245    
1246                                    StringBundler query = new StringBundler(4);
1247    
1248                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1249    
1250                                    if (uuid == null) {
1251                                            query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1252                                    }
1253                                    else {
1254                                            if (uuid.equals(StringPool.BLANK)) {
1255                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1256                                            }
1257                                            else {
1258                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1259                                            }
1260                                    }
1261    
1262                                    query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1263    
1264                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1265    
1266                                    String sql = query.toString();
1267    
1268                                    Query q = session.createQuery(sql);
1269    
1270                                    QueryPos qPos = QueryPos.getInstance(q);
1271    
1272                                    if (uuid != null) {
1273                                            qPos.add(uuid);
1274                                    }
1275    
1276                                    qPos.add(groupId);
1277    
1278                                    List<WikiPage> list = q.list();
1279    
1280                                    result = list;
1281    
1282                                    WikiPage wikiPage = null;
1283    
1284                                    if (list.isEmpty()) {
1285                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1286                                                    finderArgs, list);
1287                                    }
1288                                    else {
1289                                            wikiPage = list.get(0);
1290    
1291                                            cacheResult(wikiPage);
1292    
1293                                            if ((wikiPage.getUuid() == null) ||
1294                                                            !wikiPage.getUuid().equals(uuid) ||
1295                                                            (wikiPage.getGroupId() != groupId)) {
1296                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1297                                                            finderArgs, wikiPage);
1298                                            }
1299                                    }
1300    
1301                                    return wikiPage;
1302                            }
1303                            catch (Exception e) {
1304                                    throw processException(e);
1305                            }
1306                            finally {
1307                                    if (result == null) {
1308                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1309                                                    finderArgs, new ArrayList<WikiPage>());
1310                                    }
1311    
1312                                    closeSession(session);
1313                            }
1314                    }
1315                    else {
1316                            if (result instanceof List<?>) {
1317                                    return null;
1318                            }
1319                            else {
1320                                    return (WikiPage)result;
1321                            }
1322                    }
1323            }
1324    
1325            /**
1326             * Finds all the wiki pages where nodeId = &#63;.
1327             *
1328             * @param nodeId the node id to search with
1329             * @return the matching wiki pages
1330             * @throws SystemException if a system exception occurred
1331             */
1332            public List<WikiPage> findByNodeId(long nodeId) throws SystemException {
1333                    return findByNodeId(nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1334            }
1335    
1336            /**
1337             * Finds a range of all the wiki pages where nodeId = &#63;.
1338             *
1339             * <p>
1340             * 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.
1341             * </p>
1342             *
1343             * @param nodeId the node id to search with
1344             * @param start the lower bound of the range of wiki pages to return
1345             * @param end the upper bound of the range of wiki pages to return (not inclusive)
1346             * @return the range of matching wiki pages
1347             * @throws SystemException if a system exception occurred
1348             */
1349            public List<WikiPage> findByNodeId(long nodeId, int start, int end)
1350                    throws SystemException {
1351                    return findByNodeId(nodeId, start, end, null);
1352            }
1353    
1354            /**
1355             * Finds an ordered range of all the wiki pages where nodeId = &#63;.
1356             *
1357             * <p>
1358             * 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.
1359             * </p>
1360             *
1361             * @param nodeId the node id to search with
1362             * @param start the lower bound of the range of wiki pages to return
1363             * @param end the upper bound of the range of wiki pages to return (not inclusive)
1364             * @param orderByComparator the comparator to order the results by
1365             * @return the ordered range of matching wiki pages
1366             * @throws SystemException if a system exception occurred
1367             */
1368            public List<WikiPage> findByNodeId(long nodeId, int start, int end,
1369                    OrderByComparator orderByComparator) throws SystemException {
1370                    Object[] finderArgs = new Object[] {
1371                                    nodeId,
1372                                    
1373                                    String.valueOf(start), String.valueOf(end),
1374                                    String.valueOf(orderByComparator)
1375                            };
1376    
1377                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_NODEID,
1378                                    finderArgs, this);
1379    
1380                    if (list == null) {
1381                            Session session = null;
1382    
1383                            try {
1384                                    session = openSession();
1385    
1386                                    StringBundler query = null;
1387    
1388                                    if (orderByComparator != null) {
1389                                            query = new StringBundler(3 +
1390                                                            (orderByComparator.getOrderByFields().length * 3));
1391                                    }
1392                                    else {
1393                                            query = new StringBundler(3);
1394                                    }
1395    
1396                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1397    
1398                                    query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1399    
1400                                    if (orderByComparator != null) {
1401                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1402                                                    orderByComparator);
1403                                    }
1404    
1405                                    else {
1406                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1407                                    }
1408    
1409                                    String sql = query.toString();
1410    
1411                                    Query q = session.createQuery(sql);
1412    
1413                                    QueryPos qPos = QueryPos.getInstance(q);
1414    
1415                                    qPos.add(nodeId);
1416    
1417                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1418                                                    end);
1419                            }
1420                            catch (Exception e) {
1421                                    throw processException(e);
1422                            }
1423                            finally {
1424                                    if (list == null) {
1425                                            list = new ArrayList<WikiPage>();
1426                                    }
1427    
1428                                    cacheResult(list);
1429    
1430                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_NODEID,
1431                                            finderArgs, list);
1432    
1433                                    closeSession(session);
1434                            }
1435                    }
1436    
1437                    return list;
1438            }
1439    
1440            /**
1441             * Finds the first wiki page in the ordered set where nodeId = &#63;.
1442             *
1443             * <p>
1444             * 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.
1445             * </p>
1446             *
1447             * @param nodeId the node id to search with
1448             * @param orderByComparator the comparator to order the set by
1449             * @return the first matching wiki page
1450             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1451             * @throws SystemException if a system exception occurred
1452             */
1453            public WikiPage findByNodeId_First(long nodeId,
1454                    OrderByComparator orderByComparator)
1455                    throws NoSuchPageException, SystemException {
1456                    List<WikiPage> list = findByNodeId(nodeId, 0, 1, orderByComparator);
1457    
1458                    if (list.isEmpty()) {
1459                            StringBundler msg = new StringBundler(4);
1460    
1461                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1462    
1463                            msg.append("nodeId=");
1464                            msg.append(nodeId);
1465    
1466                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1467    
1468                            throw new NoSuchPageException(msg.toString());
1469                    }
1470                    else {
1471                            return list.get(0);
1472                    }
1473            }
1474    
1475            /**
1476             * Finds the last wiki page in the ordered set where nodeId = &#63;.
1477             *
1478             * <p>
1479             * 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.
1480             * </p>
1481             *
1482             * @param nodeId the node id to search with
1483             * @param orderByComparator the comparator to order the set by
1484             * @return the last matching wiki page
1485             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1486             * @throws SystemException if a system exception occurred
1487             */
1488            public WikiPage findByNodeId_Last(long nodeId,
1489                    OrderByComparator orderByComparator)
1490                    throws NoSuchPageException, SystemException {
1491                    int count = countByNodeId(nodeId);
1492    
1493                    List<WikiPage> list = findByNodeId(nodeId, count - 1, count,
1494                                    orderByComparator);
1495    
1496                    if (list.isEmpty()) {
1497                            StringBundler msg = new StringBundler(4);
1498    
1499                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1500    
1501                            msg.append("nodeId=");
1502                            msg.append(nodeId);
1503    
1504                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1505    
1506                            throw new NoSuchPageException(msg.toString());
1507                    }
1508                    else {
1509                            return list.get(0);
1510                    }
1511            }
1512    
1513            /**
1514             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63;.
1515             *
1516             * <p>
1517             * 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.
1518             * </p>
1519             *
1520             * @param pageId the primary key of the current wiki page
1521             * @param nodeId the node id to search with
1522             * @param orderByComparator the comparator to order the set by
1523             * @return the previous, current, and next wiki page
1524             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1525             * @throws SystemException if a system exception occurred
1526             */
1527            public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
1528                    OrderByComparator orderByComparator)
1529                    throws NoSuchPageException, SystemException {
1530                    WikiPage wikiPage = findByPrimaryKey(pageId);
1531    
1532                    Session session = null;
1533    
1534                    try {
1535                            session = openSession();
1536    
1537                            WikiPage[] array = new WikiPageImpl[3];
1538    
1539                            array[0] = getByNodeId_PrevAndNext(session, wikiPage, nodeId,
1540                                            orderByComparator, true);
1541    
1542                            array[1] = wikiPage;
1543    
1544                            array[2] = getByNodeId_PrevAndNext(session, wikiPage, nodeId,
1545                                            orderByComparator, false);
1546    
1547                            return array;
1548                    }
1549                    catch (Exception e) {
1550                            throw processException(e);
1551                    }
1552                    finally {
1553                            closeSession(session);
1554                    }
1555            }
1556    
1557            protected WikiPage getByNodeId_PrevAndNext(Session session,
1558                    WikiPage wikiPage, long nodeId, OrderByComparator orderByComparator,
1559                    boolean previous) {
1560                    StringBundler query = null;
1561    
1562                    if (orderByComparator != null) {
1563                            query = new StringBundler(6 +
1564                                            (orderByComparator.getOrderByFields().length * 6));
1565                    }
1566                    else {
1567                            query = new StringBundler(3);
1568                    }
1569    
1570                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1571    
1572                    query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1573    
1574                    if (orderByComparator != null) {
1575                            String[] orderByFields = orderByComparator.getOrderByFields();
1576    
1577                            if (orderByFields.length > 0) {
1578                                    query.append(WHERE_AND);
1579                            }
1580    
1581                            for (int i = 0; i < orderByFields.length; i++) {
1582                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1583                                    query.append(orderByFields[i]);
1584    
1585                                    if ((i + 1) < orderByFields.length) {
1586                                            if (orderByComparator.isAscending() ^ previous) {
1587                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1588                                            }
1589                                            else {
1590                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1591                                            }
1592                                    }
1593                                    else {
1594                                            if (orderByComparator.isAscending() ^ previous) {
1595                                                    query.append(WHERE_GREATER_THAN);
1596                                            }
1597                                            else {
1598                                                    query.append(WHERE_LESSER_THAN);
1599                                            }
1600                                    }
1601                            }
1602    
1603                            query.append(ORDER_BY_CLAUSE);
1604    
1605                            for (int i = 0; i < orderByFields.length; i++) {
1606                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1607                                    query.append(orderByFields[i]);
1608    
1609                                    if ((i + 1) < orderByFields.length) {
1610                                            if (orderByComparator.isAscending() ^ previous) {
1611                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1612                                            }
1613                                            else {
1614                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1615                                            }
1616                                    }
1617                                    else {
1618                                            if (orderByComparator.isAscending() ^ previous) {
1619                                                    query.append(ORDER_BY_ASC);
1620                                            }
1621                                            else {
1622                                                    query.append(ORDER_BY_DESC);
1623                                            }
1624                                    }
1625                            }
1626                    }
1627    
1628                    else {
1629                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1630                    }
1631    
1632                    String sql = query.toString();
1633    
1634                    Query q = session.createQuery(sql);
1635    
1636                    q.setFirstResult(0);
1637                    q.setMaxResults(2);
1638    
1639                    QueryPos qPos = QueryPos.getInstance(q);
1640    
1641                    qPos.add(nodeId);
1642    
1643                    if (orderByComparator != null) {
1644                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
1645    
1646                            for (Object value : values) {
1647                                    qPos.add(value);
1648                            }
1649                    }
1650    
1651                    List<WikiPage> list = q.list();
1652    
1653                    if (list.size() == 2) {
1654                            return list.get(1);
1655                    }
1656                    else {
1657                            return null;
1658                    }
1659            }
1660    
1661            /**
1662             * Finds all the wiki pages where format = &#63;.
1663             *
1664             * @param format the format to search with
1665             * @return the matching wiki pages
1666             * @throws SystemException if a system exception occurred
1667             */
1668            public List<WikiPage> findByFormat(String format) throws SystemException {
1669                    return findByFormat(format, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1670            }
1671    
1672            /**
1673             * Finds a range of all the wiki pages where format = &#63;.
1674             *
1675             * <p>
1676             * 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.
1677             * </p>
1678             *
1679             * @param format the format to search with
1680             * @param start the lower bound of the range of wiki pages to return
1681             * @param end the upper bound of the range of wiki pages to return (not inclusive)
1682             * @return the range of matching wiki pages
1683             * @throws SystemException if a system exception occurred
1684             */
1685            public List<WikiPage> findByFormat(String format, int start, int end)
1686                    throws SystemException {
1687                    return findByFormat(format, start, end, null);
1688            }
1689    
1690            /**
1691             * Finds an ordered range of all the wiki pages where format = &#63;.
1692             *
1693             * <p>
1694             * 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.
1695             * </p>
1696             *
1697             * @param format the format to search with
1698             * @param start the lower bound of the range of wiki pages to return
1699             * @param end the upper bound of the range of wiki pages to return (not inclusive)
1700             * @param orderByComparator the comparator to order the results by
1701             * @return the ordered range of matching wiki pages
1702             * @throws SystemException if a system exception occurred
1703             */
1704            public List<WikiPage> findByFormat(String format, int start, int end,
1705                    OrderByComparator orderByComparator) throws SystemException {
1706                    Object[] finderArgs = new Object[] {
1707                                    format,
1708                                    
1709                                    String.valueOf(start), String.valueOf(end),
1710                                    String.valueOf(orderByComparator)
1711                            };
1712    
1713                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FORMAT,
1714                                    finderArgs, this);
1715    
1716                    if (list == null) {
1717                            Session session = null;
1718    
1719                            try {
1720                                    session = openSession();
1721    
1722                                    StringBundler query = null;
1723    
1724                                    if (orderByComparator != null) {
1725                                            query = new StringBundler(3 +
1726                                                            (orderByComparator.getOrderByFields().length * 3));
1727                                    }
1728                                    else {
1729                                            query = new StringBundler(3);
1730                                    }
1731    
1732                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1733    
1734                                    if (format == null) {
1735                                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
1736                                    }
1737                                    else {
1738                                            if (format.equals(StringPool.BLANK)) {
1739                                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
1740                                            }
1741                                            else {
1742                                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
1743                                            }
1744                                    }
1745    
1746                                    if (orderByComparator != null) {
1747                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1748                                                    orderByComparator);
1749                                    }
1750    
1751                                    else {
1752                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1753                                    }
1754    
1755                                    String sql = query.toString();
1756    
1757                                    Query q = session.createQuery(sql);
1758    
1759                                    QueryPos qPos = QueryPos.getInstance(q);
1760    
1761                                    if (format != null) {
1762                                            qPos.add(format);
1763                                    }
1764    
1765                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1766                                                    end);
1767                            }
1768                            catch (Exception e) {
1769                                    throw processException(e);
1770                            }
1771                            finally {
1772                                    if (list == null) {
1773                                            list = new ArrayList<WikiPage>();
1774                                    }
1775    
1776                                    cacheResult(list);
1777    
1778                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FORMAT,
1779                                            finderArgs, list);
1780    
1781                                    closeSession(session);
1782                            }
1783                    }
1784    
1785                    return list;
1786            }
1787    
1788            /**
1789             * Finds the first wiki page in the ordered set where format = &#63;.
1790             *
1791             * <p>
1792             * 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.
1793             * </p>
1794             *
1795             * @param format the format to search with
1796             * @param orderByComparator the comparator to order the set by
1797             * @return the first matching wiki page
1798             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1799             * @throws SystemException if a system exception occurred
1800             */
1801            public WikiPage findByFormat_First(String format,
1802                    OrderByComparator orderByComparator)
1803                    throws NoSuchPageException, SystemException {
1804                    List<WikiPage> list = findByFormat(format, 0, 1, orderByComparator);
1805    
1806                    if (list.isEmpty()) {
1807                            StringBundler msg = new StringBundler(4);
1808    
1809                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1810    
1811                            msg.append("format=");
1812                            msg.append(format);
1813    
1814                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1815    
1816                            throw new NoSuchPageException(msg.toString());
1817                    }
1818                    else {
1819                            return list.get(0);
1820                    }
1821            }
1822    
1823            /**
1824             * Finds the last wiki page in the ordered set where format = &#63;.
1825             *
1826             * <p>
1827             * 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.
1828             * </p>
1829             *
1830             * @param format the format to search with
1831             * @param orderByComparator the comparator to order the set by
1832             * @return the last matching wiki page
1833             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1834             * @throws SystemException if a system exception occurred
1835             */
1836            public WikiPage findByFormat_Last(String format,
1837                    OrderByComparator orderByComparator)
1838                    throws NoSuchPageException, SystemException {
1839                    int count = countByFormat(format);
1840    
1841                    List<WikiPage> list = findByFormat(format, count - 1, count,
1842                                    orderByComparator);
1843    
1844                    if (list.isEmpty()) {
1845                            StringBundler msg = new StringBundler(4);
1846    
1847                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1848    
1849                            msg.append("format=");
1850                            msg.append(format);
1851    
1852                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1853    
1854                            throw new NoSuchPageException(msg.toString());
1855                    }
1856                    else {
1857                            return list.get(0);
1858                    }
1859            }
1860    
1861            /**
1862             * Finds the wiki pages before and after the current wiki page in the ordered set where format = &#63;.
1863             *
1864             * <p>
1865             * 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.
1866             * </p>
1867             *
1868             * @param pageId the primary key of the current wiki page
1869             * @param format the format to search with
1870             * @param orderByComparator the comparator to order the set by
1871             * @return the previous, current, and next wiki page
1872             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1873             * @throws SystemException if a system exception occurred
1874             */
1875            public WikiPage[] findByFormat_PrevAndNext(long pageId, String format,
1876                    OrderByComparator orderByComparator)
1877                    throws NoSuchPageException, SystemException {
1878                    WikiPage wikiPage = findByPrimaryKey(pageId);
1879    
1880                    Session session = null;
1881    
1882                    try {
1883                            session = openSession();
1884    
1885                            WikiPage[] array = new WikiPageImpl[3];
1886    
1887                            array[0] = getByFormat_PrevAndNext(session, wikiPage, format,
1888                                            orderByComparator, true);
1889    
1890                            array[1] = wikiPage;
1891    
1892                            array[2] = getByFormat_PrevAndNext(session, wikiPage, format,
1893                                            orderByComparator, false);
1894    
1895                            return array;
1896                    }
1897                    catch (Exception e) {
1898                            throw processException(e);
1899                    }
1900                    finally {
1901                            closeSession(session);
1902                    }
1903            }
1904    
1905            protected WikiPage getByFormat_PrevAndNext(Session session,
1906                    WikiPage wikiPage, String format, OrderByComparator orderByComparator,
1907                    boolean previous) {
1908                    StringBundler query = null;
1909    
1910                    if (orderByComparator != null) {
1911                            query = new StringBundler(6 +
1912                                            (orderByComparator.getOrderByFields().length * 6));
1913                    }
1914                    else {
1915                            query = new StringBundler(3);
1916                    }
1917    
1918                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1919    
1920                    if (format == null) {
1921                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
1922                    }
1923                    else {
1924                            if (format.equals(StringPool.BLANK)) {
1925                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
1926                            }
1927                            else {
1928                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
1929                            }
1930                    }
1931    
1932                    if (orderByComparator != null) {
1933                            String[] orderByFields = orderByComparator.getOrderByFields();
1934    
1935                            if (orderByFields.length > 0) {
1936                                    query.append(WHERE_AND);
1937                            }
1938    
1939                            for (int i = 0; i < orderByFields.length; i++) {
1940                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1941                                    query.append(orderByFields[i]);
1942    
1943                                    if ((i + 1) < orderByFields.length) {
1944                                            if (orderByComparator.isAscending() ^ previous) {
1945                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1946                                            }
1947                                            else {
1948                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1949                                            }
1950                                    }
1951                                    else {
1952                                            if (orderByComparator.isAscending() ^ previous) {
1953                                                    query.append(WHERE_GREATER_THAN);
1954                                            }
1955                                            else {
1956                                                    query.append(WHERE_LESSER_THAN);
1957                                            }
1958                                    }
1959                            }
1960    
1961                            query.append(ORDER_BY_CLAUSE);
1962    
1963                            for (int i = 0; i < orderByFields.length; i++) {
1964                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1965                                    query.append(orderByFields[i]);
1966    
1967                                    if ((i + 1) < orderByFields.length) {
1968                                            if (orderByComparator.isAscending() ^ previous) {
1969                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1970                                            }
1971                                            else {
1972                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1973                                            }
1974                                    }
1975                                    else {
1976                                            if (orderByComparator.isAscending() ^ previous) {
1977                                                    query.append(ORDER_BY_ASC);
1978                                            }
1979                                            else {
1980                                                    query.append(ORDER_BY_DESC);
1981                                            }
1982                                    }
1983                            }
1984                    }
1985    
1986                    else {
1987                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1988                    }
1989    
1990                    String sql = query.toString();
1991    
1992                    Query q = session.createQuery(sql);
1993    
1994                    q.setFirstResult(0);
1995                    q.setMaxResults(2);
1996    
1997                    QueryPos qPos = QueryPos.getInstance(q);
1998    
1999                    if (format != null) {
2000                            qPos.add(format);
2001                    }
2002    
2003                    if (orderByComparator != null) {
2004                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
2005    
2006                            for (Object value : values) {
2007                                    qPos.add(value);
2008                            }
2009                    }
2010    
2011                    List<WikiPage> list = q.list();
2012    
2013                    if (list.size() == 2) {
2014                            return list.get(1);
2015                    }
2016                    else {
2017                            return null;
2018                    }
2019            }
2020    
2021            /**
2022             * Finds all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2023             *
2024             * @param resourcePrimKey the resource prim key to search with
2025             * @param nodeId the node id to search with
2026             * @return the matching wiki pages
2027             * @throws SystemException if a system exception occurred
2028             */
2029            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId)
2030                    throws SystemException {
2031                    return findByR_N(resourcePrimKey, nodeId, QueryUtil.ALL_POS,
2032                            QueryUtil.ALL_POS, null);
2033            }
2034    
2035            /**
2036             * Finds a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2037             *
2038             * <p>
2039             * 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.
2040             * </p>
2041             *
2042             * @param resourcePrimKey the resource prim key to search with
2043             * @param nodeId the node id to search with
2044             * @param start the lower bound of the range of wiki pages to return
2045             * @param end the upper bound of the range of wiki pages to return (not inclusive)
2046             * @return the range of matching wiki pages
2047             * @throws SystemException if a system exception occurred
2048             */
2049            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId,
2050                    int start, int end) throws SystemException {
2051                    return findByR_N(resourcePrimKey, nodeId, start, end, null);
2052            }
2053    
2054            /**
2055             * Finds an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
2056             *
2057             * <p>
2058             * 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.
2059             * </p>
2060             *
2061             * @param resourcePrimKey the resource prim key to search with
2062             * @param nodeId the node id to search with
2063             * @param start the lower bound of the range of wiki pages to return
2064             * @param end the upper bound of the range of wiki pages to return (not inclusive)
2065             * @param orderByComparator the comparator to order the results by
2066             * @return the ordered range of matching wiki pages
2067             * @throws SystemException if a system exception occurred
2068             */
2069            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId,
2070                    int start, int end, OrderByComparator orderByComparator)
2071                    throws SystemException {
2072                    Object[] finderArgs = new Object[] {
2073                                    resourcePrimKey, nodeId,
2074                                    
2075                                    String.valueOf(start), String.valueOf(end),
2076                                    String.valueOf(orderByComparator)
2077                            };
2078    
2079                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_R_N,
2080                                    finderArgs, this);
2081    
2082                    if (list == null) {
2083                            Session session = null;
2084    
2085                            try {
2086                                    session = openSession();
2087    
2088                                    StringBundler query = null;
2089    
2090                                    if (orderByComparator != null) {
2091                                            query = new StringBundler(4 +
2092                                                            (orderByComparator.getOrderByFields().length * 3));
2093                                    }
2094                                    else {
2095                                            query = new StringBundler(4);
2096                                    }
2097    
2098                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2099    
2100                                    query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
2101    
2102                                    query.append(_FINDER_COLUMN_R_N_NODEID_2);
2103    
2104                                    if (orderByComparator != null) {
2105                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2106                                                    orderByComparator);
2107                                    }
2108    
2109                                    else {
2110                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2111                                    }
2112    
2113                                    String sql = query.toString();
2114    
2115                                    Query q = session.createQuery(sql);
2116    
2117                                    QueryPos qPos = QueryPos.getInstance(q);
2118    
2119                                    qPos.add(resourcePrimKey);
2120    
2121                                    qPos.add(nodeId);
2122    
2123                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2124                                                    end);
2125                            }
2126                            catch (Exception e) {
2127                                    throw processException(e);
2128                            }
2129                            finally {
2130                                    if (list == null) {
2131                                            list = new ArrayList<WikiPage>();
2132                                    }
2133    
2134                                    cacheResult(list);
2135    
2136                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_R_N, finderArgs,
2137                                            list);
2138    
2139                                    closeSession(session);
2140                            }
2141                    }
2142    
2143                    return list;
2144            }
2145    
2146            /**
2147             * Finds the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
2148             *
2149             * <p>
2150             * 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.
2151             * </p>
2152             *
2153             * @param resourcePrimKey the resource prim key to search with
2154             * @param nodeId the node id to search with
2155             * @param orderByComparator the comparator to order the set by
2156             * @return the first matching wiki page
2157             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2158             * @throws SystemException if a system exception occurred
2159             */
2160            public WikiPage findByR_N_First(long resourcePrimKey, long nodeId,
2161                    OrderByComparator orderByComparator)
2162                    throws NoSuchPageException, SystemException {
2163                    List<WikiPage> list = findByR_N(resourcePrimKey, nodeId, 0, 1,
2164                                    orderByComparator);
2165    
2166                    if (list.isEmpty()) {
2167                            StringBundler msg = new StringBundler(6);
2168    
2169                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2170    
2171                            msg.append("resourcePrimKey=");
2172                            msg.append(resourcePrimKey);
2173    
2174                            msg.append(", nodeId=");
2175                            msg.append(nodeId);
2176    
2177                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2178    
2179                            throw new NoSuchPageException(msg.toString());
2180                    }
2181                    else {
2182                            return list.get(0);
2183                    }
2184            }
2185    
2186            /**
2187             * Finds the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
2188             *
2189             * <p>
2190             * 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.
2191             * </p>
2192             *
2193             * @param resourcePrimKey the resource prim key to search with
2194             * @param nodeId the node id to search with
2195             * @param orderByComparator the comparator to order the set by
2196             * @return the last matching wiki page
2197             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2198             * @throws SystemException if a system exception occurred
2199             */
2200            public WikiPage findByR_N_Last(long resourcePrimKey, long nodeId,
2201                    OrderByComparator orderByComparator)
2202                    throws NoSuchPageException, SystemException {
2203                    int count = countByR_N(resourcePrimKey, nodeId);
2204    
2205                    List<WikiPage> list = findByR_N(resourcePrimKey, nodeId, count - 1,
2206                                    count, orderByComparator);
2207    
2208                    if (list.isEmpty()) {
2209                            StringBundler msg = new StringBundler(6);
2210    
2211                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2212    
2213                            msg.append("resourcePrimKey=");
2214                            msg.append(resourcePrimKey);
2215    
2216                            msg.append(", nodeId=");
2217                            msg.append(nodeId);
2218    
2219                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2220    
2221                            throw new NoSuchPageException(msg.toString());
2222                    }
2223                    else {
2224                            return list.get(0);
2225                    }
2226            }
2227    
2228            /**
2229             * Finds the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
2230             *
2231             * <p>
2232             * 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.
2233             * </p>
2234             *
2235             * @param pageId the primary key of the current wiki page
2236             * @param resourcePrimKey the resource prim key to search with
2237             * @param nodeId the node id to search with
2238             * @param orderByComparator the comparator to order the set by
2239             * @return the previous, current, and next wiki page
2240             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2241             * @throws SystemException if a system exception occurred
2242             */
2243            public WikiPage[] findByR_N_PrevAndNext(long pageId, long resourcePrimKey,
2244                    long nodeId, OrderByComparator orderByComparator)
2245                    throws NoSuchPageException, SystemException {
2246                    WikiPage wikiPage = findByPrimaryKey(pageId);
2247    
2248                    Session session = null;
2249    
2250                    try {
2251                            session = openSession();
2252    
2253                            WikiPage[] array = new WikiPageImpl[3];
2254    
2255                            array[0] = getByR_N_PrevAndNext(session, wikiPage, resourcePrimKey,
2256                                            nodeId, orderByComparator, true);
2257    
2258                            array[1] = wikiPage;
2259    
2260                            array[2] = getByR_N_PrevAndNext(session, wikiPage, resourcePrimKey,
2261                                            nodeId, orderByComparator, false);
2262    
2263                            return array;
2264                    }
2265                    catch (Exception e) {
2266                            throw processException(e);
2267                    }
2268                    finally {
2269                            closeSession(session);
2270                    }
2271            }
2272    
2273            protected WikiPage getByR_N_PrevAndNext(Session session, WikiPage wikiPage,
2274                    long resourcePrimKey, long nodeId, OrderByComparator orderByComparator,
2275                    boolean previous) {
2276                    StringBundler query = null;
2277    
2278                    if (orderByComparator != null) {
2279                            query = new StringBundler(6 +
2280                                            (orderByComparator.getOrderByFields().length * 6));
2281                    }
2282                    else {
2283                            query = new StringBundler(3);
2284                    }
2285    
2286                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2287    
2288                    query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
2289    
2290                    query.append(_FINDER_COLUMN_R_N_NODEID_2);
2291    
2292                    if (orderByComparator != null) {
2293                            String[] orderByFields = orderByComparator.getOrderByFields();
2294    
2295                            if (orderByFields.length > 0) {
2296                                    query.append(WHERE_AND);
2297                            }
2298    
2299                            for (int i = 0; i < orderByFields.length; i++) {
2300                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2301                                    query.append(orderByFields[i]);
2302    
2303                                    if ((i + 1) < orderByFields.length) {
2304                                            if (orderByComparator.isAscending() ^ previous) {
2305                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2306                                            }
2307                                            else {
2308                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2309                                            }
2310                                    }
2311                                    else {
2312                                            if (orderByComparator.isAscending() ^ previous) {
2313                                                    query.append(WHERE_GREATER_THAN);
2314                                            }
2315                                            else {
2316                                                    query.append(WHERE_LESSER_THAN);
2317                                            }
2318                                    }
2319                            }
2320    
2321                            query.append(ORDER_BY_CLAUSE);
2322    
2323                            for (int i = 0; i < orderByFields.length; i++) {
2324                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2325                                    query.append(orderByFields[i]);
2326    
2327                                    if ((i + 1) < orderByFields.length) {
2328                                            if (orderByComparator.isAscending() ^ previous) {
2329                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2330                                            }
2331                                            else {
2332                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2333                                            }
2334                                    }
2335                                    else {
2336                                            if (orderByComparator.isAscending() ^ previous) {
2337                                                    query.append(ORDER_BY_ASC);
2338                                            }
2339                                            else {
2340                                                    query.append(ORDER_BY_DESC);
2341                                            }
2342                                    }
2343                            }
2344                    }
2345    
2346                    else {
2347                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2348                    }
2349    
2350                    String sql = query.toString();
2351    
2352                    Query q = session.createQuery(sql);
2353    
2354                    q.setFirstResult(0);
2355                    q.setMaxResults(2);
2356    
2357                    QueryPos qPos = QueryPos.getInstance(q);
2358    
2359                    qPos.add(resourcePrimKey);
2360    
2361                    qPos.add(nodeId);
2362    
2363                    if (orderByComparator != null) {
2364                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
2365    
2366                            for (Object value : values) {
2367                                    qPos.add(value);
2368                            }
2369                    }
2370    
2371                    List<WikiPage> list = q.list();
2372    
2373                    if (list.size() == 2) {
2374                            return list.get(1);
2375                    }
2376                    else {
2377                            return null;
2378                    }
2379            }
2380    
2381            /**
2382             * Finds all the wiki pages where nodeId = &#63; and title = &#63;.
2383             *
2384             * @param nodeId the node id to search with
2385             * @param title the title to search with
2386             * @return the matching wiki pages
2387             * @throws SystemException if a system exception occurred
2388             */
2389            public List<WikiPage> findByN_T(long nodeId, String title)
2390                    throws SystemException {
2391                    return findByN_T(nodeId, title, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2392                            null);
2393            }
2394    
2395            /**
2396             * Finds a range of all the wiki pages where nodeId = &#63; and title = &#63;.
2397             *
2398             * <p>
2399             * 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.
2400             * </p>
2401             *
2402             * @param nodeId the node id to search with
2403             * @param title the title to search with
2404             * @param start the lower bound of the range of wiki pages to return
2405             * @param end the upper bound of the range of wiki pages to return (not inclusive)
2406             * @return the range of matching wiki pages
2407             * @throws SystemException if a system exception occurred
2408             */
2409            public List<WikiPage> findByN_T(long nodeId, String title, int start,
2410                    int end) throws SystemException {
2411                    return findByN_T(nodeId, title, start, end, null);
2412            }
2413    
2414            /**
2415             * Finds an ordered range of all the wiki pages where nodeId = &#63; and title = &#63;.
2416             *
2417             * <p>
2418             * 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.
2419             * </p>
2420             *
2421             * @param nodeId the node id to search with
2422             * @param title the title to search with
2423             * @param start the lower bound of the range of wiki pages to return
2424             * @param end the upper bound of the range of wiki pages to return (not inclusive)
2425             * @param orderByComparator the comparator to order the results by
2426             * @return the ordered range of matching wiki pages
2427             * @throws SystemException if a system exception occurred
2428             */
2429            public List<WikiPage> findByN_T(long nodeId, String title, int start,
2430                    int end, OrderByComparator orderByComparator) throws SystemException {
2431                    Object[] finderArgs = new Object[] {
2432                                    nodeId, title,
2433                                    
2434                                    String.valueOf(start), String.valueOf(end),
2435                                    String.valueOf(orderByComparator)
2436                            };
2437    
2438                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_T,
2439                                    finderArgs, this);
2440    
2441                    if (list == null) {
2442                            Session session = null;
2443    
2444                            try {
2445                                    session = openSession();
2446    
2447                                    StringBundler query = null;
2448    
2449                                    if (orderByComparator != null) {
2450                                            query = new StringBundler(4 +
2451                                                            (orderByComparator.getOrderByFields().length * 3));
2452                                    }
2453                                    else {
2454                                            query = new StringBundler(4);
2455                                    }
2456    
2457                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2458    
2459                                    query.append(_FINDER_COLUMN_N_T_NODEID_2);
2460    
2461                                    if (title == null) {
2462                                            query.append(_FINDER_COLUMN_N_T_TITLE_1);
2463                                    }
2464                                    else {
2465                                            if (title.equals(StringPool.BLANK)) {
2466                                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
2467                                            }
2468                                            else {
2469                                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
2470                                            }
2471                                    }
2472    
2473                                    if (orderByComparator != null) {
2474                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2475                                                    orderByComparator);
2476                                    }
2477    
2478                                    else {
2479                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2480                                    }
2481    
2482                                    String sql = query.toString();
2483    
2484                                    Query q = session.createQuery(sql);
2485    
2486                                    QueryPos qPos = QueryPos.getInstance(q);
2487    
2488                                    qPos.add(nodeId);
2489    
2490                                    if (title != null) {
2491                                            qPos.add(title);
2492                                    }
2493    
2494                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2495                                                    end);
2496                            }
2497                            catch (Exception e) {
2498                                    throw processException(e);
2499                            }
2500                            finally {
2501                                    if (list == null) {
2502                                            list = new ArrayList<WikiPage>();
2503                                    }
2504    
2505                                    cacheResult(list);
2506    
2507                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_T, finderArgs,
2508                                            list);
2509    
2510                                    closeSession(session);
2511                            }
2512                    }
2513    
2514                    return list;
2515            }
2516    
2517            /**
2518             * Finds the first wiki page in the ordered set where nodeId = &#63; and title = &#63;.
2519             *
2520             * <p>
2521             * 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.
2522             * </p>
2523             *
2524             * @param nodeId the node id to search with
2525             * @param title the title to search with
2526             * @param orderByComparator the comparator to order the set by
2527             * @return the first matching wiki page
2528             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2529             * @throws SystemException if a system exception occurred
2530             */
2531            public WikiPage findByN_T_First(long nodeId, String title,
2532                    OrderByComparator orderByComparator)
2533                    throws NoSuchPageException, SystemException {
2534                    List<WikiPage> list = findByN_T(nodeId, title, 0, 1, orderByComparator);
2535    
2536                    if (list.isEmpty()) {
2537                            StringBundler msg = new StringBundler(6);
2538    
2539                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2540    
2541                            msg.append("nodeId=");
2542                            msg.append(nodeId);
2543    
2544                            msg.append(", title=");
2545                            msg.append(title);
2546    
2547                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2548    
2549                            throw new NoSuchPageException(msg.toString());
2550                    }
2551                    else {
2552                            return list.get(0);
2553                    }
2554            }
2555    
2556            /**
2557             * Finds the last wiki page in the ordered set where nodeId = &#63; and title = &#63;.
2558             *
2559             * <p>
2560             * 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.
2561             * </p>
2562             *
2563             * @param nodeId the node id to search with
2564             * @param title the title to search with
2565             * @param orderByComparator the comparator to order the set by
2566             * @return the last matching wiki page
2567             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2568             * @throws SystemException if a system exception occurred
2569             */
2570            public WikiPage findByN_T_Last(long nodeId, String title,
2571                    OrderByComparator orderByComparator)
2572                    throws NoSuchPageException, SystemException {
2573                    int count = countByN_T(nodeId, title);
2574    
2575                    List<WikiPage> list = findByN_T(nodeId, title, count - 1, count,
2576                                    orderByComparator);
2577    
2578                    if (list.isEmpty()) {
2579                            StringBundler msg = new StringBundler(6);
2580    
2581                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2582    
2583                            msg.append("nodeId=");
2584                            msg.append(nodeId);
2585    
2586                            msg.append(", title=");
2587                            msg.append(title);
2588    
2589                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2590    
2591                            throw new NoSuchPageException(msg.toString());
2592                    }
2593                    else {
2594                            return list.get(0);
2595                    }
2596            }
2597    
2598            /**
2599             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63;.
2600             *
2601             * <p>
2602             * 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.
2603             * </p>
2604             *
2605             * @param pageId the primary key of the current wiki page
2606             * @param nodeId the node id to search with
2607             * @param title the title to search with
2608             * @param orderByComparator the comparator to order the set by
2609             * @return the previous, current, and next wiki page
2610             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2611             * @throws SystemException if a system exception occurred
2612             */
2613            public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
2614                    String title, OrderByComparator orderByComparator)
2615                    throws NoSuchPageException, SystemException {
2616                    WikiPage wikiPage = findByPrimaryKey(pageId);
2617    
2618                    Session session = null;
2619    
2620                    try {
2621                            session = openSession();
2622    
2623                            WikiPage[] array = new WikiPageImpl[3];
2624    
2625                            array[0] = getByN_T_PrevAndNext(session, wikiPage, nodeId, title,
2626                                            orderByComparator, true);
2627    
2628                            array[1] = wikiPage;
2629    
2630                            array[2] = getByN_T_PrevAndNext(session, wikiPage, nodeId, title,
2631                                            orderByComparator, false);
2632    
2633                            return array;
2634                    }
2635                    catch (Exception e) {
2636                            throw processException(e);
2637                    }
2638                    finally {
2639                            closeSession(session);
2640                    }
2641            }
2642    
2643            protected WikiPage getByN_T_PrevAndNext(Session session, WikiPage wikiPage,
2644                    long nodeId, String title, OrderByComparator orderByComparator,
2645                    boolean previous) {
2646                    StringBundler query = null;
2647    
2648                    if (orderByComparator != null) {
2649                            query = new StringBundler(6 +
2650                                            (orderByComparator.getOrderByFields().length * 6));
2651                    }
2652                    else {
2653                            query = new StringBundler(3);
2654                    }
2655    
2656                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2657    
2658                    query.append(_FINDER_COLUMN_N_T_NODEID_2);
2659    
2660                    if (title == null) {
2661                            query.append(_FINDER_COLUMN_N_T_TITLE_1);
2662                    }
2663                    else {
2664                            if (title.equals(StringPool.BLANK)) {
2665                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
2666                            }
2667                            else {
2668                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
2669                            }
2670                    }
2671    
2672                    if (orderByComparator != null) {
2673                            String[] orderByFields = orderByComparator.getOrderByFields();
2674    
2675                            if (orderByFields.length > 0) {
2676                                    query.append(WHERE_AND);
2677                            }
2678    
2679                            for (int i = 0; i < orderByFields.length; i++) {
2680                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2681                                    query.append(orderByFields[i]);
2682    
2683                                    if ((i + 1) < orderByFields.length) {
2684                                            if (orderByComparator.isAscending() ^ previous) {
2685                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2686                                            }
2687                                            else {
2688                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2689                                            }
2690                                    }
2691                                    else {
2692                                            if (orderByComparator.isAscending() ^ previous) {
2693                                                    query.append(WHERE_GREATER_THAN);
2694                                            }
2695                                            else {
2696                                                    query.append(WHERE_LESSER_THAN);
2697                                            }
2698                                    }
2699                            }
2700    
2701                            query.append(ORDER_BY_CLAUSE);
2702    
2703                            for (int i = 0; i < orderByFields.length; i++) {
2704                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2705                                    query.append(orderByFields[i]);
2706    
2707                                    if ((i + 1) < orderByFields.length) {
2708                                            if (orderByComparator.isAscending() ^ previous) {
2709                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2710                                            }
2711                                            else {
2712                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2713                                            }
2714                                    }
2715                                    else {
2716                                            if (orderByComparator.isAscending() ^ previous) {
2717                                                    query.append(ORDER_BY_ASC);
2718                                            }
2719                                            else {
2720                                                    query.append(ORDER_BY_DESC);
2721                                            }
2722                                    }
2723                            }
2724                    }
2725    
2726                    else {
2727                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2728                    }
2729    
2730                    String sql = query.toString();
2731    
2732                    Query q = session.createQuery(sql);
2733    
2734                    q.setFirstResult(0);
2735                    q.setMaxResults(2);
2736    
2737                    QueryPos qPos = QueryPos.getInstance(q);
2738    
2739                    qPos.add(nodeId);
2740    
2741                    if (title != null) {
2742                            qPos.add(title);
2743                    }
2744    
2745                    if (orderByComparator != null) {
2746                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
2747    
2748                            for (Object value : values) {
2749                                    qPos.add(value);
2750                            }
2751                    }
2752    
2753                    List<WikiPage> list = q.list();
2754    
2755                    if (list.size() == 2) {
2756                            return list.get(1);
2757                    }
2758                    else {
2759                            return null;
2760                    }
2761            }
2762    
2763            /**
2764             * Finds all the wiki pages where nodeId = &#63; and head = &#63;.
2765             *
2766             * @param nodeId the node id to search with
2767             * @param head the head to search with
2768             * @return the matching wiki pages
2769             * @throws SystemException if a system exception occurred
2770             */
2771            public List<WikiPage> findByN_H(long nodeId, boolean head)
2772                    throws SystemException {
2773                    return findByN_H(nodeId, head, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2774                            null);
2775            }
2776    
2777            /**
2778             * Finds a range of all the wiki pages where nodeId = &#63; and head = &#63;.
2779             *
2780             * <p>
2781             * 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.
2782             * </p>
2783             *
2784             * @param nodeId the node id to search with
2785             * @param head the head to search with
2786             * @param start the lower bound of the range of wiki pages to return
2787             * @param end the upper bound of the range of wiki pages to return (not inclusive)
2788             * @return the range of matching wiki pages
2789             * @throws SystemException if a system exception occurred
2790             */
2791            public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
2792                    int end) throws SystemException {
2793                    return findByN_H(nodeId, head, start, end, null);
2794            }
2795    
2796            /**
2797             * Finds an ordered range of all the wiki pages where nodeId = &#63; and head = &#63;.
2798             *
2799             * <p>
2800             * 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.
2801             * </p>
2802             *
2803             * @param nodeId the node id to search with
2804             * @param head the head to search with
2805             * @param start the lower bound of the range of wiki pages to return
2806             * @param end the upper bound of the range of wiki pages to return (not inclusive)
2807             * @param orderByComparator the comparator to order the results by
2808             * @return the ordered range of matching wiki pages
2809             * @throws SystemException if a system exception occurred
2810             */
2811            public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
2812                    int end, OrderByComparator orderByComparator) throws SystemException {
2813                    Object[] finderArgs = new Object[] {
2814                                    nodeId, head,
2815                                    
2816                                    String.valueOf(start), String.valueOf(end),
2817                                    String.valueOf(orderByComparator)
2818                            };
2819    
2820                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_H,
2821                                    finderArgs, this);
2822    
2823                    if (list == null) {
2824                            Session session = null;
2825    
2826                            try {
2827                                    session = openSession();
2828    
2829                                    StringBundler query = null;
2830    
2831                                    if (orderByComparator != null) {
2832                                            query = new StringBundler(4 +
2833                                                            (orderByComparator.getOrderByFields().length * 3));
2834                                    }
2835                                    else {
2836                                            query = new StringBundler(4);
2837                                    }
2838    
2839                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2840    
2841                                    query.append(_FINDER_COLUMN_N_H_NODEID_2);
2842    
2843                                    query.append(_FINDER_COLUMN_N_H_HEAD_2);
2844    
2845                                    if (orderByComparator != null) {
2846                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2847                                                    orderByComparator);
2848                                    }
2849    
2850                                    else {
2851                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2852                                    }
2853    
2854                                    String sql = query.toString();
2855    
2856                                    Query q = session.createQuery(sql);
2857    
2858                                    QueryPos qPos = QueryPos.getInstance(q);
2859    
2860                                    qPos.add(nodeId);
2861    
2862                                    qPos.add(head);
2863    
2864                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2865                                                    end);
2866                            }
2867                            catch (Exception e) {
2868                                    throw processException(e);
2869                            }
2870                            finally {
2871                                    if (list == null) {
2872                                            list = new ArrayList<WikiPage>();
2873                                    }
2874    
2875                                    cacheResult(list);
2876    
2877                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_H, finderArgs,
2878                                            list);
2879    
2880                                    closeSession(session);
2881                            }
2882                    }
2883    
2884                    return list;
2885            }
2886    
2887            /**
2888             * Finds the first wiki page in the ordered set where nodeId = &#63; and head = &#63;.
2889             *
2890             * <p>
2891             * 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.
2892             * </p>
2893             *
2894             * @param nodeId the node id to search with
2895             * @param head the head to search with
2896             * @param orderByComparator the comparator to order the set by
2897             * @return the first matching wiki page
2898             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2899             * @throws SystemException if a system exception occurred
2900             */
2901            public WikiPage findByN_H_First(long nodeId, boolean head,
2902                    OrderByComparator orderByComparator)
2903                    throws NoSuchPageException, SystemException {
2904                    List<WikiPage> list = findByN_H(nodeId, head, 0, 1, orderByComparator);
2905    
2906                    if (list.isEmpty()) {
2907                            StringBundler msg = new StringBundler(6);
2908    
2909                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2910    
2911                            msg.append("nodeId=");
2912                            msg.append(nodeId);
2913    
2914                            msg.append(", head=");
2915                            msg.append(head);
2916    
2917                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2918    
2919                            throw new NoSuchPageException(msg.toString());
2920                    }
2921                    else {
2922                            return list.get(0);
2923                    }
2924            }
2925    
2926            /**
2927             * Finds the last wiki page in the ordered set where nodeId = &#63; and head = &#63;.
2928             *
2929             * <p>
2930             * 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.
2931             * </p>
2932             *
2933             * @param nodeId the node id to search with
2934             * @param head the head to search with
2935             * @param orderByComparator the comparator to order the set by
2936             * @return the last matching wiki page
2937             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2938             * @throws SystemException if a system exception occurred
2939             */
2940            public WikiPage findByN_H_Last(long nodeId, boolean head,
2941                    OrderByComparator orderByComparator)
2942                    throws NoSuchPageException, SystemException {
2943                    int count = countByN_H(nodeId, head);
2944    
2945                    List<WikiPage> list = findByN_H(nodeId, head, count - 1, count,
2946                                    orderByComparator);
2947    
2948                    if (list.isEmpty()) {
2949                            StringBundler msg = new StringBundler(6);
2950    
2951                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2952    
2953                            msg.append("nodeId=");
2954                            msg.append(nodeId);
2955    
2956                            msg.append(", head=");
2957                            msg.append(head);
2958    
2959                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2960    
2961                            throw new NoSuchPageException(msg.toString());
2962                    }
2963                    else {
2964                            return list.get(0);
2965                    }
2966            }
2967    
2968            /**
2969             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63;.
2970             *
2971             * <p>
2972             * 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.
2973             * </p>
2974             *
2975             * @param pageId the primary key of the current wiki page
2976             * @param nodeId the node id to search with
2977             * @param head the head to search with
2978             * @param orderByComparator the comparator to order the set by
2979             * @return the previous, current, and next wiki page
2980             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2981             * @throws SystemException if a system exception occurred
2982             */
2983            public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
2984                    boolean head, OrderByComparator orderByComparator)
2985                    throws NoSuchPageException, SystemException {
2986                    WikiPage wikiPage = findByPrimaryKey(pageId);
2987    
2988                    Session session = null;
2989    
2990                    try {
2991                            session = openSession();
2992    
2993                            WikiPage[] array = new WikiPageImpl[3];
2994    
2995                            array[0] = getByN_H_PrevAndNext(session, wikiPage, nodeId, head,
2996                                            orderByComparator, true);
2997    
2998                            array[1] = wikiPage;
2999    
3000                            array[2] = getByN_H_PrevAndNext(session, wikiPage, nodeId, head,
3001                                            orderByComparator, false);
3002    
3003                            return array;
3004                    }
3005                    catch (Exception e) {
3006                            throw processException(e);
3007                    }
3008                    finally {
3009                            closeSession(session);
3010                    }
3011            }
3012    
3013            protected WikiPage getByN_H_PrevAndNext(Session session, WikiPage wikiPage,
3014                    long nodeId, boolean head, OrderByComparator orderByComparator,
3015                    boolean previous) {
3016                    StringBundler query = null;
3017    
3018                    if (orderByComparator != null) {
3019                            query = new StringBundler(6 +
3020                                            (orderByComparator.getOrderByFields().length * 6));
3021                    }
3022                    else {
3023                            query = new StringBundler(3);
3024                    }
3025    
3026                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3027    
3028                    query.append(_FINDER_COLUMN_N_H_NODEID_2);
3029    
3030                    query.append(_FINDER_COLUMN_N_H_HEAD_2);
3031    
3032                    if (orderByComparator != null) {
3033                            String[] orderByFields = orderByComparator.getOrderByFields();
3034    
3035                            if (orderByFields.length > 0) {
3036                                    query.append(WHERE_AND);
3037                            }
3038    
3039                            for (int i = 0; i < orderByFields.length; i++) {
3040                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3041                                    query.append(orderByFields[i]);
3042    
3043                                    if ((i + 1) < orderByFields.length) {
3044                                            if (orderByComparator.isAscending() ^ previous) {
3045                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3046                                            }
3047                                            else {
3048                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3049                                            }
3050                                    }
3051                                    else {
3052                                            if (orderByComparator.isAscending() ^ previous) {
3053                                                    query.append(WHERE_GREATER_THAN);
3054                                            }
3055                                            else {
3056                                                    query.append(WHERE_LESSER_THAN);
3057                                            }
3058                                    }
3059                            }
3060    
3061                            query.append(ORDER_BY_CLAUSE);
3062    
3063                            for (int i = 0; i < orderByFields.length; i++) {
3064                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3065                                    query.append(orderByFields[i]);
3066    
3067                                    if ((i + 1) < orderByFields.length) {
3068                                            if (orderByComparator.isAscending() ^ previous) {
3069                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3070                                            }
3071                                            else {
3072                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3073                                            }
3074                                    }
3075                                    else {
3076                                            if (orderByComparator.isAscending() ^ previous) {
3077                                                    query.append(ORDER_BY_ASC);
3078                                            }
3079                                            else {
3080                                                    query.append(ORDER_BY_DESC);
3081                                            }
3082                                    }
3083                            }
3084                    }
3085    
3086                    else {
3087                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3088                    }
3089    
3090                    String sql = query.toString();
3091    
3092                    Query q = session.createQuery(sql);
3093    
3094                    q.setFirstResult(0);
3095                    q.setMaxResults(2);
3096    
3097                    QueryPos qPos = QueryPos.getInstance(q);
3098    
3099                    qPos.add(nodeId);
3100    
3101                    qPos.add(head);
3102    
3103                    if (orderByComparator != null) {
3104                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
3105    
3106                            for (Object value : values) {
3107                                    qPos.add(value);
3108                            }
3109                    }
3110    
3111                    List<WikiPage> list = q.list();
3112    
3113                    if (list.size() == 2) {
3114                            return list.get(1);
3115                    }
3116                    else {
3117                            return null;
3118                    }
3119            }
3120    
3121            /**
3122             * Finds all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
3123             *
3124             * @param nodeId the node id to search with
3125             * @param parentTitle the parent title to search with
3126             * @return the matching wiki pages
3127             * @throws SystemException if a system exception occurred
3128             */
3129            public List<WikiPage> findByN_P(long nodeId, String parentTitle)
3130                    throws SystemException {
3131                    return findByN_P(nodeId, parentTitle, QueryUtil.ALL_POS,
3132                            QueryUtil.ALL_POS, null);
3133            }
3134    
3135            /**
3136             * Finds a range of all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
3137             *
3138             * <p>
3139             * 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.
3140             * </p>
3141             *
3142             * @param nodeId the node id to search with
3143             * @param parentTitle the parent title to search with
3144             * @param start the lower bound of the range of wiki pages to return
3145             * @param end the upper bound of the range of wiki pages to return (not inclusive)
3146             * @return the range of matching wiki pages
3147             * @throws SystemException if a system exception occurred
3148             */
3149            public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
3150                    int end) throws SystemException {
3151                    return findByN_P(nodeId, parentTitle, start, end, null);
3152            }
3153    
3154            /**
3155             * Finds an ordered range of all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
3156             *
3157             * <p>
3158             * 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.
3159             * </p>
3160             *
3161             * @param nodeId the node id to search with
3162             * @param parentTitle the parent title to search with
3163             * @param start the lower bound of the range of wiki pages to return
3164             * @param end the upper bound of the range of wiki pages to return (not inclusive)
3165             * @param orderByComparator the comparator to order the results by
3166             * @return the ordered range of matching wiki pages
3167             * @throws SystemException if a system exception occurred
3168             */
3169            public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
3170                    int end, OrderByComparator orderByComparator) throws SystemException {
3171                    Object[] finderArgs = new Object[] {
3172                                    nodeId, parentTitle,
3173                                    
3174                                    String.valueOf(start), String.valueOf(end),
3175                                    String.valueOf(orderByComparator)
3176                            };
3177    
3178                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_P,
3179                                    finderArgs, this);
3180    
3181                    if (list == null) {
3182                            Session session = null;
3183    
3184                            try {
3185                                    session = openSession();
3186    
3187                                    StringBundler query = null;
3188    
3189                                    if (orderByComparator != null) {
3190                                            query = new StringBundler(4 +
3191                                                            (orderByComparator.getOrderByFields().length * 3));
3192                                    }
3193                                    else {
3194                                            query = new StringBundler(4);
3195                                    }
3196    
3197                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3198    
3199                                    query.append(_FINDER_COLUMN_N_P_NODEID_2);
3200    
3201                                    if (parentTitle == null) {
3202                                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
3203                                    }
3204                                    else {
3205                                            if (parentTitle.equals(StringPool.BLANK)) {
3206                                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
3207                                            }
3208                                            else {
3209                                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
3210                                            }
3211                                    }
3212    
3213                                    if (orderByComparator != null) {
3214                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3215                                                    orderByComparator);
3216                                    }
3217    
3218                                    else {
3219                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3220                                    }
3221    
3222                                    String sql = query.toString();
3223    
3224                                    Query q = session.createQuery(sql);
3225    
3226                                    QueryPos qPos = QueryPos.getInstance(q);
3227    
3228                                    qPos.add(nodeId);
3229    
3230                                    if (parentTitle != null) {
3231                                            qPos.add(parentTitle);
3232                                    }
3233    
3234                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
3235                                                    end);
3236                            }
3237                            catch (Exception e) {
3238                                    throw processException(e);
3239                            }
3240                            finally {
3241                                    if (list == null) {
3242                                            list = new ArrayList<WikiPage>();
3243                                    }
3244    
3245                                    cacheResult(list);
3246    
3247                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_P, finderArgs,
3248                                            list);
3249    
3250                                    closeSession(session);
3251                            }
3252                    }
3253    
3254                    return list;
3255            }
3256    
3257            /**
3258             * Finds the first wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
3259             *
3260             * <p>
3261             * 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.
3262             * </p>
3263             *
3264             * @param nodeId the node id to search with
3265             * @param parentTitle the parent title to search with
3266             * @param orderByComparator the comparator to order the set by
3267             * @return the first matching wiki page
3268             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3269             * @throws SystemException if a system exception occurred
3270             */
3271            public WikiPage findByN_P_First(long nodeId, String parentTitle,
3272                    OrderByComparator orderByComparator)
3273                    throws NoSuchPageException, SystemException {
3274                    List<WikiPage> list = findByN_P(nodeId, parentTitle, 0, 1,
3275                                    orderByComparator);
3276    
3277                    if (list.isEmpty()) {
3278                            StringBundler msg = new StringBundler(6);
3279    
3280                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3281    
3282                            msg.append("nodeId=");
3283                            msg.append(nodeId);
3284    
3285                            msg.append(", parentTitle=");
3286                            msg.append(parentTitle);
3287    
3288                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3289    
3290                            throw new NoSuchPageException(msg.toString());
3291                    }
3292                    else {
3293                            return list.get(0);
3294                    }
3295            }
3296    
3297            /**
3298             * Finds the last wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
3299             *
3300             * <p>
3301             * 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.
3302             * </p>
3303             *
3304             * @param nodeId the node id to search with
3305             * @param parentTitle the parent title to search with
3306             * @param orderByComparator the comparator to order the set by
3307             * @return the last matching wiki page
3308             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3309             * @throws SystemException if a system exception occurred
3310             */
3311            public WikiPage findByN_P_Last(long nodeId, String parentTitle,
3312                    OrderByComparator orderByComparator)
3313                    throws NoSuchPageException, SystemException {
3314                    int count = countByN_P(nodeId, parentTitle);
3315    
3316                    List<WikiPage> list = findByN_P(nodeId, parentTitle, count - 1, count,
3317                                    orderByComparator);
3318    
3319                    if (list.isEmpty()) {
3320                            StringBundler msg = new StringBundler(6);
3321    
3322                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3323    
3324                            msg.append("nodeId=");
3325                            msg.append(nodeId);
3326    
3327                            msg.append(", parentTitle=");
3328                            msg.append(parentTitle);
3329    
3330                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3331    
3332                            throw new NoSuchPageException(msg.toString());
3333                    }
3334                    else {
3335                            return list.get(0);
3336                    }
3337            }
3338    
3339            /**
3340             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
3341             *
3342             * <p>
3343             * 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.
3344             * </p>
3345             *
3346             * @param pageId the primary key of the current wiki page
3347             * @param nodeId the node id to search with
3348             * @param parentTitle the parent title to search with
3349             * @param orderByComparator the comparator to order the set by
3350             * @return the previous, current, and next wiki page
3351             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
3352             * @throws SystemException if a system exception occurred
3353             */
3354            public WikiPage[] findByN_P_PrevAndNext(long pageId, long nodeId,
3355                    String parentTitle, OrderByComparator orderByComparator)
3356                    throws NoSuchPageException, SystemException {
3357                    WikiPage wikiPage = findByPrimaryKey(pageId);
3358    
3359                    Session session = null;
3360    
3361                    try {
3362                            session = openSession();
3363    
3364                            WikiPage[] array = new WikiPageImpl[3];
3365    
3366                            array[0] = getByN_P_PrevAndNext(session, wikiPage, nodeId,
3367                                            parentTitle, orderByComparator, true);
3368    
3369                            array[1] = wikiPage;
3370    
3371                            array[2] = getByN_P_PrevAndNext(session, wikiPage, nodeId,
3372                                            parentTitle, orderByComparator, false);
3373    
3374                            return array;
3375                    }
3376                    catch (Exception e) {
3377                            throw processException(e);
3378                    }
3379                    finally {
3380                            closeSession(session);
3381                    }
3382            }
3383    
3384            protected WikiPage getByN_P_PrevAndNext(Session session, WikiPage wikiPage,
3385                    long nodeId, String parentTitle, OrderByComparator orderByComparator,
3386                    boolean previous) {
3387                    StringBundler query = null;
3388    
3389                    if (orderByComparator != null) {
3390                            query = new StringBundler(6 +
3391                                            (orderByComparator.getOrderByFields().length * 6));
3392                    }
3393                    else {
3394                            query = new StringBundler(3);
3395                    }
3396    
3397                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3398    
3399                    query.append(_FINDER_COLUMN_N_P_NODEID_2);
3400    
3401                    if (parentTitle == null) {
3402                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
3403                    }
3404                    else {
3405                            if (parentTitle.equals(StringPool.BLANK)) {
3406                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
3407                            }
3408                            else {
3409                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
3410                            }
3411                    }
3412    
3413                    if (orderByComparator != null) {
3414                            String[] orderByFields = orderByComparator.getOrderByFields();
3415    
3416                            if (orderByFields.length > 0) {
3417                                    query.append(WHERE_AND);
3418                            }
3419    
3420                            for (int i = 0; i < orderByFields.length; i++) {
3421                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3422                                    query.append(orderByFields[i]);
3423    
3424                                    if ((i + 1) < orderByFields.length) {
3425                                            if (orderByComparator.isAscending() ^ previous) {
3426                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3427                                            }
3428                                            else {
3429                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3430                                            }
3431                                    }
3432                                    else {
3433                                            if (orderByComparator.isAscending() ^ previous) {
3434                                                    query.append(WHERE_GREATER_THAN);
3435                                            }
3436                                            else {
3437                                                    query.append(WHERE_LESSER_THAN);
3438                                            }
3439                                    }
3440                            }
3441    
3442                            query.append(ORDER_BY_CLAUSE);
3443    
3444                            for (int i = 0; i < orderByFields.length; i++) {
3445                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3446                                    query.append(orderByFields[i]);
3447    
3448                                    if ((i + 1) < orderByFields.length) {
3449                                            if (orderByComparator.isAscending() ^ previous) {
3450                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3451                                            }
3452                                            else {
3453                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3454                                            }
3455                                    }
3456                                    else {
3457                                            if (orderByComparator.isAscending() ^ previous) {
3458                                                    query.append(ORDER_BY_ASC);
3459                                            }
3460                                            else {
3461                                                    query.append(ORDER_BY_DESC);
3462                                            }
3463                                    }
3464                            }
3465                    }
3466    
3467                    else {
3468                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3469                    }
3470    
3471                    String sql = query.toString();
3472    
3473                    Query q = session.createQuery(sql);
3474    
3475                    q.setFirstResult(0);
3476                    q.setMaxResults(2);
3477    
3478                    QueryPos qPos = QueryPos.getInstance(q);
3479    
3480                    qPos.add(nodeId);
3481    
3482                    if (parentTitle != null) {
3483                            qPos.add(parentTitle);
3484                    }
3485    
3486                    if (orderByComparator != null) {
3487                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
3488    
3489                            for (Object value : values) {
3490                                    qPos.add(value);
3491                            }
3492                    }
3493    
3494                    List<WikiPage> list = q.list();
3495    
3496                    if (list.size() == 2) {
3497                            return list.get(1);
3498                    }
3499                    else {
3500                            return null;
3501                    }
3502            }
3503    
3504            /**
3505             * Finds all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
3506             *
3507             * @param nodeId the node id to search with
3508             * @param redirectTitle the redirect title to search with
3509             * @return the matching wiki pages
3510             * @throws SystemException if a system exception occurred
3511             */
3512            public List<WikiPage> findByN_R(long nodeId, String redirectTitle)
3513                    throws SystemException {
3514                    return findByN_R(nodeId, redirectTitle, QueryUtil.ALL_POS,
3515                            QueryUtil.ALL_POS, null);
3516            }
3517    
3518            /**
3519             * Finds a range of all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
3520             *
3521             * <p>
3522             * 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.
3523             * </p>
3524             *
3525             * @param nodeId the node id to search with
3526             * @param redirectTitle the redirect title to search with
3527             * @param start the lower bound of the range of wiki pages to return
3528             * @param end the upper bound of the range of wiki pages to return (not inclusive)
3529             * @return the range of matching wiki pages
3530             * @throws SystemException if a system exception occurred
3531             */
3532            public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
3533                    int start, int end) throws SystemException {
3534                    return findByN_R(nodeId, redirectTitle, start, end, null);
3535            }
3536    
3537            /**
3538             * Finds an ordered range of all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
3539             *
3540             * <p>
3541             * 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.
3542             * </p>
3543             *
3544             * @param nodeId the node id to search with
3545             * @param redirectTitle the redirect title to search with
3546             * @param start the lower bound of the range of wiki pages to return
3547             * @param end the upper bound of the range of wiki pages to return (not inclusive)
3548             * @param orderByComparator the comparator to order the results by
3549             * @return the ordered range of matching wiki pages
3550             * @throws SystemException if a system exception occurred
3551             */
3552            public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
3553                    int start, int end, OrderByComparator orderByComparator)
3554                    throws SystemException {
3555                    Object[] finderArgs = new Object[] {
3556                                    nodeId, redirectTitle,
3557                                    
3558                                    String.valueOf(start), String.valueOf(end),
3559                                    String.valueOf(orderByComparator)
3560                            };
3561    
3562                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_R,
3563                                    finderArgs, this);
3564    
3565                    if (list == null) {
3566                            Session session = null;
3567    
3568                            try {
3569                                    session = openSession();
3570    
3571                                    StringBundler query = null;
3572    
3573                                    if (orderByComparator != null) {
3574                                            query = new StringBundler(4 +
3575                                                            (orderByComparator.getOrderByFields().length * 3));
3576                                    }
3577                                    else {
3578                                            query = new StringBundler(4);
3579                                    }
3580    
3581                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3582    
3583                                    query.append(_FINDER_COLUMN_N_R_NODEID_2);
3584    
3585                                    if (redirectTitle == null) {
3586                                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
3587                                    }
3588                                    else {
3589                                            if (redirectTitle.equals(StringPool.BLANK)) {
3590                                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
3591                                            }
3592                                            else {
3593                                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
3594                                            }
3595                                    }
3596    
3597                                    if (orderByComparator != null) {
3598                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3599                                                    orderByComparator);
3600                                    }
3601    
3602                                    else {
3603                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3604                                    }
3605    
3606                                    String sql = query.toString();
3607    
3608                                    Query q = session.createQuery(sql);
3609    
3610                                    QueryPos qPos = QueryPos.getInstance(q);
3611    
3612                                    qPos.add(nodeId);
3613    
3614                                    if (redirectTitle != null) {
3615                                            qPos.add(redirectTitle);
3616                                    }
3617    
3618                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
3619                                                    end);
3620                            }
3621                            catch (Exception e) {
3622                                    throw processException(e);
3623                            }
3624                            finally {
3625                                    if (list == null) {
3626                                            list = new ArrayList<WikiPage>();
3627                                    }
3628    
3629                                    cacheResult(list);
3630    
3631                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_R, finderArgs,
3632                                            list);
3633    
3634                                    closeSession(session);
3635                            }
3636                    }
3637    
3638                    return list;
3639            }
3640    
3641            /**
3642             * Finds the first wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
3643             *
3644             * <p>
3645             * 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.
3646             * </p>
3647             *
3648             * @param nodeId the node id to search with
3649             * @param redirectTitle the redirect title to search with
3650             * @param orderByComparator the comparator to order the set by
3651             * @return the first matching wiki page
3652             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3653             * @throws SystemException if a system exception occurred
3654             */
3655            public WikiPage findByN_R_First(long nodeId, String redirectTitle,
3656                    OrderByComparator orderByComparator)
3657                    throws NoSuchPageException, SystemException {
3658                    List<WikiPage> list = findByN_R(nodeId, redirectTitle, 0, 1,
3659                                    orderByComparator);
3660    
3661                    if (list.isEmpty()) {
3662                            StringBundler msg = new StringBundler(6);
3663    
3664                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3665    
3666                            msg.append("nodeId=");
3667                            msg.append(nodeId);
3668    
3669                            msg.append(", redirectTitle=");
3670                            msg.append(redirectTitle);
3671    
3672                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3673    
3674                            throw new NoSuchPageException(msg.toString());
3675                    }
3676                    else {
3677                            return list.get(0);
3678                    }
3679            }
3680    
3681            /**
3682             * Finds the last wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
3683             *
3684             * <p>
3685             * 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.
3686             * </p>
3687             *
3688             * @param nodeId the node id to search with
3689             * @param redirectTitle the redirect title to search with
3690             * @param orderByComparator the comparator to order the set by
3691             * @return the last matching wiki page
3692             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3693             * @throws SystemException if a system exception occurred
3694             */
3695            public WikiPage findByN_R_Last(long nodeId, String redirectTitle,
3696                    OrderByComparator orderByComparator)
3697                    throws NoSuchPageException, SystemException {
3698                    int count = countByN_R(nodeId, redirectTitle);
3699    
3700                    List<WikiPage> list = findByN_R(nodeId, redirectTitle, count - 1,
3701                                    count, orderByComparator);
3702    
3703                    if (list.isEmpty()) {
3704                            StringBundler msg = new StringBundler(6);
3705    
3706                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3707    
3708                            msg.append("nodeId=");
3709                            msg.append(nodeId);
3710    
3711                            msg.append(", redirectTitle=");
3712                            msg.append(redirectTitle);
3713    
3714                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3715    
3716                            throw new NoSuchPageException(msg.toString());
3717                    }
3718                    else {
3719                            return list.get(0);
3720                    }
3721            }
3722    
3723            /**
3724             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
3725             *
3726             * <p>
3727             * 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.
3728             * </p>
3729             *
3730             * @param pageId the primary key of the current wiki page
3731             * @param nodeId the node id to search with
3732             * @param redirectTitle the redirect title to search with
3733             * @param orderByComparator the comparator to order the set by
3734             * @return the previous, current, and next wiki page
3735             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
3736             * @throws SystemException if a system exception occurred
3737             */
3738            public WikiPage[] findByN_R_PrevAndNext(long pageId, long nodeId,
3739                    String redirectTitle, OrderByComparator orderByComparator)
3740                    throws NoSuchPageException, SystemException {
3741                    WikiPage wikiPage = findByPrimaryKey(pageId);
3742    
3743                    Session session = null;
3744    
3745                    try {
3746                            session = openSession();
3747    
3748                            WikiPage[] array = new WikiPageImpl[3];
3749    
3750                            array[0] = getByN_R_PrevAndNext(session, wikiPage, nodeId,
3751                                            redirectTitle, orderByComparator, true);
3752    
3753                            array[1] = wikiPage;
3754    
3755                            array[2] = getByN_R_PrevAndNext(session, wikiPage, nodeId,
3756                                            redirectTitle, orderByComparator, false);
3757    
3758                            return array;
3759                    }
3760                    catch (Exception e) {
3761                            throw processException(e);
3762                    }
3763                    finally {
3764                            closeSession(session);
3765                    }
3766            }
3767    
3768            protected WikiPage getByN_R_PrevAndNext(Session session, WikiPage wikiPage,
3769                    long nodeId, String redirectTitle, OrderByComparator orderByComparator,
3770                    boolean previous) {
3771                    StringBundler query = null;
3772    
3773                    if (orderByComparator != null) {
3774                            query = new StringBundler(6 +
3775                                            (orderByComparator.getOrderByFields().length * 6));
3776                    }
3777                    else {
3778                            query = new StringBundler(3);
3779                    }
3780    
3781                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3782    
3783                    query.append(_FINDER_COLUMN_N_R_NODEID_2);
3784    
3785                    if (redirectTitle == null) {
3786                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
3787                    }
3788                    else {
3789                            if (redirectTitle.equals(StringPool.BLANK)) {
3790                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
3791                            }
3792                            else {
3793                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
3794                            }
3795                    }
3796    
3797                    if (orderByComparator != null) {
3798                            String[] orderByFields = orderByComparator.getOrderByFields();
3799    
3800                            if (orderByFields.length > 0) {
3801                                    query.append(WHERE_AND);
3802                            }
3803    
3804                            for (int i = 0; i < orderByFields.length; i++) {
3805                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3806                                    query.append(orderByFields[i]);
3807    
3808                                    if ((i + 1) < orderByFields.length) {
3809                                            if (orderByComparator.isAscending() ^ previous) {
3810                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3811                                            }
3812                                            else {
3813                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3814                                            }
3815                                    }
3816                                    else {
3817                                            if (orderByComparator.isAscending() ^ previous) {
3818                                                    query.append(WHERE_GREATER_THAN);
3819                                            }
3820                                            else {
3821                                                    query.append(WHERE_LESSER_THAN);
3822                                            }
3823                                    }
3824                            }
3825    
3826                            query.append(ORDER_BY_CLAUSE);
3827    
3828                            for (int i = 0; i < orderByFields.length; i++) {
3829                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3830                                    query.append(orderByFields[i]);
3831    
3832                                    if ((i + 1) < orderByFields.length) {
3833                                            if (orderByComparator.isAscending() ^ previous) {
3834                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3835                                            }
3836                                            else {
3837                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3838                                            }
3839                                    }
3840                                    else {
3841                                            if (orderByComparator.isAscending() ^ previous) {
3842                                                    query.append(ORDER_BY_ASC);
3843                                            }
3844                                            else {
3845                                                    query.append(ORDER_BY_DESC);
3846                                            }
3847                                    }
3848                            }
3849                    }
3850    
3851                    else {
3852                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3853                    }
3854    
3855                    String sql = query.toString();
3856    
3857                    Query q = session.createQuery(sql);
3858    
3859                    q.setFirstResult(0);
3860                    q.setMaxResults(2);
3861    
3862                    QueryPos qPos = QueryPos.getInstance(q);
3863    
3864                    qPos.add(nodeId);
3865    
3866                    if (redirectTitle != null) {
3867                            qPos.add(redirectTitle);
3868                    }
3869    
3870                    if (orderByComparator != null) {
3871                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
3872    
3873                            for (Object value : values) {
3874                                    qPos.add(value);
3875                            }
3876                    }
3877    
3878                    List<WikiPage> list = q.list();
3879    
3880                    if (list.size() == 2) {
3881                            return list.get(1);
3882                    }
3883                    else {
3884                            return null;
3885                    }
3886            }
3887    
3888            /**
3889             * Finds all the wiki pages where nodeId = &#63; and status = &#63;.
3890             *
3891             * @param nodeId the node id to search with
3892             * @param status the status to search with
3893             * @return the matching wiki pages
3894             * @throws SystemException if a system exception occurred
3895             */
3896            public List<WikiPage> findByN_S(long nodeId, int status)
3897                    throws SystemException {
3898                    return findByN_S(nodeId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3899                            null);
3900            }
3901    
3902            /**
3903             * Finds a range of all the wiki pages where nodeId = &#63; and status = &#63;.
3904             *
3905             * <p>
3906             * 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.
3907             * </p>
3908             *
3909             * @param nodeId the node id to search with
3910             * @param status the status to search with
3911             * @param start the lower bound of the range of wiki pages to return
3912             * @param end the upper bound of the range of wiki pages to return (not inclusive)
3913             * @return the range of matching wiki pages
3914             * @throws SystemException if a system exception occurred
3915             */
3916            public List<WikiPage> findByN_S(long nodeId, int status, int start, int end)
3917                    throws SystemException {
3918                    return findByN_S(nodeId, status, start, end, null);
3919            }
3920    
3921            /**
3922             * Finds an ordered range of all the wiki pages where nodeId = &#63; and status = &#63;.
3923             *
3924             * <p>
3925             * 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.
3926             * </p>
3927             *
3928             * @param nodeId the node id to search with
3929             * @param status the status to search with
3930             * @param start the lower bound of the range of wiki pages to return
3931             * @param end the upper bound of the range of wiki pages to return (not inclusive)
3932             * @param orderByComparator the comparator to order the results by
3933             * @return the ordered range of matching wiki pages
3934             * @throws SystemException if a system exception occurred
3935             */
3936            public List<WikiPage> findByN_S(long nodeId, int status, int start,
3937                    int end, OrderByComparator orderByComparator) throws SystemException {
3938                    Object[] finderArgs = new Object[] {
3939                                    nodeId, status,
3940                                    
3941                                    String.valueOf(start), String.valueOf(end),
3942                                    String.valueOf(orderByComparator)
3943                            };
3944    
3945                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_S,
3946                                    finderArgs, this);
3947    
3948                    if (list == null) {
3949                            Session session = null;
3950    
3951                            try {
3952                                    session = openSession();
3953    
3954                                    StringBundler query = null;
3955    
3956                                    if (orderByComparator != null) {
3957                                            query = new StringBundler(4 +
3958                                                            (orderByComparator.getOrderByFields().length * 3));
3959                                    }
3960                                    else {
3961                                            query = new StringBundler(4);
3962                                    }
3963    
3964                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3965    
3966                                    query.append(_FINDER_COLUMN_N_S_NODEID_2);
3967    
3968                                    query.append(_FINDER_COLUMN_N_S_STATUS_2);
3969    
3970                                    if (orderByComparator != null) {
3971                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3972                                                    orderByComparator);
3973                                    }
3974    
3975                                    else {
3976                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3977                                    }
3978    
3979                                    String sql = query.toString();
3980    
3981                                    Query q = session.createQuery(sql);
3982    
3983                                    QueryPos qPos = QueryPos.getInstance(q);
3984    
3985                                    qPos.add(nodeId);
3986    
3987                                    qPos.add(status);
3988    
3989                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
3990                                                    end);
3991                            }
3992                            catch (Exception e) {
3993                                    throw processException(e);
3994                            }
3995                            finally {
3996                                    if (list == null) {
3997                                            list = new ArrayList<WikiPage>();
3998                                    }
3999    
4000                                    cacheResult(list);
4001    
4002                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_S, finderArgs,
4003                                            list);
4004    
4005                                    closeSession(session);
4006                            }
4007                    }
4008    
4009                    return list;
4010            }
4011    
4012            /**
4013             * Finds the first wiki page in the ordered set where nodeId = &#63; and status = &#63;.
4014             *
4015             * <p>
4016             * 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.
4017             * </p>
4018             *
4019             * @param nodeId the node id to search with
4020             * @param status the status to search with
4021             * @param orderByComparator the comparator to order the set by
4022             * @return the first matching wiki page
4023             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4024             * @throws SystemException if a system exception occurred
4025             */
4026            public WikiPage findByN_S_First(long nodeId, int status,
4027                    OrderByComparator orderByComparator)
4028                    throws NoSuchPageException, SystemException {
4029                    List<WikiPage> list = findByN_S(nodeId, status, 0, 1, orderByComparator);
4030    
4031                    if (list.isEmpty()) {
4032                            StringBundler msg = new StringBundler(6);
4033    
4034                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4035    
4036                            msg.append("nodeId=");
4037                            msg.append(nodeId);
4038    
4039                            msg.append(", status=");
4040                            msg.append(status);
4041    
4042                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4043    
4044                            throw new NoSuchPageException(msg.toString());
4045                    }
4046                    else {
4047                            return list.get(0);
4048                    }
4049            }
4050    
4051            /**
4052             * Finds the last wiki page in the ordered set where nodeId = &#63; and status = &#63;.
4053             *
4054             * <p>
4055             * 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.
4056             * </p>
4057             *
4058             * @param nodeId the node id to search with
4059             * @param status the status to search with
4060             * @param orderByComparator the comparator to order the set by
4061             * @return the last matching wiki page
4062             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4063             * @throws SystemException if a system exception occurred
4064             */
4065            public WikiPage findByN_S_Last(long nodeId, int status,
4066                    OrderByComparator orderByComparator)
4067                    throws NoSuchPageException, SystemException {
4068                    int count = countByN_S(nodeId, status);
4069    
4070                    List<WikiPage> list = findByN_S(nodeId, status, count - 1, count,
4071                                    orderByComparator);
4072    
4073                    if (list.isEmpty()) {
4074                            StringBundler msg = new StringBundler(6);
4075    
4076                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4077    
4078                            msg.append("nodeId=");
4079                            msg.append(nodeId);
4080    
4081                            msg.append(", status=");
4082                            msg.append(status);
4083    
4084                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4085    
4086                            throw new NoSuchPageException(msg.toString());
4087                    }
4088                    else {
4089                            return list.get(0);
4090                    }
4091            }
4092    
4093            /**
4094             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and status = &#63;.
4095             *
4096             * <p>
4097             * 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.
4098             * </p>
4099             *
4100             * @param pageId the primary key of the current wiki page
4101             * @param nodeId the node id to search with
4102             * @param status the status to search with
4103             * @param orderByComparator the comparator to order the set by
4104             * @return the previous, current, and next wiki page
4105             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
4106             * @throws SystemException if a system exception occurred
4107             */
4108            public WikiPage[] findByN_S_PrevAndNext(long pageId, long nodeId,
4109                    int status, OrderByComparator orderByComparator)
4110                    throws NoSuchPageException, SystemException {
4111                    WikiPage wikiPage = findByPrimaryKey(pageId);
4112    
4113                    Session session = null;
4114    
4115                    try {
4116                            session = openSession();
4117    
4118                            WikiPage[] array = new WikiPageImpl[3];
4119    
4120                            array[0] = getByN_S_PrevAndNext(session, wikiPage, nodeId, status,
4121                                            orderByComparator, true);
4122    
4123                            array[1] = wikiPage;
4124    
4125                            array[2] = getByN_S_PrevAndNext(session, wikiPage, nodeId, status,
4126                                            orderByComparator, false);
4127    
4128                            return array;
4129                    }
4130                    catch (Exception e) {
4131                            throw processException(e);
4132                    }
4133                    finally {
4134                            closeSession(session);
4135                    }
4136            }
4137    
4138            protected WikiPage getByN_S_PrevAndNext(Session session, WikiPage wikiPage,
4139                    long nodeId, int status, OrderByComparator orderByComparator,
4140                    boolean previous) {
4141                    StringBundler query = null;
4142    
4143                    if (orderByComparator != null) {
4144                            query = new StringBundler(6 +
4145                                            (orderByComparator.getOrderByFields().length * 6));
4146                    }
4147                    else {
4148                            query = new StringBundler(3);
4149                    }
4150    
4151                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4152    
4153                    query.append(_FINDER_COLUMN_N_S_NODEID_2);
4154    
4155                    query.append(_FINDER_COLUMN_N_S_STATUS_2);
4156    
4157                    if (orderByComparator != null) {
4158                            String[] orderByFields = orderByComparator.getOrderByFields();
4159    
4160                            if (orderByFields.length > 0) {
4161                                    query.append(WHERE_AND);
4162                            }
4163    
4164                            for (int i = 0; i < orderByFields.length; i++) {
4165                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4166                                    query.append(orderByFields[i]);
4167    
4168                                    if ((i + 1) < orderByFields.length) {
4169                                            if (orderByComparator.isAscending() ^ previous) {
4170                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4171                                            }
4172                                            else {
4173                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4174                                            }
4175                                    }
4176                                    else {
4177                                            if (orderByComparator.isAscending() ^ previous) {
4178                                                    query.append(WHERE_GREATER_THAN);
4179                                            }
4180                                            else {
4181                                                    query.append(WHERE_LESSER_THAN);
4182                                            }
4183                                    }
4184                            }
4185    
4186                            query.append(ORDER_BY_CLAUSE);
4187    
4188                            for (int i = 0; i < orderByFields.length; i++) {
4189                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4190                                    query.append(orderByFields[i]);
4191    
4192                                    if ((i + 1) < orderByFields.length) {
4193                                            if (orderByComparator.isAscending() ^ previous) {
4194                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4195                                            }
4196                                            else {
4197                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4198                                            }
4199                                    }
4200                                    else {
4201                                            if (orderByComparator.isAscending() ^ previous) {
4202                                                    query.append(ORDER_BY_ASC);
4203                                            }
4204                                            else {
4205                                                    query.append(ORDER_BY_DESC);
4206                                            }
4207                                    }
4208                            }
4209                    }
4210    
4211                    else {
4212                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4213                    }
4214    
4215                    String sql = query.toString();
4216    
4217                    Query q = session.createQuery(sql);
4218    
4219                    q.setFirstResult(0);
4220                    q.setMaxResults(2);
4221    
4222                    QueryPos qPos = QueryPos.getInstance(q);
4223    
4224                    qPos.add(nodeId);
4225    
4226                    qPos.add(status);
4227    
4228                    if (orderByComparator != null) {
4229                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
4230    
4231                            for (Object value : values) {
4232                                    qPos.add(value);
4233                            }
4234                    }
4235    
4236                    List<WikiPage> list = q.list();
4237    
4238                    if (list.size() == 2) {
4239                            return list.get(1);
4240                    }
4241                    else {
4242                            return null;
4243                    }
4244            }
4245    
4246            /**
4247             * Finds 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.
4248             *
4249             * @param resourcePrimKey the resource prim key to search with
4250             * @param nodeId the node id to search with
4251             * @param version the version to search with
4252             * @return the matching wiki page
4253             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4254             * @throws SystemException if a system exception occurred
4255             */
4256            public WikiPage findByR_N_V(long resourcePrimKey, long nodeId,
4257                    double version) throws NoSuchPageException, SystemException {
4258                    WikiPage wikiPage = fetchByR_N_V(resourcePrimKey, nodeId, version);
4259    
4260                    if (wikiPage == null) {
4261                            StringBundler msg = new StringBundler(8);
4262    
4263                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4264    
4265                            msg.append("resourcePrimKey=");
4266                            msg.append(resourcePrimKey);
4267    
4268                            msg.append(", nodeId=");
4269                            msg.append(nodeId);
4270    
4271                            msg.append(", version=");
4272                            msg.append(version);
4273    
4274                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4275    
4276                            if (_log.isWarnEnabled()) {
4277                                    _log.warn(msg.toString());
4278                            }
4279    
4280                            throw new NoSuchPageException(msg.toString());
4281                    }
4282    
4283                    return wikiPage;
4284            }
4285    
4286            /**
4287             * Finds 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.
4288             *
4289             * @param resourcePrimKey the resource prim key to search with
4290             * @param nodeId the node id to search with
4291             * @param version the version to search with
4292             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
4293             * @throws SystemException if a system exception occurred
4294             */
4295            public WikiPage fetchByR_N_V(long resourcePrimKey, long nodeId,
4296                    double version) throws SystemException {
4297                    return fetchByR_N_V(resourcePrimKey, nodeId, version, true);
4298            }
4299    
4300            /**
4301             * Finds 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.
4302             *
4303             * @param resourcePrimKey the resource prim key to search with
4304             * @param nodeId the node id to search with
4305             * @param version the version to search with
4306             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
4307             * @throws SystemException if a system exception occurred
4308             */
4309            public WikiPage fetchByR_N_V(long resourcePrimKey, long nodeId,
4310                    double version, boolean retrieveFromCache) throws SystemException {
4311                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, version };
4312    
4313                    Object result = null;
4314    
4315                    if (retrieveFromCache) {
4316                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_N_V,
4317                                            finderArgs, this);
4318                    }
4319    
4320                    if (result == null) {
4321                            Session session = null;
4322    
4323                            try {
4324                                    session = openSession();
4325    
4326                                    StringBundler query = new StringBundler(5);
4327    
4328                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4329    
4330                                    query.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
4331    
4332                                    query.append(_FINDER_COLUMN_R_N_V_NODEID_2);
4333    
4334                                    query.append(_FINDER_COLUMN_R_N_V_VERSION_2);
4335    
4336                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4337    
4338                                    String sql = query.toString();
4339    
4340                                    Query q = session.createQuery(sql);
4341    
4342                                    QueryPos qPos = QueryPos.getInstance(q);
4343    
4344                                    qPos.add(resourcePrimKey);
4345    
4346                                    qPos.add(nodeId);
4347    
4348                                    qPos.add(version);
4349    
4350                                    List<WikiPage> list = q.list();
4351    
4352                                    result = list;
4353    
4354                                    WikiPage wikiPage = null;
4355    
4356                                    if (list.isEmpty()) {
4357                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
4358                                                    finderArgs, list);
4359                                    }
4360                                    else {
4361                                            wikiPage = list.get(0);
4362    
4363                                            cacheResult(wikiPage);
4364    
4365                                            if ((wikiPage.getResourcePrimKey() != resourcePrimKey) ||
4366                                                            (wikiPage.getNodeId() != nodeId) ||
4367                                                            (wikiPage.getVersion() != version)) {
4368                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
4369                                                            finderArgs, wikiPage);
4370                                            }
4371                                    }
4372    
4373                                    return wikiPage;
4374                            }
4375                            catch (Exception e) {
4376                                    throw processException(e);
4377                            }
4378                            finally {
4379                                    if (result == null) {
4380                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
4381                                                    finderArgs, new ArrayList<WikiPage>());
4382                                    }
4383    
4384                                    closeSession(session);
4385                            }
4386                    }
4387                    else {
4388                            if (result instanceof List<?>) {
4389                                    return null;
4390                            }
4391                            else {
4392                                    return (WikiPage)result;
4393                            }
4394                    }
4395            }
4396    
4397            /**
4398             * Finds all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
4399             *
4400             * @param resourcePrimKey the resource prim key to search with
4401             * @param nodeId the node id to search with
4402             * @param status the status to search with
4403             * @return the matching wiki pages
4404             * @throws SystemException if a system exception occurred
4405             */
4406            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
4407                    int status) throws SystemException {
4408                    return findByR_N_S(resourcePrimKey, nodeId, status, QueryUtil.ALL_POS,
4409                            QueryUtil.ALL_POS, null);
4410            }
4411    
4412            /**
4413             * Finds a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
4414             *
4415             * <p>
4416             * 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.
4417             * </p>
4418             *
4419             * @param resourcePrimKey the resource prim key to search with
4420             * @param nodeId the node id to search with
4421             * @param status the status to search with
4422             * @param start the lower bound of the range of wiki pages to return
4423             * @param end the upper bound of the range of wiki pages to return (not inclusive)
4424             * @return the range of matching wiki pages
4425             * @throws SystemException if a system exception occurred
4426             */
4427            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
4428                    int status, int start, int end) throws SystemException {
4429                    return findByR_N_S(resourcePrimKey, nodeId, status, start, end, null);
4430            }
4431    
4432            /**
4433             * Finds an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
4434             *
4435             * <p>
4436             * 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.
4437             * </p>
4438             *
4439             * @param resourcePrimKey the resource prim key to search with
4440             * @param nodeId the node id to search with
4441             * @param status the status to search with
4442             * @param start the lower bound of the range of wiki pages to return
4443             * @param end the upper bound of the range of wiki pages to return (not inclusive)
4444             * @param orderByComparator the comparator to order the results by
4445             * @return the ordered range of matching wiki pages
4446             * @throws SystemException if a system exception occurred
4447             */
4448            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
4449                    int status, int start, int end, OrderByComparator orderByComparator)
4450                    throws SystemException {
4451                    Object[] finderArgs = new Object[] {
4452                                    resourcePrimKey, nodeId, status,
4453                                    
4454                                    String.valueOf(start), String.valueOf(end),
4455                                    String.valueOf(orderByComparator)
4456                            };
4457    
4458                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_R_N_S,
4459                                    finderArgs, this);
4460    
4461                    if (list == null) {
4462                            Session session = null;
4463    
4464                            try {
4465                                    session = openSession();
4466    
4467                                    StringBundler query = null;
4468    
4469                                    if (orderByComparator != null) {
4470                                            query = new StringBundler(5 +
4471                                                            (orderByComparator.getOrderByFields().length * 3));
4472                                    }
4473                                    else {
4474                                            query = new StringBundler(5);
4475                                    }
4476    
4477                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4478    
4479                                    query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
4480    
4481                                    query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
4482    
4483                                    query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
4484    
4485                                    if (orderByComparator != null) {
4486                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4487                                                    orderByComparator);
4488                                    }
4489    
4490                                    else {
4491                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4492                                    }
4493    
4494                                    String sql = query.toString();
4495    
4496                                    Query q = session.createQuery(sql);
4497    
4498                                    QueryPos qPos = QueryPos.getInstance(q);
4499    
4500                                    qPos.add(resourcePrimKey);
4501    
4502                                    qPos.add(nodeId);
4503    
4504                                    qPos.add(status);
4505    
4506                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
4507                                                    end);
4508                            }
4509                            catch (Exception e) {
4510                                    throw processException(e);
4511                            }
4512                            finally {
4513                                    if (list == null) {
4514                                            list = new ArrayList<WikiPage>();
4515                                    }
4516    
4517                                    cacheResult(list);
4518    
4519                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_R_N_S,
4520                                            finderArgs, list);
4521    
4522                                    closeSession(session);
4523                            }
4524                    }
4525    
4526                    return list;
4527            }
4528    
4529            /**
4530             * Finds the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
4531             *
4532             * <p>
4533             * 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.
4534             * </p>
4535             *
4536             * @param resourcePrimKey the resource prim key to search with
4537             * @param nodeId the node id to search with
4538             * @param status the status to search with
4539             * @param orderByComparator the comparator to order the set by
4540             * @return the first matching wiki page
4541             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4542             * @throws SystemException if a system exception occurred
4543             */
4544            public WikiPage findByR_N_S_First(long resourcePrimKey, long nodeId,
4545                    int status, OrderByComparator orderByComparator)
4546                    throws NoSuchPageException, SystemException {
4547                    List<WikiPage> list = findByR_N_S(resourcePrimKey, nodeId, status, 0,
4548                                    1, orderByComparator);
4549    
4550                    if (list.isEmpty()) {
4551                            StringBundler msg = new StringBundler(8);
4552    
4553                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4554    
4555                            msg.append("resourcePrimKey=");
4556                            msg.append(resourcePrimKey);
4557    
4558                            msg.append(", nodeId=");
4559                            msg.append(nodeId);
4560    
4561                            msg.append(", status=");
4562                            msg.append(status);
4563    
4564                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4565    
4566                            throw new NoSuchPageException(msg.toString());
4567                    }
4568                    else {
4569                            return list.get(0);
4570                    }
4571            }
4572    
4573            /**
4574             * Finds the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
4575             *
4576             * <p>
4577             * 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.
4578             * </p>
4579             *
4580             * @param resourcePrimKey the resource prim key to search with
4581             * @param nodeId the node id to search with
4582             * @param status the status to search with
4583             * @param orderByComparator the comparator to order the set by
4584             * @return the last matching wiki page
4585             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4586             * @throws SystemException if a system exception occurred
4587             */
4588            public WikiPage findByR_N_S_Last(long resourcePrimKey, long nodeId,
4589                    int status, OrderByComparator orderByComparator)
4590                    throws NoSuchPageException, SystemException {
4591                    int count = countByR_N_S(resourcePrimKey, nodeId, status);
4592    
4593                    List<WikiPage> list = findByR_N_S(resourcePrimKey, nodeId, status,
4594                                    count - 1, count, orderByComparator);
4595    
4596                    if (list.isEmpty()) {
4597                            StringBundler msg = new StringBundler(8);
4598    
4599                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4600    
4601                            msg.append("resourcePrimKey=");
4602                            msg.append(resourcePrimKey);
4603    
4604                            msg.append(", nodeId=");
4605                            msg.append(nodeId);
4606    
4607                            msg.append(", status=");
4608                            msg.append(status);
4609    
4610                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4611    
4612                            throw new NoSuchPageException(msg.toString());
4613                    }
4614                    else {
4615                            return list.get(0);
4616                    }
4617            }
4618    
4619            /**
4620             * Finds the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
4621             *
4622             * <p>
4623             * 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.
4624             * </p>
4625             *
4626             * @param pageId the primary key of the current wiki page
4627             * @param resourcePrimKey the resource prim key to search with
4628             * @param nodeId the node id to search with
4629             * @param status the status to search with
4630             * @param orderByComparator the comparator to order the set by
4631             * @return the previous, current, and next wiki page
4632             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
4633             * @throws SystemException if a system exception occurred
4634             */
4635            public WikiPage[] findByR_N_S_PrevAndNext(long pageId,
4636                    long resourcePrimKey, long nodeId, int status,
4637                    OrderByComparator orderByComparator)
4638                    throws NoSuchPageException, SystemException {
4639                    WikiPage wikiPage = findByPrimaryKey(pageId);
4640    
4641                    Session session = null;
4642    
4643                    try {
4644                            session = openSession();
4645    
4646                            WikiPage[] array = new WikiPageImpl[3];
4647    
4648                            array[0] = getByR_N_S_PrevAndNext(session, wikiPage,
4649                                            resourcePrimKey, nodeId, status, orderByComparator, true);
4650    
4651                            array[1] = wikiPage;
4652    
4653                            array[2] = getByR_N_S_PrevAndNext(session, wikiPage,
4654                                            resourcePrimKey, nodeId, status, orderByComparator, false);
4655    
4656                            return array;
4657                    }
4658                    catch (Exception e) {
4659                            throw processException(e);
4660                    }
4661                    finally {
4662                            closeSession(session);
4663                    }
4664            }
4665    
4666            protected WikiPage getByR_N_S_PrevAndNext(Session session,
4667                    WikiPage wikiPage, long resourcePrimKey, long nodeId, int status,
4668                    OrderByComparator orderByComparator, boolean previous) {
4669                    StringBundler query = null;
4670    
4671                    if (orderByComparator != null) {
4672                            query = new StringBundler(6 +
4673                                            (orderByComparator.getOrderByFields().length * 6));
4674                    }
4675                    else {
4676                            query = new StringBundler(3);
4677                    }
4678    
4679                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4680    
4681                    query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
4682    
4683                    query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
4684    
4685                    query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
4686    
4687                    if (orderByComparator != null) {
4688                            String[] orderByFields = orderByComparator.getOrderByFields();
4689    
4690                            if (orderByFields.length > 0) {
4691                                    query.append(WHERE_AND);
4692                            }
4693    
4694                            for (int i = 0; i < orderByFields.length; i++) {
4695                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4696                                    query.append(orderByFields[i]);
4697    
4698                                    if ((i + 1) < orderByFields.length) {
4699                                            if (orderByComparator.isAscending() ^ previous) {
4700                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4701                                            }
4702                                            else {
4703                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4704                                            }
4705                                    }
4706                                    else {
4707                                            if (orderByComparator.isAscending() ^ previous) {
4708                                                    query.append(WHERE_GREATER_THAN);
4709                                            }
4710                                            else {
4711                                                    query.append(WHERE_LESSER_THAN);
4712                                            }
4713                                    }
4714                            }
4715    
4716                            query.append(ORDER_BY_CLAUSE);
4717    
4718                            for (int i = 0; i < orderByFields.length; i++) {
4719                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4720                                    query.append(orderByFields[i]);
4721    
4722                                    if ((i + 1) < orderByFields.length) {
4723                                            if (orderByComparator.isAscending() ^ previous) {
4724                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4725                                            }
4726                                            else {
4727                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4728                                            }
4729                                    }
4730                                    else {
4731                                            if (orderByComparator.isAscending() ^ previous) {
4732                                                    query.append(ORDER_BY_ASC);
4733                                            }
4734                                            else {
4735                                                    query.append(ORDER_BY_DESC);
4736                                            }
4737                                    }
4738                            }
4739                    }
4740    
4741                    else {
4742                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4743                    }
4744    
4745                    String sql = query.toString();
4746    
4747                    Query q = session.createQuery(sql);
4748    
4749                    q.setFirstResult(0);
4750                    q.setMaxResults(2);
4751    
4752                    QueryPos qPos = QueryPos.getInstance(q);
4753    
4754                    qPos.add(resourcePrimKey);
4755    
4756                    qPos.add(nodeId);
4757    
4758                    qPos.add(status);
4759    
4760                    if (orderByComparator != null) {
4761                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
4762    
4763                            for (Object value : values) {
4764                                    qPos.add(value);
4765                            }
4766                    }
4767    
4768                    List<WikiPage> list = q.list();
4769    
4770                    if (list.size() == 2) {
4771                            return list.get(1);
4772                    }
4773                    else {
4774                            return null;
4775                    }
4776            }
4777    
4778            /**
4779             * Finds all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
4780             *
4781             * @param userId the user id to search with
4782             * @param nodeId the node id to search with
4783             * @param status the status to search with
4784             * @return the matching wiki pages
4785             * @throws SystemException if a system exception occurred
4786             */
4787            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status)
4788                    throws SystemException {
4789                    return findByU_N_S(userId, nodeId, status, QueryUtil.ALL_POS,
4790                            QueryUtil.ALL_POS, null);
4791            }
4792    
4793            /**
4794             * Finds a range of all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
4795             *
4796             * <p>
4797             * 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.
4798             * </p>
4799             *
4800             * @param userId the user id to search with
4801             * @param nodeId the node id to search with
4802             * @param status the status to search with
4803             * @param start the lower bound of the range of wiki pages to return
4804             * @param end the upper bound of the range of wiki pages to return (not inclusive)
4805             * @return the range of matching wiki pages
4806             * @throws SystemException if a system exception occurred
4807             */
4808            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status,
4809                    int start, int end) throws SystemException {
4810                    return findByU_N_S(userId, nodeId, status, start, end, null);
4811            }
4812    
4813            /**
4814             * Finds an ordered range of all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
4815             *
4816             * <p>
4817             * 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.
4818             * </p>
4819             *
4820             * @param userId the user id to search with
4821             * @param nodeId the node id to search with
4822             * @param status the status to search with
4823             * @param start the lower bound of the range of wiki pages to return
4824             * @param end the upper bound of the range of wiki pages to return (not inclusive)
4825             * @param orderByComparator the comparator to order the results by
4826             * @return the ordered range of matching wiki pages
4827             * @throws SystemException if a system exception occurred
4828             */
4829            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status,
4830                    int start, int end, OrderByComparator orderByComparator)
4831                    throws SystemException {
4832                    Object[] finderArgs = new Object[] {
4833                                    userId, nodeId, status,
4834                                    
4835                                    String.valueOf(start), String.valueOf(end),
4836                                    String.valueOf(orderByComparator)
4837                            };
4838    
4839                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_N_S,
4840                                    finderArgs, this);
4841    
4842                    if (list == null) {
4843                            Session session = null;
4844    
4845                            try {
4846                                    session = openSession();
4847    
4848                                    StringBundler query = null;
4849    
4850                                    if (orderByComparator != null) {
4851                                            query = new StringBundler(5 +
4852                                                            (orderByComparator.getOrderByFields().length * 3));
4853                                    }
4854                                    else {
4855                                            query = new StringBundler(5);
4856                                    }
4857    
4858                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4859    
4860                                    query.append(_FINDER_COLUMN_U_N_S_USERID_2);
4861    
4862                                    query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
4863    
4864                                    query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
4865    
4866                                    if (orderByComparator != null) {
4867                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4868                                                    orderByComparator);
4869                                    }
4870    
4871                                    else {
4872                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4873                                    }
4874    
4875                                    String sql = query.toString();
4876    
4877                                    Query q = session.createQuery(sql);
4878    
4879                                    QueryPos qPos = QueryPos.getInstance(q);
4880    
4881                                    qPos.add(userId);
4882    
4883                                    qPos.add(nodeId);
4884    
4885                                    qPos.add(status);
4886    
4887                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
4888                                                    end);
4889                            }
4890                            catch (Exception e) {
4891                                    throw processException(e);
4892                            }
4893                            finally {
4894                                    if (list == null) {
4895                                            list = new ArrayList<WikiPage>();
4896                                    }
4897    
4898                                    cacheResult(list);
4899    
4900                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_N_S,
4901                                            finderArgs, list);
4902    
4903                                    closeSession(session);
4904                            }
4905                    }
4906    
4907                    return list;
4908            }
4909    
4910            /**
4911             * Finds the first wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
4912             *
4913             * <p>
4914             * 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.
4915             * </p>
4916             *
4917             * @param userId the user id to search with
4918             * @param nodeId the node id to search with
4919             * @param status the status to search with
4920             * @param orderByComparator the comparator to order the set by
4921             * @return the first matching wiki page
4922             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4923             * @throws SystemException if a system exception occurred
4924             */
4925            public WikiPage findByU_N_S_First(long userId, long nodeId, int status,
4926                    OrderByComparator orderByComparator)
4927                    throws NoSuchPageException, SystemException {
4928                    List<WikiPage> list = findByU_N_S(userId, nodeId, status, 0, 1,
4929                                    orderByComparator);
4930    
4931                    if (list.isEmpty()) {
4932                            StringBundler msg = new StringBundler(8);
4933    
4934                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4935    
4936                            msg.append("userId=");
4937                            msg.append(userId);
4938    
4939                            msg.append(", nodeId=");
4940                            msg.append(nodeId);
4941    
4942                            msg.append(", status=");
4943                            msg.append(status);
4944    
4945                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4946    
4947                            throw new NoSuchPageException(msg.toString());
4948                    }
4949                    else {
4950                            return list.get(0);
4951                    }
4952            }
4953    
4954            /**
4955             * Finds the last wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
4956             *
4957             * <p>
4958             * 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.
4959             * </p>
4960             *
4961             * @param userId the user id to search with
4962             * @param nodeId the node id to search with
4963             * @param status the status to search with
4964             * @param orderByComparator the comparator to order the set by
4965             * @return the last matching wiki page
4966             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4967             * @throws SystemException if a system exception occurred
4968             */
4969            public WikiPage findByU_N_S_Last(long userId, long nodeId, int status,
4970                    OrderByComparator orderByComparator)
4971                    throws NoSuchPageException, SystemException {
4972                    int count = countByU_N_S(userId, nodeId, status);
4973    
4974                    List<WikiPage> list = findByU_N_S(userId, nodeId, status, count - 1,
4975                                    count, orderByComparator);
4976    
4977                    if (list.isEmpty()) {
4978                            StringBundler msg = new StringBundler(8);
4979    
4980                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4981    
4982                            msg.append("userId=");
4983                            msg.append(userId);
4984    
4985                            msg.append(", nodeId=");
4986                            msg.append(nodeId);
4987    
4988                            msg.append(", status=");
4989                            msg.append(status);
4990    
4991                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4992    
4993                            throw new NoSuchPageException(msg.toString());
4994                    }
4995                    else {
4996                            return list.get(0);
4997                    }
4998            }
4999    
5000            /**
5001             * Finds the wiki pages before and after the current wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
5002             *
5003             * <p>
5004             * 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.
5005             * </p>
5006             *
5007             * @param pageId the primary key of the current wiki page
5008             * @param userId the user id to search with
5009             * @param nodeId the node id to search with
5010             * @param status the status to search with
5011             * @param orderByComparator the comparator to order the set by
5012             * @return the previous, current, and next wiki page
5013             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
5014             * @throws SystemException if a system exception occurred
5015             */
5016            public WikiPage[] findByU_N_S_PrevAndNext(long pageId, long userId,
5017                    long nodeId, int status, OrderByComparator orderByComparator)
5018                    throws NoSuchPageException, SystemException {
5019                    WikiPage wikiPage = findByPrimaryKey(pageId);
5020    
5021                    Session session = null;
5022    
5023                    try {
5024                            session = openSession();
5025    
5026                            WikiPage[] array = new WikiPageImpl[3];
5027    
5028                            array[0] = getByU_N_S_PrevAndNext(session, wikiPage, userId,
5029                                            nodeId, status, orderByComparator, true);
5030    
5031                            array[1] = wikiPage;
5032    
5033                            array[2] = getByU_N_S_PrevAndNext(session, wikiPage, userId,
5034                                            nodeId, status, orderByComparator, false);
5035    
5036                            return array;
5037                    }
5038                    catch (Exception e) {
5039                            throw processException(e);
5040                    }
5041                    finally {
5042                            closeSession(session);
5043                    }
5044            }
5045    
5046            protected WikiPage getByU_N_S_PrevAndNext(Session session,
5047                    WikiPage wikiPage, long userId, long nodeId, int status,
5048                    OrderByComparator orderByComparator, boolean previous) {
5049                    StringBundler query = null;
5050    
5051                    if (orderByComparator != null) {
5052                            query = new StringBundler(6 +
5053                                            (orderByComparator.getOrderByFields().length * 6));
5054                    }
5055                    else {
5056                            query = new StringBundler(3);
5057                    }
5058    
5059                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5060    
5061                    query.append(_FINDER_COLUMN_U_N_S_USERID_2);
5062    
5063                    query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
5064    
5065                    query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
5066    
5067                    if (orderByComparator != null) {
5068                            String[] orderByFields = orderByComparator.getOrderByFields();
5069    
5070                            if (orderByFields.length > 0) {
5071                                    query.append(WHERE_AND);
5072                            }
5073    
5074                            for (int i = 0; i < orderByFields.length; i++) {
5075                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5076                                    query.append(orderByFields[i]);
5077    
5078                                    if ((i + 1) < orderByFields.length) {
5079                                            if (orderByComparator.isAscending() ^ previous) {
5080                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5081                                            }
5082                                            else {
5083                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5084                                            }
5085                                    }
5086                                    else {
5087                                            if (orderByComparator.isAscending() ^ previous) {
5088                                                    query.append(WHERE_GREATER_THAN);
5089                                            }
5090                                            else {
5091                                                    query.append(WHERE_LESSER_THAN);
5092                                            }
5093                                    }
5094                            }
5095    
5096                            query.append(ORDER_BY_CLAUSE);
5097    
5098                            for (int i = 0; i < orderByFields.length; i++) {
5099                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5100                                    query.append(orderByFields[i]);
5101    
5102                                    if ((i + 1) < orderByFields.length) {
5103                                            if (orderByComparator.isAscending() ^ previous) {
5104                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5105                                            }
5106                                            else {
5107                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5108                                            }
5109                                    }
5110                                    else {
5111                                            if (orderByComparator.isAscending() ^ previous) {
5112                                                    query.append(ORDER_BY_ASC);
5113                                            }
5114                                            else {
5115                                                    query.append(ORDER_BY_DESC);
5116                                            }
5117                                    }
5118                            }
5119                    }
5120    
5121                    else {
5122                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5123                    }
5124    
5125                    String sql = query.toString();
5126    
5127                    Query q = session.createQuery(sql);
5128    
5129                    q.setFirstResult(0);
5130                    q.setMaxResults(2);
5131    
5132                    QueryPos qPos = QueryPos.getInstance(q);
5133    
5134                    qPos.add(userId);
5135    
5136                    qPos.add(nodeId);
5137    
5138                    qPos.add(status);
5139    
5140                    if (orderByComparator != null) {
5141                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
5142    
5143                            for (Object value : values) {
5144                                    qPos.add(value);
5145                            }
5146                    }
5147    
5148                    List<WikiPage> list = q.list();
5149    
5150                    if (list.size() == 2) {
5151                            return list.get(1);
5152                    }
5153                    else {
5154                            return null;
5155                    }
5156            }
5157    
5158            /**
5159             * Finds 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.
5160             *
5161             * @param nodeId the node id to search with
5162             * @param title the title to search with
5163             * @param version the version to search with
5164             * @return the matching wiki page
5165             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5166             * @throws SystemException if a system exception occurred
5167             */
5168            public WikiPage findByN_T_V(long nodeId, String title, double version)
5169                    throws NoSuchPageException, SystemException {
5170                    WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
5171    
5172                    if (wikiPage == null) {
5173                            StringBundler msg = new StringBundler(8);
5174    
5175                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5176    
5177                            msg.append("nodeId=");
5178                            msg.append(nodeId);
5179    
5180                            msg.append(", title=");
5181                            msg.append(title);
5182    
5183                            msg.append(", version=");
5184                            msg.append(version);
5185    
5186                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5187    
5188                            if (_log.isWarnEnabled()) {
5189                                    _log.warn(msg.toString());
5190                            }
5191    
5192                            throw new NoSuchPageException(msg.toString());
5193                    }
5194    
5195                    return wikiPage;
5196            }
5197    
5198            /**
5199             * Finds 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.
5200             *
5201             * @param nodeId the node id to search with
5202             * @param title the title to search with
5203             * @param version the version to search with
5204             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
5205             * @throws SystemException if a system exception occurred
5206             */
5207            public WikiPage fetchByN_T_V(long nodeId, String title, double version)
5208                    throws SystemException {
5209                    return fetchByN_T_V(nodeId, title, version, true);
5210            }
5211    
5212            /**
5213             * Finds 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.
5214             *
5215             * @param nodeId the node id to search with
5216             * @param title the title to search with
5217             * @param version the version to search with
5218             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
5219             * @throws SystemException if a system exception occurred
5220             */
5221            public WikiPage fetchByN_T_V(long nodeId, String title, double version,
5222                    boolean retrieveFromCache) throws SystemException {
5223                    Object[] finderArgs = new Object[] { nodeId, title, version };
5224    
5225                    Object result = null;
5226    
5227                    if (retrieveFromCache) {
5228                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T_V,
5229                                            finderArgs, this);
5230                    }
5231    
5232                    if (result == null) {
5233                            Session session = null;
5234    
5235                            try {
5236                                    session = openSession();
5237    
5238                                    StringBundler query = new StringBundler(5);
5239    
5240                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5241    
5242                                    query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
5243    
5244                                    if (title == null) {
5245                                            query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
5246                                    }
5247                                    else {
5248                                            if (title.equals(StringPool.BLANK)) {
5249                                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
5250                                            }
5251                                            else {
5252                                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
5253                                            }
5254                                    }
5255    
5256                                    query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
5257    
5258                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5259    
5260                                    String sql = query.toString();
5261    
5262                                    Query q = session.createQuery(sql);
5263    
5264                                    QueryPos qPos = QueryPos.getInstance(q);
5265    
5266                                    qPos.add(nodeId);
5267    
5268                                    if (title != null) {
5269                                            qPos.add(title);
5270                                    }
5271    
5272                                    qPos.add(version);
5273    
5274                                    List<WikiPage> list = q.list();
5275    
5276                                    result = list;
5277    
5278                                    WikiPage wikiPage = null;
5279    
5280                                    if (list.isEmpty()) {
5281                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
5282                                                    finderArgs, list);
5283                                    }
5284                                    else {
5285                                            wikiPage = list.get(0);
5286    
5287                                            cacheResult(wikiPage);
5288    
5289                                            if ((wikiPage.getNodeId() != nodeId) ||
5290                                                            (wikiPage.getTitle() == null) ||
5291                                                            !wikiPage.getTitle().equals(title) ||
5292                                                            (wikiPage.getVersion() != version)) {
5293                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
5294                                                            finderArgs, wikiPage);
5295                                            }
5296                                    }
5297    
5298                                    return wikiPage;
5299                            }
5300                            catch (Exception e) {
5301                                    throw processException(e);
5302                            }
5303                            finally {
5304                                    if (result == null) {
5305                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
5306                                                    finderArgs, new ArrayList<WikiPage>());
5307                                    }
5308    
5309                                    closeSession(session);
5310                            }
5311                    }
5312                    else {
5313                            if (result instanceof List<?>) {
5314                                    return null;
5315                            }
5316                            else {
5317                                    return (WikiPage)result;
5318                            }
5319                    }
5320            }
5321    
5322            /**
5323             * Finds all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
5324             *
5325             * @param nodeId the node id to search with
5326             * @param title the title to search with
5327             * @param head the head to search with
5328             * @return the matching wiki pages
5329             * @throws SystemException if a system exception occurred
5330             */
5331            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head)
5332                    throws SystemException {
5333                    return findByN_T_H(nodeId, title, head, QueryUtil.ALL_POS,
5334                            QueryUtil.ALL_POS, null);
5335            }
5336    
5337            /**
5338             * Finds a range of all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
5339             *
5340             * <p>
5341             * 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.
5342             * </p>
5343             *
5344             * @param nodeId the node id to search with
5345             * @param title the title to search with
5346             * @param head the head to search with
5347             * @param start the lower bound of the range of wiki pages to return
5348             * @param end the upper bound of the range of wiki pages to return (not inclusive)
5349             * @return the range of matching wiki pages
5350             * @throws SystemException if a system exception occurred
5351             */
5352            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
5353                    int start, int end) throws SystemException {
5354                    return findByN_T_H(nodeId, title, head, start, end, null);
5355            }
5356    
5357            /**
5358             * Finds an ordered range of all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
5359             *
5360             * <p>
5361             * 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.
5362             * </p>
5363             *
5364             * @param nodeId the node id to search with
5365             * @param title the title to search with
5366             * @param head the head to search with
5367             * @param start the lower bound of the range of wiki pages to return
5368             * @param end the upper bound of the range of wiki pages to return (not inclusive)
5369             * @param orderByComparator the comparator to order the results by
5370             * @return the ordered range of matching wiki pages
5371             * @throws SystemException if a system exception occurred
5372             */
5373            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
5374                    int start, int end, OrderByComparator orderByComparator)
5375                    throws SystemException {
5376                    Object[] finderArgs = new Object[] {
5377                                    nodeId, title, head,
5378                                    
5379                                    String.valueOf(start), String.valueOf(end),
5380                                    String.valueOf(orderByComparator)
5381                            };
5382    
5383                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_T_H,
5384                                    finderArgs, this);
5385    
5386                    if (list == null) {
5387                            Session session = null;
5388    
5389                            try {
5390                                    session = openSession();
5391    
5392                                    StringBundler query = null;
5393    
5394                                    if (orderByComparator != null) {
5395                                            query = new StringBundler(5 +
5396                                                            (orderByComparator.getOrderByFields().length * 3));
5397                                    }
5398                                    else {
5399                                            query = new StringBundler(5);
5400                                    }
5401    
5402                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5403    
5404                                    query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
5405    
5406                                    if (title == null) {
5407                                            query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
5408                                    }
5409                                    else {
5410                                            if (title.equals(StringPool.BLANK)) {
5411                                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
5412                                            }
5413                                            else {
5414                                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
5415                                            }
5416                                    }
5417    
5418                                    query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
5419    
5420                                    if (orderByComparator != null) {
5421                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5422                                                    orderByComparator);
5423                                    }
5424    
5425                                    else {
5426                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5427                                    }
5428    
5429                                    String sql = query.toString();
5430    
5431                                    Query q = session.createQuery(sql);
5432    
5433                                    QueryPos qPos = QueryPos.getInstance(q);
5434    
5435                                    qPos.add(nodeId);
5436    
5437                                    if (title != null) {
5438                                            qPos.add(title);
5439                                    }
5440    
5441                                    qPos.add(head);
5442    
5443                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
5444                                                    end);
5445                            }
5446                            catch (Exception e) {
5447                                    throw processException(e);
5448                            }
5449                            finally {
5450                                    if (list == null) {
5451                                            list = new ArrayList<WikiPage>();
5452                                    }
5453    
5454                                    cacheResult(list);
5455    
5456                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_T_H,
5457                                            finderArgs, list);
5458    
5459                                    closeSession(session);
5460                            }
5461                    }
5462    
5463                    return list;
5464            }
5465    
5466            /**
5467             * Finds the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
5468             *
5469             * <p>
5470             * 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.
5471             * </p>
5472             *
5473             * @param nodeId the node id to search with
5474             * @param title the title to search with
5475             * @param head the head to search with
5476             * @param orderByComparator the comparator to order the set by
5477             * @return the first matching wiki page
5478             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5479             * @throws SystemException if a system exception occurred
5480             */
5481            public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
5482                    OrderByComparator orderByComparator)
5483                    throws NoSuchPageException, SystemException {
5484                    List<WikiPage> list = findByN_T_H(nodeId, title, head, 0, 1,
5485                                    orderByComparator);
5486    
5487                    if (list.isEmpty()) {
5488                            StringBundler msg = new StringBundler(8);
5489    
5490                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5491    
5492                            msg.append("nodeId=");
5493                            msg.append(nodeId);
5494    
5495                            msg.append(", title=");
5496                            msg.append(title);
5497    
5498                            msg.append(", head=");
5499                            msg.append(head);
5500    
5501                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5502    
5503                            throw new NoSuchPageException(msg.toString());
5504                    }
5505                    else {
5506                            return list.get(0);
5507                    }
5508            }
5509    
5510            /**
5511             * Finds the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
5512             *
5513             * <p>
5514             * 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.
5515             * </p>
5516             *
5517             * @param nodeId the node id to search with
5518             * @param title the title to search with
5519             * @param head the head to search with
5520             * @param orderByComparator the comparator to order the set by
5521             * @return the last matching wiki page
5522             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5523             * @throws SystemException if a system exception occurred
5524             */
5525            public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
5526                    OrderByComparator orderByComparator)
5527                    throws NoSuchPageException, SystemException {
5528                    int count = countByN_T_H(nodeId, title, head);
5529    
5530                    List<WikiPage> list = findByN_T_H(nodeId, title, head, count - 1,
5531                                    count, orderByComparator);
5532    
5533                    if (list.isEmpty()) {
5534                            StringBundler msg = new StringBundler(8);
5535    
5536                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5537    
5538                            msg.append("nodeId=");
5539                            msg.append(nodeId);
5540    
5541                            msg.append(", title=");
5542                            msg.append(title);
5543    
5544                            msg.append(", head=");
5545                            msg.append(head);
5546    
5547                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5548    
5549                            throw new NoSuchPageException(msg.toString());
5550                    }
5551                    else {
5552                            return list.get(0);
5553                    }
5554            }
5555    
5556            /**
5557             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
5558             *
5559             * <p>
5560             * 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.
5561             * </p>
5562             *
5563             * @param pageId the primary key of the current wiki page
5564             * @param nodeId the node id to search with
5565             * @param title the title to search with
5566             * @param head the head to search with
5567             * @param orderByComparator the comparator to order the set by
5568             * @return the previous, current, and next wiki page
5569             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
5570             * @throws SystemException if a system exception occurred
5571             */
5572            public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
5573                    String title, boolean head, OrderByComparator orderByComparator)
5574                    throws NoSuchPageException, SystemException {
5575                    WikiPage wikiPage = findByPrimaryKey(pageId);
5576    
5577                    Session session = null;
5578    
5579                    try {
5580                            session = openSession();
5581    
5582                            WikiPage[] array = new WikiPageImpl[3];
5583    
5584                            array[0] = getByN_T_H_PrevAndNext(session, wikiPage, nodeId, title,
5585                                            head, orderByComparator, true);
5586    
5587                            array[1] = wikiPage;
5588    
5589                            array[2] = getByN_T_H_PrevAndNext(session, wikiPage, nodeId, title,
5590                                            head, orderByComparator, false);
5591    
5592                            return array;
5593                    }
5594                    catch (Exception e) {
5595                            throw processException(e);
5596                    }
5597                    finally {
5598                            closeSession(session);
5599                    }
5600            }
5601    
5602            protected WikiPage getByN_T_H_PrevAndNext(Session session,
5603                    WikiPage wikiPage, long nodeId, String title, boolean head,
5604                    OrderByComparator orderByComparator, boolean previous) {
5605                    StringBundler query = null;
5606    
5607                    if (orderByComparator != null) {
5608                            query = new StringBundler(6 +
5609                                            (orderByComparator.getOrderByFields().length * 6));
5610                    }
5611                    else {
5612                            query = new StringBundler(3);
5613                    }
5614    
5615                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5616    
5617                    query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
5618    
5619                    if (title == null) {
5620                            query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
5621                    }
5622                    else {
5623                            if (title.equals(StringPool.BLANK)) {
5624                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
5625                            }
5626                            else {
5627                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
5628                            }
5629                    }
5630    
5631                    query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
5632    
5633                    if (orderByComparator != null) {
5634                            String[] orderByFields = orderByComparator.getOrderByFields();
5635    
5636                            if (orderByFields.length > 0) {
5637                                    query.append(WHERE_AND);
5638                            }
5639    
5640                            for (int i = 0; i < orderByFields.length; i++) {
5641                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5642                                    query.append(orderByFields[i]);
5643    
5644                                    if ((i + 1) < orderByFields.length) {
5645                                            if (orderByComparator.isAscending() ^ previous) {
5646                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5647                                            }
5648                                            else {
5649                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5650                                            }
5651                                    }
5652                                    else {
5653                                            if (orderByComparator.isAscending() ^ previous) {
5654                                                    query.append(WHERE_GREATER_THAN);
5655                                            }
5656                                            else {
5657                                                    query.append(WHERE_LESSER_THAN);
5658                                            }
5659                                    }
5660                            }
5661    
5662                            query.append(ORDER_BY_CLAUSE);
5663    
5664                            for (int i = 0; i < orderByFields.length; i++) {
5665                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5666                                    query.append(orderByFields[i]);
5667    
5668                                    if ((i + 1) < orderByFields.length) {
5669                                            if (orderByComparator.isAscending() ^ previous) {
5670                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5671                                            }
5672                                            else {
5673                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5674                                            }
5675                                    }
5676                                    else {
5677                                            if (orderByComparator.isAscending() ^ previous) {
5678                                                    query.append(ORDER_BY_ASC);
5679                                            }
5680                                            else {
5681                                                    query.append(ORDER_BY_DESC);
5682                                            }
5683                                    }
5684                            }
5685                    }
5686    
5687                    else {
5688                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5689                    }
5690    
5691                    String sql = query.toString();
5692    
5693                    Query q = session.createQuery(sql);
5694    
5695                    q.setFirstResult(0);
5696                    q.setMaxResults(2);
5697    
5698                    QueryPos qPos = QueryPos.getInstance(q);
5699    
5700                    qPos.add(nodeId);
5701    
5702                    if (title != null) {
5703                            qPos.add(title);
5704                    }
5705    
5706                    qPos.add(head);
5707    
5708                    if (orderByComparator != null) {
5709                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
5710    
5711                            for (Object value : values) {
5712                                    qPos.add(value);
5713                            }
5714                    }
5715    
5716                    List<WikiPage> list = q.list();
5717    
5718                    if (list.size() == 2) {
5719                            return list.get(1);
5720                    }
5721                    else {
5722                            return null;
5723                    }
5724            }
5725    
5726            /**
5727             * Finds all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
5728             *
5729             * @param nodeId the node id to search with
5730             * @param title the title to search with
5731             * @param status the status to search with
5732             * @return the matching wiki pages
5733             * @throws SystemException if a system exception occurred
5734             */
5735            public List<WikiPage> findByN_T_S(long nodeId, String title, int status)
5736                    throws SystemException {
5737                    return findByN_T_S(nodeId, title, status, QueryUtil.ALL_POS,
5738                            QueryUtil.ALL_POS, null);
5739            }
5740    
5741            /**
5742             * Finds a range of all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
5743             *
5744             * <p>
5745             * 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.
5746             * </p>
5747             *
5748             * @param nodeId the node id to search with
5749             * @param title the title to search with
5750             * @param status the status to search with
5751             * @param start the lower bound of the range of wiki pages to return
5752             * @param end the upper bound of the range of wiki pages to return (not inclusive)
5753             * @return the range of matching wiki pages
5754             * @throws SystemException if a system exception occurred
5755             */
5756            public List<WikiPage> findByN_T_S(long nodeId, String title, int status,
5757                    int start, int end) throws SystemException {
5758                    return findByN_T_S(nodeId, title, status, start, end, null);
5759            }
5760    
5761            /**
5762             * Finds an ordered range of all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
5763             *
5764             * <p>
5765             * 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.
5766             * </p>
5767             *
5768             * @param nodeId the node id to search with
5769             * @param title the title to search with
5770             * @param status the status to search with
5771             * @param start the lower bound of the range of wiki pages to return
5772             * @param end the upper bound of the range of wiki pages to return (not inclusive)
5773             * @param orderByComparator the comparator to order the results by
5774             * @return the ordered range of matching wiki pages
5775             * @throws SystemException if a system exception occurred
5776             */
5777            public List<WikiPage> findByN_T_S(long nodeId, String title, int status,
5778                    int start, int end, OrderByComparator orderByComparator)
5779                    throws SystemException {
5780                    Object[] finderArgs = new Object[] {
5781                                    nodeId, title, status,
5782                                    
5783                                    String.valueOf(start), String.valueOf(end),
5784                                    String.valueOf(orderByComparator)
5785                            };
5786    
5787                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_T_S,
5788                                    finderArgs, this);
5789    
5790                    if (list == null) {
5791                            Session session = null;
5792    
5793                            try {
5794                                    session = openSession();
5795    
5796                                    StringBundler query = null;
5797    
5798                                    if (orderByComparator != null) {
5799                                            query = new StringBundler(5 +
5800                                                            (orderByComparator.getOrderByFields().length * 3));
5801                                    }
5802                                    else {
5803                                            query = new StringBundler(5);
5804                                    }
5805    
5806                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5807    
5808                                    query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
5809    
5810                                    if (title == null) {
5811                                            query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
5812                                    }
5813                                    else {
5814                                            if (title.equals(StringPool.BLANK)) {
5815                                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
5816                                            }
5817                                            else {
5818                                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
5819                                            }
5820                                    }
5821    
5822                                    query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
5823    
5824                                    if (orderByComparator != null) {
5825                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5826                                                    orderByComparator);
5827                                    }
5828    
5829                                    else {
5830                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5831                                    }
5832    
5833                                    String sql = query.toString();
5834    
5835                                    Query q = session.createQuery(sql);
5836    
5837                                    QueryPos qPos = QueryPos.getInstance(q);
5838    
5839                                    qPos.add(nodeId);
5840    
5841                                    if (title != null) {
5842                                            qPos.add(title);
5843                                    }
5844    
5845                                    qPos.add(status);
5846    
5847                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
5848                                                    end);
5849                            }
5850                            catch (Exception e) {
5851                                    throw processException(e);
5852                            }
5853                            finally {
5854                                    if (list == null) {
5855                                            list = new ArrayList<WikiPage>();
5856                                    }
5857    
5858                                    cacheResult(list);
5859    
5860                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_T_S,
5861                                            finderArgs, list);
5862    
5863                                    closeSession(session);
5864                            }
5865                    }
5866    
5867                    return list;
5868            }
5869    
5870            /**
5871             * Finds the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
5872             *
5873             * <p>
5874             * 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.
5875             * </p>
5876             *
5877             * @param nodeId the node id to search with
5878             * @param title the title to search with
5879             * @param status the status to search with
5880             * @param orderByComparator the comparator to order the set by
5881             * @return the first matching wiki page
5882             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5883             * @throws SystemException if a system exception occurred
5884             */
5885            public WikiPage findByN_T_S_First(long nodeId, String title, int status,
5886                    OrderByComparator orderByComparator)
5887                    throws NoSuchPageException, SystemException {
5888                    List<WikiPage> list = findByN_T_S(nodeId, title, status, 0, 1,
5889                                    orderByComparator);
5890    
5891                    if (list.isEmpty()) {
5892                            StringBundler msg = new StringBundler(8);
5893    
5894                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5895    
5896                            msg.append("nodeId=");
5897                            msg.append(nodeId);
5898    
5899                            msg.append(", title=");
5900                            msg.append(title);
5901    
5902                            msg.append(", status=");
5903                            msg.append(status);
5904    
5905                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5906    
5907                            throw new NoSuchPageException(msg.toString());
5908                    }
5909                    else {
5910                            return list.get(0);
5911                    }
5912            }
5913    
5914            /**
5915             * Finds the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
5916             *
5917             * <p>
5918             * 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.
5919             * </p>
5920             *
5921             * @param nodeId the node id to search with
5922             * @param title the title to search with
5923             * @param status the status to search with
5924             * @param orderByComparator the comparator to order the set by
5925             * @return the last matching wiki page
5926             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5927             * @throws SystemException if a system exception occurred
5928             */
5929            public WikiPage findByN_T_S_Last(long nodeId, String title, int status,
5930                    OrderByComparator orderByComparator)
5931                    throws NoSuchPageException, SystemException {
5932                    int count = countByN_T_S(nodeId, title, status);
5933    
5934                    List<WikiPage> list = findByN_T_S(nodeId, title, status, count - 1,
5935                                    count, orderByComparator);
5936    
5937                    if (list.isEmpty()) {
5938                            StringBundler msg = new StringBundler(8);
5939    
5940                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5941    
5942                            msg.append("nodeId=");
5943                            msg.append(nodeId);
5944    
5945                            msg.append(", title=");
5946                            msg.append(title);
5947    
5948                            msg.append(", status=");
5949                            msg.append(status);
5950    
5951                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5952    
5953                            throw new NoSuchPageException(msg.toString());
5954                    }
5955                    else {
5956                            return list.get(0);
5957                    }
5958            }
5959    
5960            /**
5961             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
5962             *
5963             * <p>
5964             * 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.
5965             * </p>
5966             *
5967             * @param pageId the primary key of the current wiki page
5968             * @param nodeId the node id to search with
5969             * @param title the title to search with
5970             * @param status the status to search with
5971             * @param orderByComparator the comparator to order the set by
5972             * @return the previous, current, and next wiki page
5973             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
5974             * @throws SystemException if a system exception occurred
5975             */
5976            public WikiPage[] findByN_T_S_PrevAndNext(long pageId, long nodeId,
5977                    String title, int status, OrderByComparator orderByComparator)
5978                    throws NoSuchPageException, SystemException {
5979                    WikiPage wikiPage = findByPrimaryKey(pageId);
5980    
5981                    Session session = null;
5982    
5983                    try {
5984                            session = openSession();
5985    
5986                            WikiPage[] array = new WikiPageImpl[3];
5987    
5988                            array[0] = getByN_T_S_PrevAndNext(session, wikiPage, nodeId, title,
5989                                            status, orderByComparator, true);
5990    
5991                            array[1] = wikiPage;
5992    
5993                            array[2] = getByN_T_S_PrevAndNext(session, wikiPage, nodeId, title,
5994                                            status, orderByComparator, false);
5995    
5996                            return array;
5997                    }
5998                    catch (Exception e) {
5999                            throw processException(e);
6000                    }
6001                    finally {
6002                            closeSession(session);
6003                    }
6004            }
6005    
6006            protected WikiPage getByN_T_S_PrevAndNext(Session session,
6007                    WikiPage wikiPage, long nodeId, String title, int status,
6008                    OrderByComparator orderByComparator, boolean previous) {
6009                    StringBundler query = null;
6010    
6011                    if (orderByComparator != null) {
6012                            query = new StringBundler(6 +
6013                                            (orderByComparator.getOrderByFields().length * 6));
6014                    }
6015                    else {
6016                            query = new StringBundler(3);
6017                    }
6018    
6019                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6020    
6021                    query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
6022    
6023                    if (title == null) {
6024                            query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
6025                    }
6026                    else {
6027                            if (title.equals(StringPool.BLANK)) {
6028                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
6029                            }
6030                            else {
6031                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
6032                            }
6033                    }
6034    
6035                    query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
6036    
6037                    if (orderByComparator != null) {
6038                            String[] orderByFields = orderByComparator.getOrderByFields();
6039    
6040                            if (orderByFields.length > 0) {
6041                                    query.append(WHERE_AND);
6042                            }
6043    
6044                            for (int i = 0; i < orderByFields.length; i++) {
6045                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6046                                    query.append(orderByFields[i]);
6047    
6048                                    if ((i + 1) < orderByFields.length) {
6049                                            if (orderByComparator.isAscending() ^ previous) {
6050                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6051                                            }
6052                                            else {
6053                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6054                                            }
6055                                    }
6056                                    else {
6057                                            if (orderByComparator.isAscending() ^ previous) {
6058                                                    query.append(WHERE_GREATER_THAN);
6059                                            }
6060                                            else {
6061                                                    query.append(WHERE_LESSER_THAN);
6062                                            }
6063                                    }
6064                            }
6065    
6066                            query.append(ORDER_BY_CLAUSE);
6067    
6068                            for (int i = 0; i < orderByFields.length; i++) {
6069                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6070                                    query.append(orderByFields[i]);
6071    
6072                                    if ((i + 1) < orderByFields.length) {
6073                                            if (orderByComparator.isAscending() ^ previous) {
6074                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6075                                            }
6076                                            else {
6077                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6078                                            }
6079                                    }
6080                                    else {
6081                                            if (orderByComparator.isAscending() ^ previous) {
6082                                                    query.append(ORDER_BY_ASC);
6083                                            }
6084                                            else {
6085                                                    query.append(ORDER_BY_DESC);
6086                                            }
6087                                    }
6088                            }
6089                    }
6090    
6091                    else {
6092                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6093                    }
6094    
6095                    String sql = query.toString();
6096    
6097                    Query q = session.createQuery(sql);
6098    
6099                    q.setFirstResult(0);
6100                    q.setMaxResults(2);
6101    
6102                    QueryPos qPos = QueryPos.getInstance(q);
6103    
6104                    qPos.add(nodeId);
6105    
6106                    if (title != null) {
6107                            qPos.add(title);
6108                    }
6109    
6110                    qPos.add(status);
6111    
6112                    if (orderByComparator != null) {
6113                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
6114    
6115                            for (Object value : values) {
6116                                    qPos.add(value);
6117                            }
6118                    }
6119    
6120                    List<WikiPage> list = q.list();
6121    
6122                    if (list.size() == 2) {
6123                            return list.get(1);
6124                    }
6125                    else {
6126                            return null;
6127                    }
6128            }
6129    
6130            /**
6131             * Finds all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
6132             *
6133             * @param nodeId the node id to search with
6134             * @param head the head to search with
6135             * @param parentTitle the parent title to search with
6136             * @return the matching wiki pages
6137             * @throws SystemException if a system exception occurred
6138             */
6139            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
6140                    String parentTitle) throws SystemException {
6141                    return findByN_H_P(nodeId, head, parentTitle, QueryUtil.ALL_POS,
6142                            QueryUtil.ALL_POS, null);
6143            }
6144    
6145            /**
6146             * Finds a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
6147             *
6148             * <p>
6149             * 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.
6150             * </p>
6151             *
6152             * @param nodeId the node id to search with
6153             * @param head the head to search with
6154             * @param parentTitle the parent title to search with
6155             * @param start the lower bound of the range of wiki pages to return
6156             * @param end the upper bound of the range of wiki pages to return (not inclusive)
6157             * @return the range of matching wiki pages
6158             * @throws SystemException if a system exception occurred
6159             */
6160            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
6161                    String parentTitle, int start, int end) throws SystemException {
6162                    return findByN_H_P(nodeId, head, parentTitle, start, end, null);
6163            }
6164    
6165            /**
6166             * Finds an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
6167             *
6168             * <p>
6169             * 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.
6170             * </p>
6171             *
6172             * @param nodeId the node id to search with
6173             * @param head the head to search with
6174             * @param parentTitle the parent title to search with
6175             * @param start the lower bound of the range of wiki pages to return
6176             * @param end the upper bound of the range of wiki pages to return (not inclusive)
6177             * @param orderByComparator the comparator to order the results by
6178             * @return the ordered range of matching wiki pages
6179             * @throws SystemException if a system exception occurred
6180             */
6181            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
6182                    String parentTitle, int start, int end,
6183                    OrderByComparator orderByComparator) throws SystemException {
6184                    Object[] finderArgs = new Object[] {
6185                                    nodeId, head, parentTitle,
6186                                    
6187                                    String.valueOf(start), String.valueOf(end),
6188                                    String.valueOf(orderByComparator)
6189                            };
6190    
6191                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_H_P,
6192                                    finderArgs, this);
6193    
6194                    if (list == null) {
6195                            Session session = null;
6196    
6197                            try {
6198                                    session = openSession();
6199    
6200                                    StringBundler query = null;
6201    
6202                                    if (orderByComparator != null) {
6203                                            query = new StringBundler(5 +
6204                                                            (orderByComparator.getOrderByFields().length * 3));
6205                                    }
6206                                    else {
6207                                            query = new StringBundler(5);
6208                                    }
6209    
6210                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6211    
6212                                    query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
6213    
6214                                    query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
6215    
6216                                    if (parentTitle == null) {
6217                                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
6218                                    }
6219                                    else {
6220                                            if (parentTitle.equals(StringPool.BLANK)) {
6221                                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
6222                                            }
6223                                            else {
6224                                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
6225                                            }
6226                                    }
6227    
6228                                    if (orderByComparator != null) {
6229                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6230                                                    orderByComparator);
6231                                    }
6232    
6233                                    else {
6234                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6235                                    }
6236    
6237                                    String sql = query.toString();
6238    
6239                                    Query q = session.createQuery(sql);
6240    
6241                                    QueryPos qPos = QueryPos.getInstance(q);
6242    
6243                                    qPos.add(nodeId);
6244    
6245                                    qPos.add(head);
6246    
6247                                    if (parentTitle != null) {
6248                                            qPos.add(parentTitle);
6249                                    }
6250    
6251                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
6252                                                    end);
6253                            }
6254                            catch (Exception e) {
6255                                    throw processException(e);
6256                            }
6257                            finally {
6258                                    if (list == null) {
6259                                            list = new ArrayList<WikiPage>();
6260                                    }
6261    
6262                                    cacheResult(list);
6263    
6264                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_H_P,
6265                                            finderArgs, list);
6266    
6267                                    closeSession(session);
6268                            }
6269                    }
6270    
6271                    return list;
6272            }
6273    
6274            /**
6275             * Finds the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
6276             *
6277             * <p>
6278             * 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.
6279             * </p>
6280             *
6281             * @param nodeId the node id to search with
6282             * @param head the head to search with
6283             * @param parentTitle the parent title to search with
6284             * @param orderByComparator the comparator to order the set by
6285             * @return the first matching wiki page
6286             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6287             * @throws SystemException if a system exception occurred
6288             */
6289            public WikiPage findByN_H_P_First(long nodeId, boolean head,
6290                    String parentTitle, OrderByComparator orderByComparator)
6291                    throws NoSuchPageException, SystemException {
6292                    List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, 0, 1,
6293                                    orderByComparator);
6294    
6295                    if (list.isEmpty()) {
6296                            StringBundler msg = new StringBundler(8);
6297    
6298                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6299    
6300                            msg.append("nodeId=");
6301                            msg.append(nodeId);
6302    
6303                            msg.append(", head=");
6304                            msg.append(head);
6305    
6306                            msg.append(", parentTitle=");
6307                            msg.append(parentTitle);
6308    
6309                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6310    
6311                            throw new NoSuchPageException(msg.toString());
6312                    }
6313                    else {
6314                            return list.get(0);
6315                    }
6316            }
6317    
6318            /**
6319             * Finds the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
6320             *
6321             * <p>
6322             * 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.
6323             * </p>
6324             *
6325             * @param nodeId the node id to search with
6326             * @param head the head to search with
6327             * @param parentTitle the parent title to search with
6328             * @param orderByComparator the comparator to order the set by
6329             * @return the last matching wiki page
6330             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6331             * @throws SystemException if a system exception occurred
6332             */
6333            public WikiPage findByN_H_P_Last(long nodeId, boolean head,
6334                    String parentTitle, OrderByComparator orderByComparator)
6335                    throws NoSuchPageException, SystemException {
6336                    int count = countByN_H_P(nodeId, head, parentTitle);
6337    
6338                    List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, count - 1,
6339                                    count, orderByComparator);
6340    
6341                    if (list.isEmpty()) {
6342                            StringBundler msg = new StringBundler(8);
6343    
6344                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6345    
6346                            msg.append("nodeId=");
6347                            msg.append(nodeId);
6348    
6349                            msg.append(", head=");
6350                            msg.append(head);
6351    
6352                            msg.append(", parentTitle=");
6353                            msg.append(parentTitle);
6354    
6355                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6356    
6357                            throw new NoSuchPageException(msg.toString());
6358                    }
6359                    else {
6360                            return list.get(0);
6361                    }
6362            }
6363    
6364            /**
6365             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
6366             *
6367             * <p>
6368             * 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.
6369             * </p>
6370             *
6371             * @param pageId the primary key of the current wiki page
6372             * @param nodeId the node id to search with
6373             * @param head the head to search with
6374             * @param parentTitle the parent title to search with
6375             * @param orderByComparator the comparator to order the set by
6376             * @return the previous, current, and next wiki page
6377             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
6378             * @throws SystemException if a system exception occurred
6379             */
6380            public WikiPage[] findByN_H_P_PrevAndNext(long pageId, long nodeId,
6381                    boolean head, String parentTitle, OrderByComparator orderByComparator)
6382                    throws NoSuchPageException, SystemException {
6383                    WikiPage wikiPage = findByPrimaryKey(pageId);
6384    
6385                    Session session = null;
6386    
6387                    try {
6388                            session = openSession();
6389    
6390                            WikiPage[] array = new WikiPageImpl[3];
6391    
6392                            array[0] = getByN_H_P_PrevAndNext(session, wikiPage, nodeId, head,
6393                                            parentTitle, orderByComparator, true);
6394    
6395                            array[1] = wikiPage;
6396    
6397                            array[2] = getByN_H_P_PrevAndNext(session, wikiPage, nodeId, head,
6398                                            parentTitle, orderByComparator, false);
6399    
6400                            return array;
6401                    }
6402                    catch (Exception e) {
6403                            throw processException(e);
6404                    }
6405                    finally {
6406                            closeSession(session);
6407                    }
6408            }
6409    
6410            protected WikiPage getByN_H_P_PrevAndNext(Session session,
6411                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
6412                    OrderByComparator orderByComparator, boolean previous) {
6413                    StringBundler query = null;
6414    
6415                    if (orderByComparator != null) {
6416                            query = new StringBundler(6 +
6417                                            (orderByComparator.getOrderByFields().length * 6));
6418                    }
6419                    else {
6420                            query = new StringBundler(3);
6421                    }
6422    
6423                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6424    
6425                    query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
6426    
6427                    query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
6428    
6429                    if (parentTitle == null) {
6430                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
6431                    }
6432                    else {
6433                            if (parentTitle.equals(StringPool.BLANK)) {
6434                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
6435                            }
6436                            else {
6437                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
6438                            }
6439                    }
6440    
6441                    if (orderByComparator != null) {
6442                            String[] orderByFields = orderByComparator.getOrderByFields();
6443    
6444                            if (orderByFields.length > 0) {
6445                                    query.append(WHERE_AND);
6446                            }
6447    
6448                            for (int i = 0; i < orderByFields.length; i++) {
6449                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6450                                    query.append(orderByFields[i]);
6451    
6452                                    if ((i + 1) < orderByFields.length) {
6453                                            if (orderByComparator.isAscending() ^ previous) {
6454                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6455                                            }
6456                                            else {
6457                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6458                                            }
6459                                    }
6460                                    else {
6461                                            if (orderByComparator.isAscending() ^ previous) {
6462                                                    query.append(WHERE_GREATER_THAN);
6463                                            }
6464                                            else {
6465                                                    query.append(WHERE_LESSER_THAN);
6466                                            }
6467                                    }
6468                            }
6469    
6470                            query.append(ORDER_BY_CLAUSE);
6471    
6472                            for (int i = 0; i < orderByFields.length; i++) {
6473                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6474                                    query.append(orderByFields[i]);
6475    
6476                                    if ((i + 1) < orderByFields.length) {
6477                                            if (orderByComparator.isAscending() ^ previous) {
6478                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6479                                            }
6480                                            else {
6481                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6482                                            }
6483                                    }
6484                                    else {
6485                                            if (orderByComparator.isAscending() ^ previous) {
6486                                                    query.append(ORDER_BY_ASC);
6487                                            }
6488                                            else {
6489                                                    query.append(ORDER_BY_DESC);
6490                                            }
6491                                    }
6492                            }
6493                    }
6494    
6495                    else {
6496                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6497                    }
6498    
6499                    String sql = query.toString();
6500    
6501                    Query q = session.createQuery(sql);
6502    
6503                    q.setFirstResult(0);
6504                    q.setMaxResults(2);
6505    
6506                    QueryPos qPos = QueryPos.getInstance(q);
6507    
6508                    qPos.add(nodeId);
6509    
6510                    qPos.add(head);
6511    
6512                    if (parentTitle != null) {
6513                            qPos.add(parentTitle);
6514                    }
6515    
6516                    if (orderByComparator != null) {
6517                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
6518    
6519                            for (Object value : values) {
6520                                    qPos.add(value);
6521                            }
6522                    }
6523    
6524                    List<WikiPage> list = q.list();
6525    
6526                    if (list.size() == 2) {
6527                            return list.get(1);
6528                    }
6529                    else {
6530                            return null;
6531                    }
6532            }
6533    
6534            /**
6535             * Finds all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
6536             *
6537             * @param nodeId the node id to search with
6538             * @param head the head to search with
6539             * @param status the status to search with
6540             * @return the matching wiki pages
6541             * @throws SystemException if a system exception occurred
6542             */
6543            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status)
6544                    throws SystemException {
6545                    return findByN_H_S(nodeId, head, status, QueryUtil.ALL_POS,
6546                            QueryUtil.ALL_POS, null);
6547            }
6548    
6549            /**
6550             * Finds a range of all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
6551             *
6552             * <p>
6553             * 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.
6554             * </p>
6555             *
6556             * @param nodeId the node id to search with
6557             * @param head the head to search with
6558             * @param status the status to search with
6559             * @param start the lower bound of the range of wiki pages to return
6560             * @param end the upper bound of the range of wiki pages to return (not inclusive)
6561             * @return the range of matching wiki pages
6562             * @throws SystemException if a system exception occurred
6563             */
6564            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status,
6565                    int start, int end) throws SystemException {
6566                    return findByN_H_S(nodeId, head, status, start, end, null);
6567            }
6568    
6569            /**
6570             * Finds an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
6571             *
6572             * <p>
6573             * 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.
6574             * </p>
6575             *
6576             * @param nodeId the node id to search with
6577             * @param head the head to search with
6578             * @param status the status to search with
6579             * @param start the lower bound of the range of wiki pages to return
6580             * @param end the upper bound of the range of wiki pages to return (not inclusive)
6581             * @param orderByComparator the comparator to order the results by
6582             * @return the ordered range of matching wiki pages
6583             * @throws SystemException if a system exception occurred
6584             */
6585            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status,
6586                    int start, int end, OrderByComparator orderByComparator)
6587                    throws SystemException {
6588                    Object[] finderArgs = new Object[] {
6589                                    nodeId, head, status,
6590                                    
6591                                    String.valueOf(start), String.valueOf(end),
6592                                    String.valueOf(orderByComparator)
6593                            };
6594    
6595                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_H_S,
6596                                    finderArgs, this);
6597    
6598                    if (list == null) {
6599                            Session session = null;
6600    
6601                            try {
6602                                    session = openSession();
6603    
6604                                    StringBundler query = null;
6605    
6606                                    if (orderByComparator != null) {
6607                                            query = new StringBundler(5 +
6608                                                            (orderByComparator.getOrderByFields().length * 3));
6609                                    }
6610                                    else {
6611                                            query = new StringBundler(5);
6612                                    }
6613    
6614                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6615    
6616                                    query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
6617    
6618                                    query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
6619    
6620                                    query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
6621    
6622                                    if (orderByComparator != null) {
6623                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6624                                                    orderByComparator);
6625                                    }
6626    
6627                                    else {
6628                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6629                                    }
6630    
6631                                    String sql = query.toString();
6632    
6633                                    Query q = session.createQuery(sql);
6634    
6635                                    QueryPos qPos = QueryPos.getInstance(q);
6636    
6637                                    qPos.add(nodeId);
6638    
6639                                    qPos.add(head);
6640    
6641                                    qPos.add(status);
6642    
6643                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
6644                                                    end);
6645                            }
6646                            catch (Exception e) {
6647                                    throw processException(e);
6648                            }
6649                            finally {
6650                                    if (list == null) {
6651                                            list = new ArrayList<WikiPage>();
6652                                    }
6653    
6654                                    cacheResult(list);
6655    
6656                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_H_S,
6657                                            finderArgs, list);
6658    
6659                                    closeSession(session);
6660                            }
6661                    }
6662    
6663                    return list;
6664            }
6665    
6666            /**
6667             * Finds the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
6668             *
6669             * <p>
6670             * 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.
6671             * </p>
6672             *
6673             * @param nodeId the node id to search with
6674             * @param head the head to search with
6675             * @param status the status to search with
6676             * @param orderByComparator the comparator to order the set by
6677             * @return the first matching wiki page
6678             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6679             * @throws SystemException if a system exception occurred
6680             */
6681            public WikiPage findByN_H_S_First(long nodeId, boolean head, int status,
6682                    OrderByComparator orderByComparator)
6683                    throws NoSuchPageException, SystemException {
6684                    List<WikiPage> list = findByN_H_S(nodeId, head, status, 0, 1,
6685                                    orderByComparator);
6686    
6687                    if (list.isEmpty()) {
6688                            StringBundler msg = new StringBundler(8);
6689    
6690                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6691    
6692                            msg.append("nodeId=");
6693                            msg.append(nodeId);
6694    
6695                            msg.append(", head=");
6696                            msg.append(head);
6697    
6698                            msg.append(", status=");
6699                            msg.append(status);
6700    
6701                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6702    
6703                            throw new NoSuchPageException(msg.toString());
6704                    }
6705                    else {
6706                            return list.get(0);
6707                    }
6708            }
6709    
6710            /**
6711             * Finds the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
6712             *
6713             * <p>
6714             * 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.
6715             * </p>
6716             *
6717             * @param nodeId the node id to search with
6718             * @param head the head to search with
6719             * @param status the status to search with
6720             * @param orderByComparator the comparator to order the set by
6721             * @return the last matching wiki page
6722             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6723             * @throws SystemException if a system exception occurred
6724             */
6725            public WikiPage findByN_H_S_Last(long nodeId, boolean head, int status,
6726                    OrderByComparator orderByComparator)
6727                    throws NoSuchPageException, SystemException {
6728                    int count = countByN_H_S(nodeId, head, status);
6729    
6730                    List<WikiPage> list = findByN_H_S(nodeId, head, status, count - 1,
6731                                    count, orderByComparator);
6732    
6733                    if (list.isEmpty()) {
6734                            StringBundler msg = new StringBundler(8);
6735    
6736                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6737    
6738                            msg.append("nodeId=");
6739                            msg.append(nodeId);
6740    
6741                            msg.append(", head=");
6742                            msg.append(head);
6743    
6744                            msg.append(", status=");
6745                            msg.append(status);
6746    
6747                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6748    
6749                            throw new NoSuchPageException(msg.toString());
6750                    }
6751                    else {
6752                            return list.get(0);
6753                    }
6754            }
6755    
6756            /**
6757             * Finds the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
6758             *
6759             * <p>
6760             * 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.
6761             * </p>
6762             *
6763             * @param pageId the primary key of the current wiki page
6764             * @param nodeId the node id to search with
6765             * @param head the head to search with
6766             * @param status the status to search with
6767             * @param orderByComparator the comparator to order the set by
6768             * @return the previous, current, and next wiki page
6769             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
6770             * @throws SystemException if a system exception occurred
6771             */
6772            public WikiPage[] findByN_H_S_PrevAndNext(long pageId, long nodeId,
6773                    boolean head, int status, OrderByComparator orderByComparator)
6774                    throws NoSuchPageException, SystemException {
6775                    WikiPage wikiPage = findByPrimaryKey(pageId);
6776    
6777                    Session session = null;
6778    
6779                    try {
6780                            session = openSession();
6781    
6782                            WikiPage[] array = new WikiPageImpl[3];
6783    
6784                            array[0] = getByN_H_S_PrevAndNext(session, wikiPage, nodeId, head,
6785                                            status, orderByComparator, true);
6786    
6787                            array[1] = wikiPage;
6788    
6789                            array[2] = getByN_H_S_PrevAndNext(session, wikiPage, nodeId, head,
6790                                            status, orderByComparator, false);
6791    
6792                            return array;
6793                    }
6794                    catch (Exception e) {
6795                            throw processException(e);
6796                    }
6797                    finally {
6798                            closeSession(session);
6799                    }
6800            }
6801    
6802            protected WikiPage getByN_H_S_PrevAndNext(Session session,
6803                    WikiPage wikiPage, long nodeId, boolean head, int status,
6804                    OrderByComparator orderByComparator, boolean previous) {
6805                    StringBundler query = null;
6806    
6807                    if (orderByComparator != null) {
6808                            query = new StringBundler(6 +
6809                                            (orderByComparator.getOrderByFields().length * 6));
6810                    }
6811                    else {
6812                            query = new StringBundler(3);
6813                    }
6814    
6815                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6816    
6817                    query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
6818    
6819                    query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
6820    
6821                    query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
6822    
6823                    if (orderByComparator != null) {
6824                            String[] orderByFields = orderByComparator.getOrderByFields();
6825    
6826                            if (orderByFields.length > 0) {
6827                                    query.append(WHERE_AND);
6828                            }
6829    
6830                            for (int i = 0; i < orderByFields.length; i++) {
6831                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6832                                    query.append(orderByFields[i]);
6833    
6834                                    if ((i + 1) < orderByFields.length) {
6835                                            if (orderByComparator.isAscending() ^ previous) {
6836                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6837                                            }
6838                                            else {
6839                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6840                                            }
6841                                    }
6842                                    else {
6843                                            if (orderByComparator.isAscending() ^ previous) {
6844                                                    query.append(WHERE_GREATER_THAN);
6845                                            }
6846                                            else {
6847                                                    query.append(WHERE_LESSER_THAN);
6848                                            }
6849                                    }
6850                            }
6851    
6852                            query.append(ORDER_BY_CLAUSE);
6853    
6854                            for (int i = 0; i < orderByFields.length; i++) {
6855                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6856                                    query.append(orderByFields[i]);
6857    
6858                                    if ((i + 1) < orderByFields.length) {
6859                                            if (orderByComparator.isAscending() ^ previous) {
6860                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6861                                            }
6862                                            else {
6863                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6864                                            }
6865                                    }
6866                                    else {
6867                                            if (orderByComparator.isAscending() ^ previous) {
6868                                                    query.append(ORDER_BY_ASC);
6869                                            }
6870                                            else {
6871                                                    query.append(ORDER_BY_DESC);
6872                                            }
6873                                    }
6874                            }
6875                    }
6876    
6877                    else {
6878                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6879                    }
6880    
6881                    String sql = query.toString();
6882    
6883                    Query q = session.createQuery(sql);
6884    
6885                    q.setFirstResult(0);
6886                    q.setMaxResults(2);
6887    
6888                    QueryPos qPos = QueryPos.getInstance(q);
6889    
6890                    qPos.add(nodeId);
6891    
6892                    qPos.add(head);
6893    
6894                    qPos.add(status);
6895    
6896                    if (orderByComparator != null) {
6897                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
6898    
6899                            for (Object value : values) {
6900                                    qPos.add(value);
6901                            }
6902                    }
6903    
6904                    List<WikiPage> list = q.list();
6905    
6906                    if (list.size() == 2) {
6907                            return list.get(1);
6908                    }
6909                    else {
6910                            return null;
6911                    }
6912            }
6913    
6914            /**
6915             * Finds all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
6916             *
6917             * @param nodeId the node id to search with
6918             * @param head the head to search with
6919             * @param parentTitle the parent title to search with
6920             * @param status the status to search with
6921             * @return the matching wiki pages
6922             * @throws SystemException if a system exception occurred
6923             */
6924            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
6925                    String parentTitle, int status) throws SystemException {
6926                    return findByN_H_P_S(nodeId, head, parentTitle, status,
6927                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6928            }
6929    
6930            /**
6931             * Finds a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
6932             *
6933             * <p>
6934             * 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.
6935             * </p>
6936             *
6937             * @param nodeId the node id to search with
6938             * @param head the head to search with
6939             * @param parentTitle the parent title to search with
6940             * @param status the status to search with
6941             * @param start the lower bound of the range of wiki pages to return
6942             * @param end the upper bound of the range of wiki pages to return (not inclusive)
6943             * @return the range of matching wiki pages
6944             * @throws SystemException if a system exception occurred
6945             */
6946            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
6947                    String parentTitle, int status, int start, int end)
6948                    throws SystemException {
6949                    return findByN_H_P_S(nodeId, head, parentTitle, status, start, end, null);
6950            }
6951    
6952            /**
6953             * Finds an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
6954             *
6955             * <p>
6956             * 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.
6957             * </p>
6958             *
6959             * @param nodeId the node id to search with
6960             * @param head the head to search with
6961             * @param parentTitle the parent title to search with
6962             * @param status the status to search with
6963             * @param start the lower bound of the range of wiki pages to return
6964             * @param end the upper bound of the range of wiki pages to return (not inclusive)
6965             * @param orderByComparator the comparator to order the results by
6966             * @return the ordered range of matching wiki pages
6967             * @throws SystemException if a system exception occurred
6968             */
6969            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
6970                    String parentTitle, int status, int start, int end,
6971                    OrderByComparator orderByComparator) throws SystemException {
6972                    Object[] finderArgs = new Object[] {
6973                                    nodeId, head, parentTitle, status,
6974                                    
6975                                    String.valueOf(start), String.valueOf(end),
6976                                    String.valueOf(orderByComparator)
6977                            };
6978    
6979                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_H_P_S,
6980                                    finderArgs, this);
6981    
6982                    if (list == null) {
6983                            Session session = null;
6984    
6985                            try {
6986                                    session = openSession();
6987    
6988                                    StringBundler query = null;
6989    
6990                                    if (orderByComparator != null) {
6991                                            query = new StringBundler(6 +
6992                                                            (orderByComparator.getOrderByFields().length * 3));
6993                                    }
6994                                    else {
6995                                            query = new StringBundler(6);
6996                                    }
6997    
6998                                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6999    
7000                                    query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
7001    
7002                                    query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
7003    
7004                                    if (parentTitle == null) {
7005                                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
7006                                    }
7007                                    else {
7008                                            if (parentTitle.equals(StringPool.BLANK)) {
7009                                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
7010                                            }
7011                                            else {
7012                                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
7013                                            }
7014                                    }
7015    
7016                                    query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
7017    
7018                                    if (orderByComparator != null) {
7019                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7020                                                    orderByComparator);
7021                                    }
7022    
7023                                    else {
7024                                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7025                                    }
7026    
7027                                    String sql = query.toString();
7028    
7029                                    Query q = session.createQuery(sql);
7030    
7031                                    QueryPos qPos = QueryPos.getInstance(q);
7032    
7033                                    qPos.add(nodeId);
7034    
7035                                    qPos.add(head);
7036    
7037                                    if (parentTitle != null) {
7038                                            qPos.add(parentTitle);
7039                                    }
7040    
7041                                    qPos.add(status);
7042    
7043                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
7044                                                    end);
7045                            }
7046                            catch (Exception e) {
7047                                    throw processException(e);
7048                            }
7049                            finally {
7050                                    if (list == null) {
7051                                            list = new ArrayList<WikiPage>();
7052                                    }
7053    
7054                                    cacheResult(list);
7055    
7056                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_H_P_S,
7057                                            finderArgs, list);
7058    
7059                                    closeSession(session);
7060                            }
7061                    }
7062    
7063                    return list;
7064            }
7065    
7066            /**
7067             * Finds the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
7068             *
7069             * <p>
7070             * 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.
7071             * </p>
7072             *
7073             * @param nodeId the node id to search with
7074             * @param head the head to search with
7075             * @param parentTitle the parent title to search with
7076             * @param status the status to search with
7077             * @param orderByComparator the comparator to order the set by
7078             * @return the first matching wiki page
7079             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7080             * @throws SystemException if a system exception occurred
7081             */
7082            public WikiPage findByN_H_P_S_First(long nodeId, boolean head,
7083                    String parentTitle, int status, OrderByComparator orderByComparator)
7084                    throws NoSuchPageException, SystemException {
7085                    List<WikiPage> list = findByN_H_P_S(nodeId, head, parentTitle, status,
7086                                    0, 1, orderByComparator);
7087    
7088                    if (list.isEmpty()) {
7089                            StringBundler msg = new StringBundler(10);
7090    
7091                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7092    
7093                            msg.append("nodeId=");
7094                            msg.append(nodeId);
7095    
7096                            msg.append(", head=");
7097                            msg.append(head);
7098    
7099                            msg.append(", parentTitle=");
7100                            msg.append(parentTitle);
7101    
7102                            msg.append(", status=");
7103                            msg.append(status);
7104    
7105                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7106    
7107                            throw new NoSuchPageException(msg.toString());
7108                    }
7109                    else {
7110                            return list.get(0);
7111                    }
7112            }
7113    
7114            /**
7115             * Finds the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
7116             *
7117             * <p>
7118             * 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.
7119             * </p>
7120             *
7121             * @param nodeId the node id to search with
7122             * @param head the head to search with
7123             * @param parentTitle the parent title to search with
7124             * @param status the status to search with
7125             * @param orderByComparator the comparator to order the set by
7126             * @return the last matching wiki page
7127             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7128             * @throws SystemException if a system exception occurred
7129             */
7130            public WikiPage findByN_H_P_S_Last(long nodeId, boolean head,
7131                    String parentTitle, int status, OrderByComparator orderByComparator)
7132                    throws NoSuchPageException, SystemException {
7133                    int count = countByN_H_P_S(nodeId, head, parentTitle, status);
7134    
7135                    List<WikiPage> list = findByN_H_P_S(nodeId, head, parentTitle, status,
7136                                    count - 1, count, orderByComparator);
7137    
7138                    if (list.isEmpty()) {
7139                            StringBundler msg = new StringBundler(10);
7140    
7141                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7142    
7143                            msg.append("nodeId=");
7144                            msg.append(nodeId);
7145    
7146                            msg.append(", head=");
7147                            msg.append(head);
7148    
7149                            msg.append(", parentTitle=");
7150                            msg.append(parentTitle);
7151    
7152                            msg.append(", status=");
7153                            msg.append(status);
7154    
7155                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7156    
7157                            throw new NoSuchPageException(msg.toString());
7158                    }
7159                    else {
7160                            return list.get(0);
7161                    }
7162            }
7163    
7164            /**
7165             * Finds 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;.
7166             *
7167             * <p>
7168             * 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.
7169             * </p>
7170             *
7171             * @param pageId the primary key of the current wiki page
7172             * @param nodeId the node id to search with
7173             * @param head the head to search with
7174             * @param parentTitle the parent title to search with
7175             * @param status the status to search with
7176             * @param orderByComparator the comparator to order the set by
7177             * @return the previous, current, and next wiki page
7178             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
7179             * @throws SystemException if a system exception occurred
7180             */
7181            public WikiPage[] findByN_H_P_S_PrevAndNext(long pageId, long nodeId,
7182                    boolean head, String parentTitle, int status,
7183                    OrderByComparator orderByComparator)
7184                    throws NoSuchPageException, SystemException {
7185                    WikiPage wikiPage = findByPrimaryKey(pageId);
7186    
7187                    Session session = null;
7188    
7189                    try {
7190                            session = openSession();
7191    
7192                            WikiPage[] array = new WikiPageImpl[3];
7193    
7194                            array[0] = getByN_H_P_S_PrevAndNext(session, wikiPage, nodeId,
7195                                            head, parentTitle, status, orderByComparator, true);
7196    
7197                            array[1] = wikiPage;
7198    
7199                            array[2] = getByN_H_P_S_PrevAndNext(session, wikiPage, nodeId,
7200                                            head, parentTitle, status, orderByComparator, false);
7201    
7202                            return array;
7203                    }
7204                    catch (Exception e) {
7205                            throw processException(e);
7206                    }
7207                    finally {
7208                            closeSession(session);
7209                    }
7210            }
7211    
7212            protected WikiPage getByN_H_P_S_PrevAndNext(Session session,
7213                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
7214                    int status, OrderByComparator orderByComparator, boolean previous) {
7215                    StringBundler query = null;
7216    
7217                    if (orderByComparator != null) {
7218                            query = new StringBundler(6 +
7219                                            (orderByComparator.getOrderByFields().length * 6));
7220                    }
7221                    else {
7222                            query = new StringBundler(3);
7223                    }
7224    
7225                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7226    
7227                    query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
7228    
7229                    query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
7230    
7231                    if (parentTitle == null) {
7232                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
7233                    }
7234                    else {
7235                            if (parentTitle.equals(StringPool.BLANK)) {
7236                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
7237                            }
7238                            else {
7239                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
7240                            }
7241                    }
7242    
7243                    query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
7244    
7245                    if (orderByComparator != null) {
7246                            String[] orderByFields = orderByComparator.getOrderByFields();
7247    
7248                            if (orderByFields.length > 0) {
7249                                    query.append(WHERE_AND);
7250                            }
7251    
7252                            for (int i = 0; i < orderByFields.length; i++) {
7253                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7254                                    query.append(orderByFields[i]);
7255    
7256                                    if ((i + 1) < orderByFields.length) {
7257                                            if (orderByComparator.isAscending() ^ previous) {
7258                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7259                                            }
7260                                            else {
7261                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7262                                            }
7263                                    }
7264                                    else {
7265                                            if (orderByComparator.isAscending() ^ previous) {
7266                                                    query.append(WHERE_GREATER_THAN);
7267                                            }
7268                                            else {
7269                                                    query.append(WHERE_LESSER_THAN);
7270                                            }
7271                                    }
7272                            }
7273    
7274                            query.append(ORDER_BY_CLAUSE);
7275    
7276                            for (int i = 0; i < orderByFields.length; i++) {
7277                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7278                                    query.append(orderByFields[i]);
7279    
7280                                    if ((i + 1) < orderByFields.length) {
7281                                            if (orderByComparator.isAscending() ^ previous) {
7282                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7283                                            }
7284                                            else {
7285                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7286                                            }
7287                                    }
7288                                    else {
7289                                            if (orderByComparator.isAscending() ^ previous) {
7290                                                    query.append(ORDER_BY_ASC);
7291                                            }
7292                                            else {
7293                                                    query.append(ORDER_BY_DESC);
7294                                            }
7295                                    }
7296                            }
7297                    }
7298    
7299                    else {
7300                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7301                    }
7302    
7303                    String sql = query.toString();
7304    
7305                    Query q = session.createQuery(sql);
7306    
7307                    q.setFirstResult(0);
7308                    q.setMaxResults(2);
7309    
7310                    QueryPos qPos = QueryPos.getInstance(q);
7311    
7312                    qPos.add(nodeId);
7313    
7314                    qPos.add(head);
7315    
7316                    if (parentTitle != null) {
7317                            qPos.add(parentTitle);
7318                    }
7319    
7320                    qPos.add(status);
7321    
7322                    if (orderByComparator != null) {
7323                            Object[] values = orderByComparator.getOrderByValues(wikiPage);
7324    
7325                            for (Object value : values) {
7326                                    qPos.add(value);
7327                            }
7328                    }
7329    
7330                    List<WikiPage> list = q.list();
7331    
7332                    if (list.size() == 2) {
7333                            return list.get(1);
7334                    }
7335                    else {
7336                            return null;
7337                    }
7338            }
7339    
7340            /**
7341             * Finds all the wiki pages.
7342             *
7343             * @return the wiki pages
7344             * @throws SystemException if a system exception occurred
7345             */
7346            public List<WikiPage> findAll() throws SystemException {
7347                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7348            }
7349    
7350            /**
7351             * Finds a range of all the wiki pages.
7352             *
7353             * <p>
7354             * 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.
7355             * </p>
7356             *
7357             * @param start the lower bound of the range of wiki pages to return
7358             * @param end the upper bound of the range of wiki pages to return (not inclusive)
7359             * @return the range of wiki pages
7360             * @throws SystemException if a system exception occurred
7361             */
7362            public List<WikiPage> findAll(int start, int end) throws SystemException {
7363                    return findAll(start, end, null);
7364            }
7365    
7366            /**
7367             * Finds an ordered range of all the wiki pages.
7368             *
7369             * <p>
7370             * 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.
7371             * </p>
7372             *
7373             * @param start the lower bound of the range of wiki pages to return
7374             * @param end the upper bound of the range of wiki pages to return (not inclusive)
7375             * @param orderByComparator the comparator to order the results by
7376             * @return the ordered range of wiki pages
7377             * @throws SystemException if a system exception occurred
7378             */
7379            public List<WikiPage> findAll(int start, int end,
7380                    OrderByComparator orderByComparator) throws SystemException {
7381                    Object[] finderArgs = new Object[] {
7382                                    String.valueOf(start), String.valueOf(end),
7383                                    String.valueOf(orderByComparator)
7384                            };
7385    
7386                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
7387                                    finderArgs, this);
7388    
7389                    if (list == null) {
7390                            Session session = null;
7391    
7392                            try {
7393                                    session = openSession();
7394    
7395                                    StringBundler query = null;
7396                                    String sql = null;
7397    
7398                                    if (orderByComparator != null) {
7399                                            query = new StringBundler(2 +
7400                                                            (orderByComparator.getOrderByFields().length * 3));
7401    
7402                                            query.append(_SQL_SELECT_WIKIPAGE);
7403    
7404                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7405                                                    orderByComparator);
7406    
7407                                            sql = query.toString();
7408                                    }
7409                                    else {
7410                                            sql = _SQL_SELECT_WIKIPAGE.concat(WikiPageModelImpl.ORDER_BY_JPQL);
7411                                    }
7412    
7413                                    Query q = session.createQuery(sql);
7414    
7415                                    if (orderByComparator == null) {
7416                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
7417                                                            start, end, false);
7418    
7419                                            Collections.sort(list);
7420                                    }
7421                                    else {
7422                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
7423                                                            start, end);
7424                                    }
7425                            }
7426                            catch (Exception e) {
7427                                    throw processException(e);
7428                            }
7429                            finally {
7430                                    if (list == null) {
7431                                            list = new ArrayList<WikiPage>();
7432                                    }
7433    
7434                                    cacheResult(list);
7435    
7436                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
7437    
7438                                    closeSession(session);
7439                            }
7440                    }
7441    
7442                    return list;
7443            }
7444    
7445            /**
7446             * Removes all the wiki pages where uuid = &#63; from the database.
7447             *
7448             * @param uuid the uuid to search with
7449             * @throws SystemException if a system exception occurred
7450             */
7451            public void removeByUuid(String uuid) throws SystemException {
7452                    for (WikiPage wikiPage : findByUuid(uuid)) {
7453                            remove(wikiPage);
7454                    }
7455            }
7456    
7457            /**
7458             * Removes the wiki page where uuid = &#63; and groupId = &#63; from the database.
7459             *
7460             * @param uuid the uuid to search with
7461             * @param groupId the group id to search with
7462             * @throws SystemException if a system exception occurred
7463             */
7464            public void removeByUUID_G(String uuid, long groupId)
7465                    throws NoSuchPageException, SystemException {
7466                    WikiPage wikiPage = findByUUID_G(uuid, groupId);
7467    
7468                    remove(wikiPage);
7469            }
7470    
7471            /**
7472             * Removes all the wiki pages where nodeId = &#63; from the database.
7473             *
7474             * @param nodeId the node id to search with
7475             * @throws SystemException if a system exception occurred
7476             */
7477            public void removeByNodeId(long nodeId) throws SystemException {
7478                    for (WikiPage wikiPage : findByNodeId(nodeId)) {
7479                            remove(wikiPage);
7480                    }
7481            }
7482    
7483            /**
7484             * Removes all the wiki pages where format = &#63; from the database.
7485             *
7486             * @param format the format to search with
7487             * @throws SystemException if a system exception occurred
7488             */
7489            public void removeByFormat(String format) throws SystemException {
7490                    for (WikiPage wikiPage : findByFormat(format)) {
7491                            remove(wikiPage);
7492                    }
7493            }
7494    
7495            /**
7496             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; from the database.
7497             *
7498             * @param resourcePrimKey the resource prim key to search with
7499             * @param nodeId the node id to search with
7500             * @throws SystemException if a system exception occurred
7501             */
7502            public void removeByR_N(long resourcePrimKey, long nodeId)
7503                    throws SystemException {
7504                    for (WikiPage wikiPage : findByR_N(resourcePrimKey, nodeId)) {
7505                            remove(wikiPage);
7506                    }
7507            }
7508    
7509            /**
7510             * Removes all the wiki pages where nodeId = &#63; and title = &#63; from the database.
7511             *
7512             * @param nodeId the node id to search with
7513             * @param title the title to search with
7514             * @throws SystemException if a system exception occurred
7515             */
7516            public void removeByN_T(long nodeId, String title)
7517                    throws SystemException {
7518                    for (WikiPage wikiPage : findByN_T(nodeId, title)) {
7519                            remove(wikiPage);
7520                    }
7521            }
7522    
7523            /**
7524             * Removes all the wiki pages where nodeId = &#63; and head = &#63; from the database.
7525             *
7526             * @param nodeId the node id to search with
7527             * @param head the head to search with
7528             * @throws SystemException if a system exception occurred
7529             */
7530            public void removeByN_H(long nodeId, boolean head)
7531                    throws SystemException {
7532                    for (WikiPage wikiPage : findByN_H(nodeId, head)) {
7533                            remove(wikiPage);
7534                    }
7535            }
7536    
7537            /**
7538             * Removes all the wiki pages where nodeId = &#63; and parentTitle = &#63; from the database.
7539             *
7540             * @param nodeId the node id to search with
7541             * @param parentTitle the parent title to search with
7542             * @throws SystemException if a system exception occurred
7543             */
7544            public void removeByN_P(long nodeId, String parentTitle)
7545                    throws SystemException {
7546                    for (WikiPage wikiPage : findByN_P(nodeId, parentTitle)) {
7547                            remove(wikiPage);
7548                    }
7549            }
7550    
7551            /**
7552             * Removes all the wiki pages where nodeId = &#63; and redirectTitle = &#63; from the database.
7553             *
7554             * @param nodeId the node id to search with
7555             * @param redirectTitle the redirect title to search with
7556             * @throws SystemException if a system exception occurred
7557             */
7558            public void removeByN_R(long nodeId, String redirectTitle)
7559                    throws SystemException {
7560                    for (WikiPage wikiPage : findByN_R(nodeId, redirectTitle)) {
7561                            remove(wikiPage);
7562                    }
7563            }
7564    
7565            /**
7566             * Removes all the wiki pages where nodeId = &#63; and status = &#63; from the database.
7567             *
7568             * @param nodeId the node id to search with
7569             * @param status the status to search with
7570             * @throws SystemException if a system exception occurred
7571             */
7572            public void removeByN_S(long nodeId, int status) throws SystemException {
7573                    for (WikiPage wikiPage : findByN_S(nodeId, status)) {
7574                            remove(wikiPage);
7575                    }
7576            }
7577    
7578            /**
7579             * Removes the wiki page where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63; from the database.
7580             *
7581             * @param resourcePrimKey the resource prim key to search with
7582             * @param nodeId the node id to search with
7583             * @param version the version to search with
7584             * @throws SystemException if a system exception occurred
7585             */
7586            public void removeByR_N_V(long resourcePrimKey, long nodeId, double version)
7587                    throws NoSuchPageException, SystemException {
7588                    WikiPage wikiPage = findByR_N_V(resourcePrimKey, nodeId, version);
7589    
7590                    remove(wikiPage);
7591            }
7592    
7593            /**
7594             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63; from the database.
7595             *
7596             * @param resourcePrimKey the resource prim key to search with
7597             * @param nodeId the node id to search with
7598             * @param status the status to search with
7599             * @throws SystemException if a system exception occurred
7600             */
7601            public void removeByR_N_S(long resourcePrimKey, long nodeId, int status)
7602                    throws SystemException {
7603                    for (WikiPage wikiPage : findByR_N_S(resourcePrimKey, nodeId, status)) {
7604                            remove(wikiPage);
7605                    }
7606            }
7607    
7608            /**
7609             * Removes all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63; from the database.
7610             *
7611             * @param userId the user id to search with
7612             * @param nodeId the node id to search with
7613             * @param status the status to search with
7614             * @throws SystemException if a system exception occurred
7615             */
7616            public void removeByU_N_S(long userId, long nodeId, int status)
7617                    throws SystemException {
7618                    for (WikiPage wikiPage : findByU_N_S(userId, nodeId, status)) {
7619                            remove(wikiPage);
7620                    }
7621            }
7622    
7623            /**
7624             * Removes the wiki page where nodeId = &#63; and title = &#63; and version = &#63; from the database.
7625             *
7626             * @param nodeId the node id to search with
7627             * @param title the title to search with
7628             * @param version the version to search with
7629             * @throws SystemException if a system exception occurred
7630             */
7631            public void removeByN_T_V(long nodeId, String title, double version)
7632                    throws NoSuchPageException, SystemException {
7633                    WikiPage wikiPage = findByN_T_V(nodeId, title, version);
7634    
7635                    remove(wikiPage);
7636            }
7637    
7638            /**
7639             * Removes all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63; from the database.
7640             *
7641             * @param nodeId the node id to search with
7642             * @param title the title to search with
7643             * @param head the head to search with
7644             * @throws SystemException if a system exception occurred
7645             */
7646            public void removeByN_T_H(long nodeId, String title, boolean head)
7647                    throws SystemException {
7648                    for (WikiPage wikiPage : findByN_T_H(nodeId, title, head)) {
7649                            remove(wikiPage);
7650                    }
7651            }
7652    
7653            /**
7654             * Removes all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63; from the database.
7655             *
7656             * @param nodeId the node id to search with
7657             * @param title the title to search with
7658             * @param status the status to search with
7659             * @throws SystemException if a system exception occurred
7660             */
7661            public void removeByN_T_S(long nodeId, String title, int status)
7662                    throws SystemException {
7663                    for (WikiPage wikiPage : findByN_T_S(nodeId, title, status)) {
7664                            remove(wikiPage);
7665                    }
7666            }
7667    
7668            /**
7669             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; from the database.
7670             *
7671             * @param nodeId the node id to search with
7672             * @param head the head to search with
7673             * @param parentTitle the parent title to search with
7674             * @throws SystemException if a system exception occurred
7675             */
7676            public void removeByN_H_P(long nodeId, boolean head, String parentTitle)
7677                    throws SystemException {
7678                    for (WikiPage wikiPage : findByN_H_P(nodeId, head, parentTitle)) {
7679                            remove(wikiPage);
7680                    }
7681            }
7682    
7683            /**
7684             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63; from the database.
7685             *
7686             * @param nodeId the node id to search with
7687             * @param head the head to search with
7688             * @param status the status to search with
7689             * @throws SystemException if a system exception occurred
7690             */
7691            public void removeByN_H_S(long nodeId, boolean head, int status)
7692                    throws SystemException {
7693                    for (WikiPage wikiPage : findByN_H_S(nodeId, head, status)) {
7694                            remove(wikiPage);
7695                    }
7696            }
7697    
7698            /**
7699             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63; from the database.
7700             *
7701             * @param nodeId the node id to search with
7702             * @param head the head to search with
7703             * @param parentTitle the parent title to search with
7704             * @param status the status to search with
7705             * @throws SystemException if a system exception occurred
7706             */
7707            public void removeByN_H_P_S(long nodeId, boolean head, String parentTitle,
7708                    int status) throws SystemException {
7709                    for (WikiPage wikiPage : findByN_H_P_S(nodeId, head, parentTitle, status)) {
7710                            remove(wikiPage);
7711                    }
7712            }
7713    
7714            /**
7715             * Removes all the wiki pages from the database.
7716             *
7717             * @throws SystemException if a system exception occurred
7718             */
7719            public void removeAll() throws SystemException {
7720                    for (WikiPage wikiPage : findAll()) {
7721                            remove(wikiPage);
7722                    }
7723            }
7724    
7725            /**
7726             * Counts all the wiki pages where uuid = &#63;.
7727             *
7728             * @param uuid the uuid to search with
7729             * @return the number of matching wiki pages
7730             * @throws SystemException if a system exception occurred
7731             */
7732            public int countByUuid(String uuid) throws SystemException {
7733                    Object[] finderArgs = new Object[] { uuid };
7734    
7735                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
7736                                    finderArgs, this);
7737    
7738                    if (count == null) {
7739                            Session session = null;
7740    
7741                            try {
7742                                    session = openSession();
7743    
7744                                    StringBundler query = new StringBundler(2);
7745    
7746                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
7747    
7748                                    if (uuid == null) {
7749                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
7750                                    }
7751                                    else {
7752                                            if (uuid.equals(StringPool.BLANK)) {
7753                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
7754                                            }
7755                                            else {
7756                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
7757                                            }
7758                                    }
7759    
7760                                    String sql = query.toString();
7761    
7762                                    Query q = session.createQuery(sql);
7763    
7764                                    QueryPos qPos = QueryPos.getInstance(q);
7765    
7766                                    if (uuid != null) {
7767                                            qPos.add(uuid);
7768                                    }
7769    
7770                                    count = (Long)q.uniqueResult();
7771                            }
7772                            catch (Exception e) {
7773                                    throw processException(e);
7774                            }
7775                            finally {
7776                                    if (count == null) {
7777                                            count = Long.valueOf(0);
7778                                    }
7779    
7780                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
7781                                            finderArgs, count);
7782    
7783                                    closeSession(session);
7784                            }
7785                    }
7786    
7787                    return count.intValue();
7788            }
7789    
7790            /**
7791             * Counts all the wiki pages where uuid = &#63; and groupId = &#63;.
7792             *
7793             * @param uuid the uuid to search with
7794             * @param groupId the group id to search with
7795             * @return the number of matching wiki pages
7796             * @throws SystemException if a system exception occurred
7797             */
7798            public int countByUUID_G(String uuid, long groupId)
7799                    throws SystemException {
7800                    Object[] finderArgs = new Object[] { uuid, groupId };
7801    
7802                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
7803                                    finderArgs, this);
7804    
7805                    if (count == null) {
7806                            Session session = null;
7807    
7808                            try {
7809                                    session = openSession();
7810    
7811                                    StringBundler query = new StringBundler(3);
7812    
7813                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
7814    
7815                                    if (uuid == null) {
7816                                            query.append(_FINDER_COLUMN_UUID_G_UUID_1);
7817                                    }
7818                                    else {
7819                                            if (uuid.equals(StringPool.BLANK)) {
7820                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
7821                                            }
7822                                            else {
7823                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
7824                                            }
7825                                    }
7826    
7827                                    query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
7828    
7829                                    String sql = query.toString();
7830    
7831                                    Query q = session.createQuery(sql);
7832    
7833                                    QueryPos qPos = QueryPos.getInstance(q);
7834    
7835                                    if (uuid != null) {
7836                                            qPos.add(uuid);
7837                                    }
7838    
7839                                    qPos.add(groupId);
7840    
7841                                    count = (Long)q.uniqueResult();
7842                            }
7843                            catch (Exception e) {
7844                                    throw processException(e);
7845                            }
7846                            finally {
7847                                    if (count == null) {
7848                                            count = Long.valueOf(0);
7849                                    }
7850    
7851                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
7852                                            finderArgs, count);
7853    
7854                                    closeSession(session);
7855                            }
7856                    }
7857    
7858                    return count.intValue();
7859            }
7860    
7861            /**
7862             * Counts all the wiki pages where nodeId = &#63;.
7863             *
7864             * @param nodeId the node id to search with
7865             * @return the number of matching wiki pages
7866             * @throws SystemException if a system exception occurred
7867             */
7868            public int countByNodeId(long nodeId) throws SystemException {
7869                    Object[] finderArgs = new Object[] { nodeId };
7870    
7871                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NODEID,
7872                                    finderArgs, this);
7873    
7874                    if (count == null) {
7875                            Session session = null;
7876    
7877                            try {
7878                                    session = openSession();
7879    
7880                                    StringBundler query = new StringBundler(2);
7881    
7882                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
7883    
7884                                    query.append(_FINDER_COLUMN_NODEID_NODEID_2);
7885    
7886                                    String sql = query.toString();
7887    
7888                                    Query q = session.createQuery(sql);
7889    
7890                                    QueryPos qPos = QueryPos.getInstance(q);
7891    
7892                                    qPos.add(nodeId);
7893    
7894                                    count = (Long)q.uniqueResult();
7895                            }
7896                            catch (Exception e) {
7897                                    throw processException(e);
7898                            }
7899                            finally {
7900                                    if (count == null) {
7901                                            count = Long.valueOf(0);
7902                                    }
7903    
7904                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NODEID,
7905                                            finderArgs, count);
7906    
7907                                    closeSession(session);
7908                            }
7909                    }
7910    
7911                    return count.intValue();
7912            }
7913    
7914            /**
7915             * Counts all the wiki pages where format = &#63;.
7916             *
7917             * @param format the format to search with
7918             * @return the number of matching wiki pages
7919             * @throws SystemException if a system exception occurred
7920             */
7921            public int countByFormat(String format) throws SystemException {
7922                    Object[] finderArgs = new Object[] { format };
7923    
7924                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FORMAT,
7925                                    finderArgs, this);
7926    
7927                    if (count == null) {
7928                            Session session = null;
7929    
7930                            try {
7931                                    session = openSession();
7932    
7933                                    StringBundler query = new StringBundler(2);
7934    
7935                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
7936    
7937                                    if (format == null) {
7938                                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
7939                                    }
7940                                    else {
7941                                            if (format.equals(StringPool.BLANK)) {
7942                                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
7943                                            }
7944                                            else {
7945                                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
7946                                            }
7947                                    }
7948    
7949                                    String sql = query.toString();
7950    
7951                                    Query q = session.createQuery(sql);
7952    
7953                                    QueryPos qPos = QueryPos.getInstance(q);
7954    
7955                                    if (format != null) {
7956                                            qPos.add(format);
7957                                    }
7958    
7959                                    count = (Long)q.uniqueResult();
7960                            }
7961                            catch (Exception e) {
7962                                    throw processException(e);
7963                            }
7964                            finally {
7965                                    if (count == null) {
7966                                            count = Long.valueOf(0);
7967                                    }
7968    
7969                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FORMAT,
7970                                            finderArgs, count);
7971    
7972                                    closeSession(session);
7973                            }
7974                    }
7975    
7976                    return count.intValue();
7977            }
7978    
7979            /**
7980             * Counts all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
7981             *
7982             * @param resourcePrimKey the resource prim key to search with
7983             * @param nodeId the node id to search with
7984             * @return the number of matching wiki pages
7985             * @throws SystemException if a system exception occurred
7986             */
7987            public int countByR_N(long resourcePrimKey, long nodeId)
7988                    throws SystemException {
7989                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId };
7990    
7991                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_N,
7992                                    finderArgs, this);
7993    
7994                    if (count == null) {
7995                            Session session = null;
7996    
7997                            try {
7998                                    session = openSession();
7999    
8000                                    StringBundler query = new StringBundler(3);
8001    
8002                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8003    
8004                                    query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
8005    
8006                                    query.append(_FINDER_COLUMN_R_N_NODEID_2);
8007    
8008                                    String sql = query.toString();
8009    
8010                                    Query q = session.createQuery(sql);
8011    
8012                                    QueryPos qPos = QueryPos.getInstance(q);
8013    
8014                                    qPos.add(resourcePrimKey);
8015    
8016                                    qPos.add(nodeId);
8017    
8018                                    count = (Long)q.uniqueResult();
8019                            }
8020                            catch (Exception e) {
8021                                    throw processException(e);
8022                            }
8023                            finally {
8024                                    if (count == null) {
8025                                            count = Long.valueOf(0);
8026                                    }
8027    
8028                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N, finderArgs,
8029                                            count);
8030    
8031                                    closeSession(session);
8032                            }
8033                    }
8034    
8035                    return count.intValue();
8036            }
8037    
8038            /**
8039             * Counts all the wiki pages where nodeId = &#63; and title = &#63;.
8040             *
8041             * @param nodeId the node id to search with
8042             * @param title the title to search with
8043             * @return the number of matching wiki pages
8044             * @throws SystemException if a system exception occurred
8045             */
8046            public int countByN_T(long nodeId, String title) throws SystemException {
8047                    Object[] finderArgs = new Object[] { nodeId, title };
8048    
8049                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T,
8050                                    finderArgs, this);
8051    
8052                    if (count == null) {
8053                            Session session = null;
8054    
8055                            try {
8056                                    session = openSession();
8057    
8058                                    StringBundler query = new StringBundler(3);
8059    
8060                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8061    
8062                                    query.append(_FINDER_COLUMN_N_T_NODEID_2);
8063    
8064                                    if (title == null) {
8065                                            query.append(_FINDER_COLUMN_N_T_TITLE_1);
8066                                    }
8067                                    else {
8068                                            if (title.equals(StringPool.BLANK)) {
8069                                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
8070                                            }
8071                                            else {
8072                                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
8073                                            }
8074                                    }
8075    
8076                                    String sql = query.toString();
8077    
8078                                    Query q = session.createQuery(sql);
8079    
8080                                    QueryPos qPos = QueryPos.getInstance(q);
8081    
8082                                    qPos.add(nodeId);
8083    
8084                                    if (title != null) {
8085                                            qPos.add(title);
8086                                    }
8087    
8088                                    count = (Long)q.uniqueResult();
8089                            }
8090                            catch (Exception e) {
8091                                    throw processException(e);
8092                            }
8093                            finally {
8094                                    if (count == null) {
8095                                            count = Long.valueOf(0);
8096                                    }
8097    
8098                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, finderArgs,
8099                                            count);
8100    
8101                                    closeSession(session);
8102                            }
8103                    }
8104    
8105                    return count.intValue();
8106            }
8107    
8108            /**
8109             * Counts all the wiki pages where nodeId = &#63; and head = &#63;.
8110             *
8111             * @param nodeId the node id to search with
8112             * @param head the head to search with
8113             * @return the number of matching wiki pages
8114             * @throws SystemException if a system exception occurred
8115             */
8116            public int countByN_H(long nodeId, boolean head) throws SystemException {
8117                    Object[] finderArgs = new Object[] { nodeId, head };
8118    
8119                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H,
8120                                    finderArgs, this);
8121    
8122                    if (count == null) {
8123                            Session session = null;
8124    
8125                            try {
8126                                    session = openSession();
8127    
8128                                    StringBundler query = new StringBundler(3);
8129    
8130                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8131    
8132                                    query.append(_FINDER_COLUMN_N_H_NODEID_2);
8133    
8134                                    query.append(_FINDER_COLUMN_N_H_HEAD_2);
8135    
8136                                    String sql = query.toString();
8137    
8138                                    Query q = session.createQuery(sql);
8139    
8140                                    QueryPos qPos = QueryPos.getInstance(q);
8141    
8142                                    qPos.add(nodeId);
8143    
8144                                    qPos.add(head);
8145    
8146                                    count = (Long)q.uniqueResult();
8147                            }
8148                            catch (Exception e) {
8149                                    throw processException(e);
8150                            }
8151                            finally {
8152                                    if (count == null) {
8153                                            count = Long.valueOf(0);
8154                                    }
8155    
8156                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H, finderArgs,
8157                                            count);
8158    
8159                                    closeSession(session);
8160                            }
8161                    }
8162    
8163                    return count.intValue();
8164            }
8165    
8166            /**
8167             * Counts all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
8168             *
8169             * @param nodeId the node id to search with
8170             * @param parentTitle the parent title to search with
8171             * @return the number of matching wiki pages
8172             * @throws SystemException if a system exception occurred
8173             */
8174            public int countByN_P(long nodeId, String parentTitle)
8175                    throws SystemException {
8176                    Object[] finderArgs = new Object[] { nodeId, parentTitle };
8177    
8178                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_P,
8179                                    finderArgs, this);
8180    
8181                    if (count == null) {
8182                            Session session = null;
8183    
8184                            try {
8185                                    session = openSession();
8186    
8187                                    StringBundler query = new StringBundler(3);
8188    
8189                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8190    
8191                                    query.append(_FINDER_COLUMN_N_P_NODEID_2);
8192    
8193                                    if (parentTitle == null) {
8194                                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
8195                                    }
8196                                    else {
8197                                            if (parentTitle.equals(StringPool.BLANK)) {
8198                                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
8199                                            }
8200                                            else {
8201                                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
8202                                            }
8203                                    }
8204    
8205                                    String sql = query.toString();
8206    
8207                                    Query q = session.createQuery(sql);
8208    
8209                                    QueryPos qPos = QueryPos.getInstance(q);
8210    
8211                                    qPos.add(nodeId);
8212    
8213                                    if (parentTitle != null) {
8214                                            qPos.add(parentTitle);
8215                                    }
8216    
8217                                    count = (Long)q.uniqueResult();
8218                            }
8219                            catch (Exception e) {
8220                                    throw processException(e);
8221                            }
8222                            finally {
8223                                    if (count == null) {
8224                                            count = Long.valueOf(0);
8225                                    }
8226    
8227                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_P, finderArgs,
8228                                            count);
8229    
8230                                    closeSession(session);
8231                            }
8232                    }
8233    
8234                    return count.intValue();
8235            }
8236    
8237            /**
8238             * Counts all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
8239             *
8240             * @param nodeId the node id to search with
8241             * @param redirectTitle the redirect title to search with
8242             * @return the number of matching wiki pages
8243             * @throws SystemException if a system exception occurred
8244             */
8245            public int countByN_R(long nodeId, String redirectTitle)
8246                    throws SystemException {
8247                    Object[] finderArgs = new Object[] { nodeId, redirectTitle };
8248    
8249                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_R,
8250                                    finderArgs, this);
8251    
8252                    if (count == null) {
8253                            Session session = null;
8254    
8255                            try {
8256                                    session = openSession();
8257    
8258                                    StringBundler query = new StringBundler(3);
8259    
8260                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8261    
8262                                    query.append(_FINDER_COLUMN_N_R_NODEID_2);
8263    
8264                                    if (redirectTitle == null) {
8265                                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
8266                                    }
8267                                    else {
8268                                            if (redirectTitle.equals(StringPool.BLANK)) {
8269                                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
8270                                            }
8271                                            else {
8272                                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
8273                                            }
8274                                    }
8275    
8276                                    String sql = query.toString();
8277    
8278                                    Query q = session.createQuery(sql);
8279    
8280                                    QueryPos qPos = QueryPos.getInstance(q);
8281    
8282                                    qPos.add(nodeId);
8283    
8284                                    if (redirectTitle != null) {
8285                                            qPos.add(redirectTitle);
8286                                    }
8287    
8288                                    count = (Long)q.uniqueResult();
8289                            }
8290                            catch (Exception e) {
8291                                    throw processException(e);
8292                            }
8293                            finally {
8294                                    if (count == null) {
8295                                            count = Long.valueOf(0);
8296                                    }
8297    
8298                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_R, finderArgs,
8299                                            count);
8300    
8301                                    closeSession(session);
8302                            }
8303                    }
8304    
8305                    return count.intValue();
8306            }
8307    
8308            /**
8309             * Counts all the wiki pages where nodeId = &#63; and status = &#63;.
8310             *
8311             * @param nodeId the node id to search with
8312             * @param status the status to search with
8313             * @return the number of matching wiki pages
8314             * @throws SystemException if a system exception occurred
8315             */
8316            public int countByN_S(long nodeId, int status) throws SystemException {
8317                    Object[] finderArgs = new Object[] { nodeId, status };
8318    
8319                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_S,
8320                                    finderArgs, this);
8321    
8322                    if (count == null) {
8323                            Session session = null;
8324    
8325                            try {
8326                                    session = openSession();
8327    
8328                                    StringBundler query = new StringBundler(3);
8329    
8330                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8331    
8332                                    query.append(_FINDER_COLUMN_N_S_NODEID_2);
8333    
8334                                    query.append(_FINDER_COLUMN_N_S_STATUS_2);
8335    
8336                                    String sql = query.toString();
8337    
8338                                    Query q = session.createQuery(sql);
8339    
8340                                    QueryPos qPos = QueryPos.getInstance(q);
8341    
8342                                    qPos.add(nodeId);
8343    
8344                                    qPos.add(status);
8345    
8346                                    count = (Long)q.uniqueResult();
8347                            }
8348                            catch (Exception e) {
8349                                    throw processException(e);
8350                            }
8351                            finally {
8352                                    if (count == null) {
8353                                            count = Long.valueOf(0);
8354                                    }
8355    
8356                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_S, finderArgs,
8357                                            count);
8358    
8359                                    closeSession(session);
8360                            }
8361                    }
8362    
8363                    return count.intValue();
8364            }
8365    
8366            /**
8367             * Counts all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63;.
8368             *
8369             * @param resourcePrimKey the resource prim key to search with
8370             * @param nodeId the node id to search with
8371             * @param version the version to search with
8372             * @return the number of matching wiki pages
8373             * @throws SystemException if a system exception occurred
8374             */
8375            public int countByR_N_V(long resourcePrimKey, long nodeId, double version)
8376                    throws SystemException {
8377                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, version };
8378    
8379                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_N_V,
8380                                    finderArgs, this);
8381    
8382                    if (count == null) {
8383                            Session session = null;
8384    
8385                            try {
8386                                    session = openSession();
8387    
8388                                    StringBundler query = new StringBundler(4);
8389    
8390                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8391    
8392                                    query.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
8393    
8394                                    query.append(_FINDER_COLUMN_R_N_V_NODEID_2);
8395    
8396                                    query.append(_FINDER_COLUMN_R_N_V_VERSION_2);
8397    
8398                                    String sql = query.toString();
8399    
8400                                    Query q = session.createQuery(sql);
8401    
8402                                    QueryPos qPos = QueryPos.getInstance(q);
8403    
8404                                    qPos.add(resourcePrimKey);
8405    
8406                                    qPos.add(nodeId);
8407    
8408                                    qPos.add(version);
8409    
8410                                    count = (Long)q.uniqueResult();
8411                            }
8412                            catch (Exception e) {
8413                                    throw processException(e);
8414                            }
8415                            finally {
8416                                    if (count == null) {
8417                                            count = Long.valueOf(0);
8418                                    }
8419    
8420                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_V,
8421                                            finderArgs, count);
8422    
8423                                    closeSession(session);
8424                            }
8425                    }
8426    
8427                    return count.intValue();
8428            }
8429    
8430            /**
8431             * Counts all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
8432             *
8433             * @param resourcePrimKey the resource prim key to search with
8434             * @param nodeId the node id to search with
8435             * @param status the status to search with
8436             * @return the number of matching wiki pages
8437             * @throws SystemException if a system exception occurred
8438             */
8439            public int countByR_N_S(long resourcePrimKey, long nodeId, int status)
8440                    throws SystemException {
8441                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, status };
8442    
8443                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_N_S,
8444                                    finderArgs, this);
8445    
8446                    if (count == null) {
8447                            Session session = null;
8448    
8449                            try {
8450                                    session = openSession();
8451    
8452                                    StringBundler query = new StringBundler(4);
8453    
8454                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8455    
8456                                    query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
8457    
8458                                    query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
8459    
8460                                    query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
8461    
8462                                    String sql = query.toString();
8463    
8464                                    Query q = session.createQuery(sql);
8465    
8466                                    QueryPos qPos = QueryPos.getInstance(q);
8467    
8468                                    qPos.add(resourcePrimKey);
8469    
8470                                    qPos.add(nodeId);
8471    
8472                                    qPos.add(status);
8473    
8474                                    count = (Long)q.uniqueResult();
8475                            }
8476                            catch (Exception e) {
8477                                    throw processException(e);
8478                            }
8479                            finally {
8480                                    if (count == null) {
8481                                            count = Long.valueOf(0);
8482                                    }
8483    
8484                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_S,
8485                                            finderArgs, count);
8486    
8487                                    closeSession(session);
8488                            }
8489                    }
8490    
8491                    return count.intValue();
8492            }
8493    
8494            /**
8495             * Counts all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
8496             *
8497             * @param userId the user id to search with
8498             * @param nodeId the node id to search with
8499             * @param status the status to search with
8500             * @return the number of matching wiki pages
8501             * @throws SystemException if a system exception occurred
8502             */
8503            public int countByU_N_S(long userId, long nodeId, int status)
8504                    throws SystemException {
8505                    Object[] finderArgs = new Object[] { userId, nodeId, status };
8506    
8507                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_N_S,
8508                                    finderArgs, this);
8509    
8510                    if (count == null) {
8511                            Session session = null;
8512    
8513                            try {
8514                                    session = openSession();
8515    
8516                                    StringBundler query = new StringBundler(4);
8517    
8518                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8519    
8520                                    query.append(_FINDER_COLUMN_U_N_S_USERID_2);
8521    
8522                                    query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
8523    
8524                                    query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
8525    
8526                                    String sql = query.toString();
8527    
8528                                    Query q = session.createQuery(sql);
8529    
8530                                    QueryPos qPos = QueryPos.getInstance(q);
8531    
8532                                    qPos.add(userId);
8533    
8534                                    qPos.add(nodeId);
8535    
8536                                    qPos.add(status);
8537    
8538                                    count = (Long)q.uniqueResult();
8539                            }
8540                            catch (Exception e) {
8541                                    throw processException(e);
8542                            }
8543                            finally {
8544                                    if (count == null) {
8545                                            count = Long.valueOf(0);
8546                                    }
8547    
8548                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_N_S,
8549                                            finderArgs, count);
8550    
8551                                    closeSession(session);
8552                            }
8553                    }
8554    
8555                    return count.intValue();
8556            }
8557    
8558            /**
8559             * Counts all the wiki pages where nodeId = &#63; and title = &#63; and version = &#63;.
8560             *
8561             * @param nodeId the node id to search with
8562             * @param title the title to search with
8563             * @param version the version to search with
8564             * @return the number of matching wiki pages
8565             * @throws SystemException if a system exception occurred
8566             */
8567            public int countByN_T_V(long nodeId, String title, double version)
8568                    throws SystemException {
8569                    Object[] finderArgs = new Object[] { nodeId, title, version };
8570    
8571                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_V,
8572                                    finderArgs, this);
8573    
8574                    if (count == null) {
8575                            Session session = null;
8576    
8577                            try {
8578                                    session = openSession();
8579    
8580                                    StringBundler query = new StringBundler(4);
8581    
8582                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8583    
8584                                    query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
8585    
8586                                    if (title == null) {
8587                                            query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
8588                                    }
8589                                    else {
8590                                            if (title.equals(StringPool.BLANK)) {
8591                                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
8592                                            }
8593                                            else {
8594                                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
8595                                            }
8596                                    }
8597    
8598                                    query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
8599    
8600                                    String sql = query.toString();
8601    
8602                                    Query q = session.createQuery(sql);
8603    
8604                                    QueryPos qPos = QueryPos.getInstance(q);
8605    
8606                                    qPos.add(nodeId);
8607    
8608                                    if (title != null) {
8609                                            qPos.add(title);
8610                                    }
8611    
8612                                    qPos.add(version);
8613    
8614                                    count = (Long)q.uniqueResult();
8615                            }
8616                            catch (Exception e) {
8617                                    throw processException(e);
8618                            }
8619                            finally {
8620                                    if (count == null) {
8621                                            count = Long.valueOf(0);
8622                                    }
8623    
8624                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V,
8625                                            finderArgs, count);
8626    
8627                                    closeSession(session);
8628                            }
8629                    }
8630    
8631                    return count.intValue();
8632            }
8633    
8634            /**
8635             * Counts all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
8636             *
8637             * @param nodeId the node id to search with
8638             * @param title the title to search with
8639             * @param head the head to search with
8640             * @return the number of matching wiki pages
8641             * @throws SystemException if a system exception occurred
8642             */
8643            public int countByN_T_H(long nodeId, String title, boolean head)
8644                    throws SystemException {
8645                    Object[] finderArgs = new Object[] { nodeId, title, head };
8646    
8647                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_H,
8648                                    finderArgs, this);
8649    
8650                    if (count == null) {
8651                            Session session = null;
8652    
8653                            try {
8654                                    session = openSession();
8655    
8656                                    StringBundler query = new StringBundler(4);
8657    
8658                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8659    
8660                                    query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
8661    
8662                                    if (title == null) {
8663                                            query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
8664                                    }
8665                                    else {
8666                                            if (title.equals(StringPool.BLANK)) {
8667                                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
8668                                            }
8669                                            else {
8670                                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
8671                                            }
8672                                    }
8673    
8674                                    query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
8675    
8676                                    String sql = query.toString();
8677    
8678                                    Query q = session.createQuery(sql);
8679    
8680                                    QueryPos qPos = QueryPos.getInstance(q);
8681    
8682                                    qPos.add(nodeId);
8683    
8684                                    if (title != null) {
8685                                            qPos.add(title);
8686                                    }
8687    
8688                                    qPos.add(head);
8689    
8690                                    count = (Long)q.uniqueResult();
8691                            }
8692                            catch (Exception e) {
8693                                    throw processException(e);
8694                            }
8695                            finally {
8696                                    if (count == null) {
8697                                            count = Long.valueOf(0);
8698                                    }
8699    
8700                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_H,
8701                                            finderArgs, count);
8702    
8703                                    closeSession(session);
8704                            }
8705                    }
8706    
8707                    return count.intValue();
8708            }
8709    
8710            /**
8711             * Counts all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
8712             *
8713             * @param nodeId the node id to search with
8714             * @param title the title to search with
8715             * @param status the status to search with
8716             * @return the number of matching wiki pages
8717             * @throws SystemException if a system exception occurred
8718             */
8719            public int countByN_T_S(long nodeId, String title, int status)
8720                    throws SystemException {
8721                    Object[] finderArgs = new Object[] { nodeId, title, status };
8722    
8723                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_S,
8724                                    finderArgs, this);
8725    
8726                    if (count == null) {
8727                            Session session = null;
8728    
8729                            try {
8730                                    session = openSession();
8731    
8732                                    StringBundler query = new StringBundler(4);
8733    
8734                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8735    
8736                                    query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
8737    
8738                                    if (title == null) {
8739                                            query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
8740                                    }
8741                                    else {
8742                                            if (title.equals(StringPool.BLANK)) {
8743                                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
8744                                            }
8745                                            else {
8746                                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
8747                                            }
8748                                    }
8749    
8750                                    query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
8751    
8752                                    String sql = query.toString();
8753    
8754                                    Query q = session.createQuery(sql);
8755    
8756                                    QueryPos qPos = QueryPos.getInstance(q);
8757    
8758                                    qPos.add(nodeId);
8759    
8760                                    if (title != null) {
8761                                            qPos.add(title);
8762                                    }
8763    
8764                                    qPos.add(status);
8765    
8766                                    count = (Long)q.uniqueResult();
8767                            }
8768                            catch (Exception e) {
8769                                    throw processException(e);
8770                            }
8771                            finally {
8772                                    if (count == null) {
8773                                            count = Long.valueOf(0);
8774                                    }
8775    
8776                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_S,
8777                                            finderArgs, count);
8778    
8779                                    closeSession(session);
8780                            }
8781                    }
8782    
8783                    return count.intValue();
8784            }
8785    
8786            /**
8787             * Counts all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
8788             *
8789             * @param nodeId the node id to search with
8790             * @param head the head to search with
8791             * @param parentTitle the parent title to search with
8792             * @return the number of matching wiki pages
8793             * @throws SystemException if a system exception occurred
8794             */
8795            public int countByN_H_P(long nodeId, boolean head, String parentTitle)
8796                    throws SystemException {
8797                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle };
8798    
8799                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H_P,
8800                                    finderArgs, this);
8801    
8802                    if (count == null) {
8803                            Session session = null;
8804    
8805                            try {
8806                                    session = openSession();
8807    
8808                                    StringBundler query = new StringBundler(4);
8809    
8810                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8811    
8812                                    query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
8813    
8814                                    query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
8815    
8816                                    if (parentTitle == null) {
8817                                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
8818                                    }
8819                                    else {
8820                                            if (parentTitle.equals(StringPool.BLANK)) {
8821                                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
8822                                            }
8823                                            else {
8824                                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
8825                                            }
8826                                    }
8827    
8828                                    String sql = query.toString();
8829    
8830                                    Query q = session.createQuery(sql);
8831    
8832                                    QueryPos qPos = QueryPos.getInstance(q);
8833    
8834                                    qPos.add(nodeId);
8835    
8836                                    qPos.add(head);
8837    
8838                                    if (parentTitle != null) {
8839                                            qPos.add(parentTitle);
8840                                    }
8841    
8842                                    count = (Long)q.uniqueResult();
8843                            }
8844                            catch (Exception e) {
8845                                    throw processException(e);
8846                            }
8847                            finally {
8848                                    if (count == null) {
8849                                            count = Long.valueOf(0);
8850                                    }
8851    
8852                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H_P,
8853                                            finderArgs, count);
8854    
8855                                    closeSession(session);
8856                            }
8857                    }
8858    
8859                    return count.intValue();
8860            }
8861    
8862            /**
8863             * Counts all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
8864             *
8865             * @param nodeId the node id to search with
8866             * @param head the head to search with
8867             * @param status the status to search with
8868             * @return the number of matching wiki pages
8869             * @throws SystemException if a system exception occurred
8870             */
8871            public int countByN_H_S(long nodeId, boolean head, int status)
8872                    throws SystemException {
8873                    Object[] finderArgs = new Object[] { nodeId, head, status };
8874    
8875                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H_S,
8876                                    finderArgs, this);
8877    
8878                    if (count == null) {
8879                            Session session = null;
8880    
8881                            try {
8882                                    session = openSession();
8883    
8884                                    StringBundler query = new StringBundler(4);
8885    
8886                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8887    
8888                                    query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
8889    
8890                                    query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
8891    
8892                                    query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
8893    
8894                                    String sql = query.toString();
8895    
8896                                    Query q = session.createQuery(sql);
8897    
8898                                    QueryPos qPos = QueryPos.getInstance(q);
8899    
8900                                    qPos.add(nodeId);
8901    
8902                                    qPos.add(head);
8903    
8904                                    qPos.add(status);
8905    
8906                                    count = (Long)q.uniqueResult();
8907                            }
8908                            catch (Exception e) {
8909                                    throw processException(e);
8910                            }
8911                            finally {
8912                                    if (count == null) {
8913                                            count = Long.valueOf(0);
8914                                    }
8915    
8916                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H_S,
8917                                            finderArgs, count);
8918    
8919                                    closeSession(session);
8920                            }
8921                    }
8922    
8923                    return count.intValue();
8924            }
8925    
8926            /**
8927             * Counts all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
8928             *
8929             * @param nodeId the node id to search with
8930             * @param head the head to search with
8931             * @param parentTitle the parent title to search with
8932             * @param status the status to search with
8933             * @return the number of matching wiki pages
8934             * @throws SystemException if a system exception occurred
8935             */
8936            public int countByN_H_P_S(long nodeId, boolean head, String parentTitle,
8937                    int status) throws SystemException {
8938                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle, status };
8939    
8940                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H_P_S,
8941                                    finderArgs, this);
8942    
8943                    if (count == null) {
8944                            Session session = null;
8945    
8946                            try {
8947                                    session = openSession();
8948    
8949                                    StringBundler query = new StringBundler(5);
8950    
8951                                    query.append(_SQL_COUNT_WIKIPAGE_WHERE);
8952    
8953                                    query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
8954    
8955                                    query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
8956    
8957                                    if (parentTitle == null) {
8958                                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
8959                                    }
8960                                    else {
8961                                            if (parentTitle.equals(StringPool.BLANK)) {
8962                                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
8963                                            }
8964                                            else {
8965                                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
8966                                            }
8967                                    }
8968    
8969                                    query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
8970    
8971                                    String sql = query.toString();
8972    
8973                                    Query q = session.createQuery(sql);
8974    
8975                                    QueryPos qPos = QueryPos.getInstance(q);
8976    
8977                                    qPos.add(nodeId);
8978    
8979                                    qPos.add(head);
8980    
8981                                    if (parentTitle != null) {
8982                                            qPos.add(parentTitle);
8983                                    }
8984    
8985                                    qPos.add(status);
8986    
8987                                    count = (Long)q.uniqueResult();
8988                            }
8989                            catch (Exception e) {
8990                                    throw processException(e);
8991                            }
8992                            finally {
8993                                    if (count == null) {
8994                                            count = Long.valueOf(0);
8995                                    }
8996    
8997                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H_P_S,
8998                                            finderArgs, count);
8999    
9000                                    closeSession(session);
9001                            }
9002                    }
9003    
9004                    return count.intValue();
9005            }
9006    
9007            /**
9008             * Counts all the wiki pages.
9009             *
9010             * @return the number of wiki pages
9011             * @throws SystemException if a system exception occurred
9012             */
9013            public int countAll() throws SystemException {
9014                    Object[] finderArgs = new Object[0];
9015    
9016                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
9017                                    finderArgs, this);
9018    
9019                    if (count == null) {
9020                            Session session = null;
9021    
9022                            try {
9023                                    session = openSession();
9024    
9025                                    Query q = session.createQuery(_SQL_COUNT_WIKIPAGE);
9026    
9027                                    count = (Long)q.uniqueResult();
9028                            }
9029                            catch (Exception e) {
9030                                    throw processException(e);
9031                            }
9032                            finally {
9033                                    if (count == null) {
9034                                            count = Long.valueOf(0);
9035                                    }
9036    
9037                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
9038                                            count);
9039    
9040                                    closeSession(session);
9041                            }
9042                    }
9043    
9044                    return count.intValue();
9045            }
9046    
9047            /**
9048             * Initializes the wiki page persistence.
9049             */
9050            public void afterPropertiesSet() {
9051                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
9052                                            com.liferay.portal.util.PropsUtil.get(
9053                                                    "value.object.listener.com.liferay.portlet.wiki.model.WikiPage")));
9054    
9055                    if (listenerClassNames.length > 0) {
9056                            try {
9057                                    List<ModelListener<WikiPage>> listenersList = new ArrayList<ModelListener<WikiPage>>();
9058    
9059                                    for (String listenerClassName : listenerClassNames) {
9060                                            listenersList.add((ModelListener<WikiPage>)InstanceFactory.newInstance(
9061                                                            listenerClassName));
9062                                    }
9063    
9064                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
9065                            }
9066                            catch (Exception e) {
9067                                    _log.error(e);
9068                            }
9069                    }
9070            }
9071    
9072            @BeanReference(type = WikiNodePersistence.class)
9073            protected WikiNodePersistence wikiNodePersistence;
9074            @BeanReference(type = WikiPagePersistence.class)
9075            protected WikiPagePersistence wikiPagePersistence;
9076            @BeanReference(type = WikiPageResourcePersistence.class)
9077            protected WikiPageResourcePersistence wikiPageResourcePersistence;
9078            @BeanReference(type = CompanyPersistence.class)
9079            protected CompanyPersistence companyPersistence;
9080            @BeanReference(type = GroupPersistence.class)
9081            protected GroupPersistence groupPersistence;
9082            @BeanReference(type = PortletPreferencesPersistence.class)
9083            protected PortletPreferencesPersistence portletPreferencesPersistence;
9084            @BeanReference(type = ResourcePersistence.class)
9085            protected ResourcePersistence resourcePersistence;
9086            @BeanReference(type = SubscriptionPersistence.class)
9087            protected SubscriptionPersistence subscriptionPersistence;
9088            @BeanReference(type = UserPersistence.class)
9089            protected UserPersistence userPersistence;
9090            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
9091            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
9092            @BeanReference(type = AssetCategoryPersistence.class)
9093            protected AssetCategoryPersistence assetCategoryPersistence;
9094            @BeanReference(type = AssetEntryPersistence.class)
9095            protected AssetEntryPersistence assetEntryPersistence;
9096            @BeanReference(type = AssetTagPersistence.class)
9097            protected AssetTagPersistence assetTagPersistence;
9098            @BeanReference(type = ExpandoValuePersistence.class)
9099            protected ExpandoValuePersistence expandoValuePersistence;
9100            @BeanReference(type = MBMessagePersistence.class)
9101            protected MBMessagePersistence mbMessagePersistence;
9102            @BeanReference(type = SocialActivityPersistence.class)
9103            protected SocialActivityPersistence socialActivityPersistence;
9104            @BeanReference(type = SocialEquityLogPersistence.class)
9105            protected SocialEquityLogPersistence socialEquityLogPersistence;
9106            private static final String _SQL_SELECT_WIKIPAGE = "SELECT wikiPage FROM WikiPage wikiPage";
9107            private static final String _SQL_SELECT_WIKIPAGE_WHERE = "SELECT wikiPage FROM WikiPage wikiPage WHERE ";
9108            private static final String _SQL_COUNT_WIKIPAGE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage";
9109            private static final String _SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage WHERE ";
9110            private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiPage.uuid IS NULL";
9111            private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiPage.uuid = ?";
9112            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = ?)";
9113            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiPage.uuid IS NULL AND ";
9114            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiPage.uuid = ? AND ";
9115            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = ?) AND ";
9116            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiPage.groupId = ?";
9117            private static final String _FINDER_COLUMN_NODEID_NODEID_2 = "wikiPage.nodeId = ?";
9118            private static final String _FINDER_COLUMN_FORMAT_FORMAT_1 = "wikiPage.format IS NULL";
9119            private static final String _FINDER_COLUMN_FORMAT_FORMAT_2 = "wikiPage.format = ?";
9120            private static final String _FINDER_COLUMN_FORMAT_FORMAT_3 = "(wikiPage.format IS NULL OR wikiPage.format = ?)";
9121            private static final String _FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
9122            private static final String _FINDER_COLUMN_R_N_NODEID_2 = "wikiPage.nodeId = ?";
9123            private static final String _FINDER_COLUMN_N_T_NODEID_2 = "wikiPage.nodeId = ? AND ";
9124            private static final String _FINDER_COLUMN_N_T_TITLE_1 = "wikiPage.title IS NULL";
9125            private static final String _FINDER_COLUMN_N_T_TITLE_2 = "lower(wikiPage.title) = lower(?)";
9126            private static final String _FINDER_COLUMN_N_T_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(?))";
9127            private static final String _FINDER_COLUMN_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
9128            private static final String _FINDER_COLUMN_N_H_HEAD_2 = "wikiPage.head = ?";
9129            private static final String _FINDER_COLUMN_N_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
9130            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
9131            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = lower(?)";
9132            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR lower(wikiPage.parentTitle) = lower(?))";
9133            private static final String _FINDER_COLUMN_N_R_NODEID_2 = "wikiPage.nodeId = ? AND ";
9134            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL";
9135            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_2 = "lower(wikiPage.redirectTitle) = lower(?)";
9136            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR lower(wikiPage.redirectTitle) = lower(?))";
9137            private static final String _FINDER_COLUMN_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
9138            private static final String _FINDER_COLUMN_N_S_STATUS_2 = "wikiPage.status = ?";
9139            private static final String _FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
9140            private static final String _FINDER_COLUMN_R_N_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
9141            private static final String _FINDER_COLUMN_R_N_V_VERSION_2 = "wikiPage.version = ?";
9142            private static final String _FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
9143            private static final String _FINDER_COLUMN_R_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
9144            private static final String _FINDER_COLUMN_R_N_S_STATUS_2 = "wikiPage.status = ?";
9145            private static final String _FINDER_COLUMN_U_N_S_USERID_2 = "wikiPage.userId = ? AND ";
9146            private static final String _FINDER_COLUMN_U_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
9147            private static final String _FINDER_COLUMN_U_N_S_STATUS_2 = "wikiPage.status = ?";
9148            private static final String _FINDER_COLUMN_N_T_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
9149            private static final String _FINDER_COLUMN_N_T_V_TITLE_1 = "wikiPage.title IS NULL AND ";
9150            private static final String _FINDER_COLUMN_N_T_V_TITLE_2 = "lower(wikiPage.title) = lower(?) AND ";
9151            private static final String _FINDER_COLUMN_N_T_V_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(?)) AND ";
9152            private static final String _FINDER_COLUMN_N_T_V_VERSION_2 = "wikiPage.version = ?";
9153            private static final String _FINDER_COLUMN_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
9154            private static final String _FINDER_COLUMN_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
9155            private static final String _FINDER_COLUMN_N_T_H_TITLE_2 = "lower(wikiPage.title) = lower(?) AND ";
9156            private static final String _FINDER_COLUMN_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(?)) AND ";
9157            private static final String _FINDER_COLUMN_N_T_H_HEAD_2 = "wikiPage.head = ?";
9158            private static final String _FINDER_COLUMN_N_T_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
9159            private static final String _FINDER_COLUMN_N_T_S_TITLE_1 = "wikiPage.title IS NULL AND ";
9160            private static final String _FINDER_COLUMN_N_T_S_TITLE_2 = "lower(wikiPage.title) = lower(?) AND ";
9161            private static final String _FINDER_COLUMN_N_T_S_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(?)) AND ";
9162            private static final String _FINDER_COLUMN_N_T_S_STATUS_2 = "wikiPage.status = ?";
9163            private static final String _FINDER_COLUMN_N_H_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
9164            private static final String _FINDER_COLUMN_N_H_P_HEAD_2 = "wikiPage.head = ? AND ";
9165            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
9166            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = lower(?)";
9167            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR lower(wikiPage.parentTitle) = lower(?))";
9168            private static final String _FINDER_COLUMN_N_H_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
9169            private static final String _FINDER_COLUMN_N_H_S_HEAD_2 = "wikiPage.head = ? AND ";
9170            private static final String _FINDER_COLUMN_N_H_S_STATUS_2 = "wikiPage.status = ?";
9171            private static final String _FINDER_COLUMN_N_H_P_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
9172            private static final String _FINDER_COLUMN_N_H_P_S_HEAD_2 = "wikiPage.head = ? AND ";
9173            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL AND ";
9174            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = lower(?) AND ";
9175            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR lower(wikiPage.parentTitle) = lower(?)) AND ";
9176            private static final String _FINDER_COLUMN_N_H_P_S_STATUS_2 = "wikiPage.status = ?";
9177            private static final String _ORDER_BY_ENTITY_ALIAS = "wikiPage.";
9178            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiPage exists with the primary key ";
9179            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiPage exists with the key {";
9180            private static Log _log = LogFactoryUtil.getLog(WikiPagePersistenceImpl.class);
9181    }