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