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