001    /**
002     * Copyright (c) 2000-2013 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.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.sanitizer.Sanitizer;
032    import com.liferay.portal.kernel.sanitizer.SanitizerException;
033    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
034    import com.liferay.portal.kernel.util.ContentTypes;
035    import com.liferay.portal.kernel.util.GetterUtil;
036    import com.liferay.portal.kernel.util.InstanceFactory;
037    import com.liferay.portal.kernel.util.OrderByComparator;
038    import com.liferay.portal.kernel.util.StringBundler;
039    import com.liferay.portal.kernel.util.StringPool;
040    import com.liferay.portal.kernel.util.StringUtil;
041    import com.liferay.portal.kernel.util.Validator;
042    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
043    import com.liferay.portal.model.CacheModel;
044    import com.liferay.portal.model.ModelListener;
045    import com.liferay.portal.security.auth.PrincipalThreadLocal;
046    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047    import com.liferay.portal.service.persistence.BatchSessionUtil;
048    import com.liferay.portal.service.persistence.CompanyPersistence;
049    import com.liferay.portal.service.persistence.GroupPersistence;
050    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
051    import com.liferay.portal.service.persistence.ResourcePersistence;
052    import com.liferay.portal.service.persistence.SubscriptionPersistence;
053    import com.liferay.portal.service.persistence.UserPersistence;
054    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
055    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
056    
057    import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
058    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
059    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
060    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
061    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
062    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
063    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
064    import com.liferay.portlet.wiki.NoSuchPageException;
065    import com.liferay.portlet.wiki.model.WikiPage;
066    import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
067    import com.liferay.portlet.wiki.model.impl.WikiPageModelImpl;
068    
069    import java.io.Serializable;
070    
071    import java.util.ArrayList;
072    import java.util.Collections;
073    import java.util.List;
074    
075    /**
076     * The persistence implementation for the wiki page service.
077     *
078     * <p>
079     * Caching information and settings can be found in <code>portal.properties</code>
080     * </p>
081     *
082     * @author Brian Wing Shun Chan
083     * @see WikiPagePersistence
084     * @see WikiPageUtil
085     * @generated
086     */
087    public class WikiPagePersistenceImpl extends BasePersistenceImpl<WikiPage>
088            implements WikiPagePersistence {
089            /*
090             * NOTE FOR DEVELOPERS:
091             *
092             * 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.
093             */
094            public static final String FINDER_CLASS_NAME_ENTITY = WikiPageImpl.class.getName();
095            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
096                    ".List1";
097            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
098                    ".List2";
099            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
100                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
102                            new String[] {
103                                    String.class.getName(),
104                                    
105                            "java.lang.Integer", "java.lang.Integer",
106                                    "com.liferay.portal.kernel.util.OrderByComparator"
107                            });
108            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
109                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
111                            new String[] { String.class.getName() },
112                            WikiPageModelImpl.UUID_COLUMN_BITMASK);
113            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
114                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
116                            new String[] { String.class.getName() });
117            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
118                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
119                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
120                            new String[] { String.class.getName(), Long.class.getName() },
121                            WikiPageModelImpl.UUID_COLUMN_BITMASK |
122                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK);
123            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
124                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
125                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
126                            new String[] { String.class.getName(), Long.class.getName() });
127            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
128                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
129                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNodeId",
130                            new String[] {
131                                    Long.class.getName(),
132                                    
133                            "java.lang.Integer", "java.lang.Integer",
134                                    "com.liferay.portal.kernel.util.OrderByComparator"
135                            });
136            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID =
137                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
138                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
139                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByNodeId",
140                            new String[] { Long.class.getName() },
141                            WikiPageModelImpl.NODEID_COLUMN_BITMASK);
142            public static final FinderPath FINDER_PATH_COUNT_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
143                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
144                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByNodeId",
145                            new String[] { Long.class.getName() });
146            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
147                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
148                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFormat",
149                            new String[] {
150                                    String.class.getName(),
151                                    
152                            "java.lang.Integer", "java.lang.Integer",
153                                    "com.liferay.portal.kernel.util.OrderByComparator"
154                            });
155            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT =
156                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
157                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
158                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFormat",
159                            new String[] { String.class.getName() },
160                            WikiPageModelImpl.FORMAT_COLUMN_BITMASK);
161            public static final FinderPath FINDER_PATH_COUNT_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
162                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFormat",
164                            new String[] { String.class.getName() });
165            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
166                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
167                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_N",
168                            new String[] {
169                                    Long.class.getName(), Long.class.getName(),
170                                    
171                            "java.lang.Integer", "java.lang.Integer",
172                                    "com.liferay.portal.kernel.util.OrderByComparator"
173                            });
174            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
175                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
176                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_N",
177                            new String[] { Long.class.getName(), Long.class.getName() },
178                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
179                            WikiPageModelImpl.NODEID_COLUMN_BITMASK);
180            public static final FinderPath FINDER_PATH_COUNT_BY_R_N = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
181                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
182                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N",
183                            new String[] { Long.class.getName(), Long.class.getName() });
184            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
185                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
186                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T",
187                            new String[] {
188                                    Long.class.getName(), String.class.getName(),
189                                    
190                            "java.lang.Integer", "java.lang.Integer",
191                                    "com.liferay.portal.kernel.util.OrderByComparator"
192                            });
193            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
194                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
195                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T",
196                            new String[] { Long.class.getName(), String.class.getName() },
197                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
198                            WikiPageModelImpl.TITLE_COLUMN_BITMASK);
199            public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
200                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
201                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T",
202                            new String[] { Long.class.getName(), String.class.getName() });
203            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
204                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
205                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H",
206                            new String[] {
207                                    Long.class.getName(), Boolean.class.getName(),
208                                    
209                            "java.lang.Integer", "java.lang.Integer",
210                                    "com.liferay.portal.kernel.util.OrderByComparator"
211                            });
212            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
213                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
214                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H",
215                            new String[] { Long.class.getName(), Boolean.class.getName() },
216                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
217                            WikiPageModelImpl.HEAD_COLUMN_BITMASK);
218            public static final FinderPath FINDER_PATH_COUNT_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
219                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
220                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H",
221                            new String[] { Long.class.getName(), Boolean.class.getName() });
222            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
223                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
224                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_P",
225                            new String[] {
226                                    Long.class.getName(), String.class.getName(),
227                                    
228                            "java.lang.Integer", "java.lang.Integer",
229                                    "com.liferay.portal.kernel.util.OrderByComparator"
230                            });
231            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
232                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
233                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_P",
234                            new String[] { Long.class.getName(), String.class.getName() },
235                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
236                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK);
237            public static final FinderPath FINDER_PATH_COUNT_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
238                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
239                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_P",
240                            new String[] { Long.class.getName(), String.class.getName() });
241            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
242                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
243                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_R",
244                            new String[] {
245                                    Long.class.getName(), String.class.getName(),
246                                    
247                            "java.lang.Integer", "java.lang.Integer",
248                                    "com.liferay.portal.kernel.util.OrderByComparator"
249                            });
250            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
251                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
252                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_R",
253                            new String[] { Long.class.getName(), String.class.getName() },
254                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
255                            WikiPageModelImpl.REDIRECTTITLE_COLUMN_BITMASK);
256            public static final FinderPath FINDER_PATH_COUNT_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
257                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
258                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_R",
259                            new String[] { Long.class.getName(), String.class.getName() });
260            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
261                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
262                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_S",
263                            new String[] {
264                                    Long.class.getName(), Integer.class.getName(),
265                                    
266                            "java.lang.Integer", "java.lang.Integer",
267                                    "com.liferay.portal.kernel.util.OrderByComparator"
268                            });
269            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
270                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
271                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_S",
272                            new String[] { Long.class.getName(), Integer.class.getName() },
273                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
274                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
275            public static final FinderPath FINDER_PATH_COUNT_BY_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
276                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
277                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_S",
278                            new String[] { Long.class.getName(), Integer.class.getName() });
279            public static final FinderPath FINDER_PATH_FETCH_BY_R_N_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
280                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
281                            FINDER_CLASS_NAME_ENTITY, "fetchByR_N_V",
282                            new String[] {
283                                    Long.class.getName(), Long.class.getName(),
284                                    Double.class.getName()
285                            },
286                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
287                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
288                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
289            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
290                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
291                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N_V",
292                            new String[] {
293                                    Long.class.getName(), Long.class.getName(),
294                                    Double.class.getName()
295                            });
296            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
297                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
298                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_N_S",
299                            new String[] {
300                                    Long.class.getName(), Long.class.getName(),
301                                    Integer.class.getName(),
302                                    
303                            "java.lang.Integer", "java.lang.Integer",
304                                    "com.liferay.portal.kernel.util.OrderByComparator"
305                            });
306            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
307                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
308                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_N_S",
309                            new String[] {
310                                    Long.class.getName(), Long.class.getName(),
311                                    Integer.class.getName()
312                            },
313                            WikiPageModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
314                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
315                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
316            public static final FinderPath FINDER_PATH_COUNT_BY_R_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
317                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
318                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_N_S",
319                            new String[] {
320                                    Long.class.getName(), Long.class.getName(),
321                                    Integer.class.getName()
322                            });
323            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
324                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
325                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H",
326                            new String[] {
327                                    Long.class.getName(), Long.class.getName(),
328                                    Boolean.class.getName(),
329                                    
330                            "java.lang.Integer", "java.lang.Integer",
331                                    "com.liferay.portal.kernel.util.OrderByComparator"
332                            });
333            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
334                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
335                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H",
336                            new String[] {
337                                    Long.class.getName(), Long.class.getName(),
338                                    Boolean.class.getName()
339                            },
340                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
341                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
342                            WikiPageModelImpl.HEAD_COLUMN_BITMASK);
343            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
344                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
345                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H",
346                            new String[] {
347                                    Long.class.getName(), Long.class.getName(),
348                                    Boolean.class.getName()
349                            });
350            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
351                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
352                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_S",
353                            new String[] {
354                                    Long.class.getName(), Long.class.getName(),
355                                    Integer.class.getName(),
356                                    
357                            "java.lang.Integer", "java.lang.Integer",
358                                    "com.liferay.portal.kernel.util.OrderByComparator"
359                            });
360            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
361                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
362                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_S",
363                            new String[] {
364                                    Long.class.getName(), Long.class.getName(),
365                                    Integer.class.getName()
366                            },
367                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
368                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
369                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
370            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
371                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
372                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_S",
373                            new String[] {
374                                    Long.class.getName(), Long.class.getName(),
375                                    Integer.class.getName()
376                            });
377            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
378                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
379                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_N_S",
380                            new String[] {
381                                    Long.class.getName(), Long.class.getName(),
382                                    Integer.class.getName(),
383                                    
384                            "java.lang.Integer", "java.lang.Integer",
385                                    "com.liferay.portal.kernel.util.OrderByComparator"
386                            });
387            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
388                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
389                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_N_S",
390                            new String[] {
391                                    Long.class.getName(), Long.class.getName(),
392                                    Integer.class.getName()
393                            },
394                            WikiPageModelImpl.USERID_COLUMN_BITMASK |
395                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
396                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
397            public static final FinderPath FINDER_PATH_COUNT_BY_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
398                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
399                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_N_S",
400                            new String[] {
401                                    Long.class.getName(), Long.class.getName(),
402                                    Integer.class.getName()
403                            });
404            public static final FinderPath FINDER_PATH_FETCH_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
405                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
406                            FINDER_CLASS_NAME_ENTITY, "fetchByN_T_V",
407                            new String[] {
408                                    Long.class.getName(), String.class.getName(),
409                                    Double.class.getName()
410                            },
411                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
412                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
413                            WikiPageModelImpl.VERSION_COLUMN_BITMASK);
414            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
415                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
416                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_V",
417                            new String[] {
418                                    Long.class.getName(), String.class.getName(),
419                                    Double.class.getName()
420                            });
421            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
422                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
423                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T_H",
424                            new String[] {
425                                    Long.class.getName(), String.class.getName(),
426                                    Boolean.class.getName(),
427                                    
428                            "java.lang.Integer", "java.lang.Integer",
429                                    "com.liferay.portal.kernel.util.OrderByComparator"
430                            });
431            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
432                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
433                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T_H",
434                            new String[] {
435                                    Long.class.getName(), String.class.getName(),
436                                    Boolean.class.getName()
437                            },
438                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
439                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
440                            WikiPageModelImpl.HEAD_COLUMN_BITMASK);
441            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
442                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
443                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_H",
444                            new String[] {
445                                    Long.class.getName(), String.class.getName(),
446                                    Boolean.class.getName()
447                            });
448            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
449                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
450                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_T_S",
451                            new String[] {
452                                    Long.class.getName(), String.class.getName(),
453                                    Integer.class.getName(),
454                                    
455                            "java.lang.Integer", "java.lang.Integer",
456                                    "com.liferay.portal.kernel.util.OrderByComparator"
457                            });
458            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
459                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
460                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_T_S",
461                            new String[] {
462                                    Long.class.getName(), String.class.getName(),
463                                    Integer.class.getName()
464                            },
465                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
466                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
467                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
468            public static final FinderPath FINDER_PATH_COUNT_BY_N_T_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
469                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
470                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_T_S",
471                            new String[] {
472                                    Long.class.getName(), String.class.getName(),
473                                    Integer.class.getName()
474                            });
475            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
476                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
477                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_P",
478                            new String[] {
479                                    Long.class.getName(), Boolean.class.getName(),
480                                    String.class.getName(),
481                                    
482                            "java.lang.Integer", "java.lang.Integer",
483                                    "com.liferay.portal.kernel.util.OrderByComparator"
484                            });
485            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
486                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
487                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_P",
488                            new String[] {
489                                    Long.class.getName(), Boolean.class.getName(),
490                                    String.class.getName()
491                            },
492                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
493                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
494                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK);
495            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
496                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
497                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_P",
498                            new String[] {
499                                    Long.class.getName(), Boolean.class.getName(),
500                                    String.class.getName()
501                            });
502            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
503                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
504                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_S",
505                            new String[] {
506                                    Long.class.getName(), Boolean.class.getName(),
507                                    Integer.class.getName(),
508                                    
509                            "java.lang.Integer", "java.lang.Integer",
510                                    "com.liferay.portal.kernel.util.OrderByComparator"
511                            });
512            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
513                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
514                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_S",
515                            new String[] {
516                                    Long.class.getName(), Boolean.class.getName(),
517                                    Integer.class.getName()
518                            },
519                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
520                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
521                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
522            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
523                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
524                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_S",
525                            new String[] {
526                                    Long.class.getName(), Boolean.class.getName(),
527                                    Integer.class.getName()
528                            });
529            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
530                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
531                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_N_S",
532                            new String[] {
533                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
534                                    Integer.class.getName(),
535                                    
536                            "java.lang.Integer", "java.lang.Integer",
537                                    "com.liferay.portal.kernel.util.OrderByComparator"
538                            });
539            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S =
540                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
541                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
542                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_N_S",
543                            new String[] {
544                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
545                                    Integer.class.getName()
546                            },
547                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
548                            WikiPageModelImpl.USERID_COLUMN_BITMASK |
549                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
550                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
551            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_N_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
552                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
553                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_N_S",
554                            new String[] {
555                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
556                                    Integer.class.getName()
557                            });
558            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
559                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
560                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_T_H",
561                            new String[] {
562                                    Long.class.getName(), Long.class.getName(),
563                                    String.class.getName(), Boolean.class.getName(),
564                                    
565                            "java.lang.Integer", "java.lang.Integer",
566                                    "com.liferay.portal.kernel.util.OrderByComparator"
567                            });
568            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H =
569                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
570                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
571                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_T_H",
572                            new String[] {
573                                    Long.class.getName(), Long.class.getName(),
574                                    String.class.getName(), Boolean.class.getName()
575                            },
576                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
577                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
578                            WikiPageModelImpl.TITLE_COLUMN_BITMASK |
579                            WikiPageModelImpl.HEAD_COLUMN_BITMASK);
580            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
581                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
582                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_T_H",
583                            new String[] {
584                                    Long.class.getName(), Long.class.getName(),
585                                    String.class.getName(), Boolean.class.getName()
586                            });
587            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
588                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
589                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H_S",
590                            new String[] {
591                                    Long.class.getName(), Long.class.getName(),
592                                    Boolean.class.getName(), Integer.class.getName(),
593                                    
594                            "java.lang.Integer", "java.lang.Integer",
595                                    "com.liferay.portal.kernel.util.OrderByComparator"
596                            });
597            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S =
598                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
599                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
600                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H_S",
601                            new String[] {
602                                    Long.class.getName(), Long.class.getName(),
603                                    Boolean.class.getName(), Integer.class.getName()
604                            },
605                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
606                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
607                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
608                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
609            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
610                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
611                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H_S",
612                            new String[] {
613                                    Long.class.getName(), Long.class.getName(),
614                                    Boolean.class.getName(), Integer.class.getName()
615                            });
616            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
617                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
618                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_H_P_S",
619                            new String[] {
620                                    Long.class.getName(), Boolean.class.getName(),
621                                    String.class.getName(), Integer.class.getName(),
622                                    
623                            "java.lang.Integer", "java.lang.Integer",
624                                    "com.liferay.portal.kernel.util.OrderByComparator"
625                            });
626            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S =
627                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
628                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
629                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_H_P_S",
630                            new String[] {
631                                    Long.class.getName(), Boolean.class.getName(),
632                                    String.class.getName(), Integer.class.getName()
633                            },
634                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
635                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
636                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
637                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
638            public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
639                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
640                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_H_P_S",
641                            new String[] {
642                                    Long.class.getName(), Boolean.class.getName(),
643                                    String.class.getName(), Integer.class.getName()
644                            });
645            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_P_S =
646                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
647                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
648                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_H_P_S",
649                            new String[] {
650                                    Long.class.getName(), Long.class.getName(),
651                                    Boolean.class.getName(), String.class.getName(),
652                                    Integer.class.getName(),
653                                    
654                            "java.lang.Integer", "java.lang.Integer",
655                                    "com.liferay.portal.kernel.util.OrderByComparator"
656                            });
657            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S =
658                    new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
659                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
660                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_H_P_S",
661                            new String[] {
662                                    Long.class.getName(), Long.class.getName(),
663                                    Boolean.class.getName(), String.class.getName(),
664                                    Integer.class.getName()
665                            },
666                            WikiPageModelImpl.GROUPID_COLUMN_BITMASK |
667                            WikiPageModelImpl.NODEID_COLUMN_BITMASK |
668                            WikiPageModelImpl.HEAD_COLUMN_BITMASK |
669                            WikiPageModelImpl.PARENTTITLE_COLUMN_BITMASK |
670                            WikiPageModelImpl.STATUS_COLUMN_BITMASK);
671            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_H_P_S = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
672                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
673                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_H_P_S",
674                            new String[] {
675                                    Long.class.getName(), Long.class.getName(),
676                                    Boolean.class.getName(), String.class.getName(),
677                                    Integer.class.getName()
678                            });
679            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
680                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
681                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
682            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
683                            WikiPageModelImpl.FINDER_CACHE_ENABLED, WikiPageImpl.class,
684                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
685            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
686                            WikiPageModelImpl.FINDER_CACHE_ENABLED, Long.class,
687                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
688    
689            /**
690             * Caches the wiki page in the entity cache if it is enabled.
691             *
692             * @param wikiPage the wiki page
693             */
694            public void cacheResult(WikiPage wikiPage) {
695                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
696                            WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
697    
698                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
699                            new Object[] { wikiPage.getUuid(), Long.valueOf(
700                                            wikiPage.getGroupId()) }, wikiPage);
701    
702                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
703                            new Object[] {
704                                    Long.valueOf(wikiPage.getResourcePrimKey()),
705                                    Long.valueOf(wikiPage.getNodeId()),
706                                    Double.valueOf(wikiPage.getVersion())
707                            }, wikiPage);
708    
709                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
710                            new Object[] {
711                                    Long.valueOf(wikiPage.getNodeId()),
712                                    
713                            wikiPage.getTitle(), Double.valueOf(wikiPage.getVersion())
714                            }, wikiPage);
715    
716                    wikiPage.resetOriginalValues();
717            }
718    
719            /**
720             * Caches the wiki pages in the entity cache if it is enabled.
721             *
722             * @param wikiPages the wiki pages
723             */
724            public void cacheResult(List<WikiPage> wikiPages) {
725                    for (WikiPage wikiPage : wikiPages) {
726                            if (EntityCacheUtil.getResult(
727                                                    WikiPageModelImpl.ENTITY_CACHE_ENABLED,
728                                                    WikiPageImpl.class, wikiPage.getPrimaryKey()) == null) {
729                                    cacheResult(wikiPage);
730                            }
731                            else {
732                                    wikiPage.resetOriginalValues();
733                            }
734                    }
735            }
736    
737            /**
738             * Clears the cache for all wiki pages.
739             *
740             * <p>
741             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
742             * </p>
743             */
744            @Override
745            public void clearCache() {
746                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
747                            CacheRegistryUtil.clear(WikiPageImpl.class.getName());
748                    }
749    
750                    EntityCacheUtil.clearCache(WikiPageImpl.class.getName());
751    
752                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
753                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
754                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
755            }
756    
757            /**
758             * Clears the cache for the wiki page.
759             *
760             * <p>
761             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
762             * </p>
763             */
764            @Override
765            public void clearCache(WikiPage wikiPage) {
766                    EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
767                            WikiPageImpl.class, wikiPage.getPrimaryKey());
768    
769                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
770                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
771    
772                    clearUniqueFindersCache(wikiPage);
773            }
774    
775            @Override
776            public void clearCache(List<WikiPage> wikiPages) {
777                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
778                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
779    
780                    for (WikiPage wikiPage : wikiPages) {
781                            EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
782                                    WikiPageImpl.class, wikiPage.getPrimaryKey());
783    
784                            clearUniqueFindersCache(wikiPage);
785                    }
786            }
787    
788            protected void cacheUniqueFindersCache(WikiPage wikiPage) {
789                    if (wikiPage.isNew()) {
790                            Object[] args = new Object[] {
791                                            wikiPage.getUuid(), Long.valueOf(wikiPage.getGroupId())
792                                    };
793    
794                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
795                                    Long.valueOf(1));
796                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
797                                    wikiPage);
798    
799                            args = new Object[] {
800                                            Long.valueOf(wikiPage.getResourcePrimKey()),
801                                            Long.valueOf(wikiPage.getNodeId()),
802                                            Double.valueOf(wikiPage.getVersion())
803                                    };
804    
805                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_V, args,
806                                    Long.valueOf(1));
807                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V, args, wikiPage);
808    
809                            args = new Object[] {
810                                            Long.valueOf(wikiPage.getNodeId()),
811                                            
812                                            wikiPage.getTitle(), Double.valueOf(wikiPage.getVersion())
813                                    };
814    
815                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V, args,
816                                    Long.valueOf(1));
817                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V, args, wikiPage);
818                    }
819                    else {
820                            WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
821    
822                            if ((wikiPageModelImpl.getColumnBitmask() &
823                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
824                                    Object[] args = new Object[] {
825                                                    wikiPage.getUuid(), Long.valueOf(wikiPage.getGroupId())
826                                            };
827    
828                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
829                                            Long.valueOf(1));
830                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
831                                            wikiPage);
832                            }
833    
834                            if ((wikiPageModelImpl.getColumnBitmask() &
835                                            FINDER_PATH_FETCH_BY_R_N_V.getColumnBitmask()) != 0) {
836                                    Object[] args = new Object[] {
837                                                    Long.valueOf(wikiPage.getResourcePrimKey()),
838                                                    Long.valueOf(wikiPage.getNodeId()),
839                                                    Double.valueOf(wikiPage.getVersion())
840                                            };
841    
842                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_V, args,
843                                            Long.valueOf(1));
844                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V, args,
845                                            wikiPage);
846                            }
847    
848                            if ((wikiPageModelImpl.getColumnBitmask() &
849                                            FINDER_PATH_FETCH_BY_N_T_V.getColumnBitmask()) != 0) {
850                                    Object[] args = new Object[] {
851                                                    Long.valueOf(wikiPage.getNodeId()),
852                                                    
853                                                    wikiPage.getTitle(),
854                                                    Double.valueOf(wikiPage.getVersion())
855                                            };
856    
857                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V, args,
858                                            Long.valueOf(1));
859                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V, args,
860                                            wikiPage);
861                            }
862                    }
863            }
864    
865            protected void clearUniqueFindersCache(WikiPage wikiPage) {
866                    WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
867    
868                    Object[] args = new Object[] {
869                                    wikiPage.getUuid(), Long.valueOf(wikiPage.getGroupId())
870                            };
871    
872                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
873                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
874    
875                    if ((wikiPageModelImpl.getColumnBitmask() &
876                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
877                            args = new Object[] {
878                                            wikiPageModelImpl.getOriginalUuid(),
879                                            Long.valueOf(wikiPageModelImpl.getOriginalGroupId())
880                                    };
881    
882                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
883                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
884                    }
885    
886                    args = new Object[] {
887                                    Long.valueOf(wikiPage.getResourcePrimKey()),
888                                    Long.valueOf(wikiPage.getNodeId()),
889                                    Double.valueOf(wikiPage.getVersion())
890                            };
891    
892                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_V, args);
893                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V, args);
894    
895                    if ((wikiPageModelImpl.getColumnBitmask() &
896                                    FINDER_PATH_FETCH_BY_R_N_V.getColumnBitmask()) != 0) {
897                            args = new Object[] {
898                                            Long.valueOf(wikiPageModelImpl.getOriginalResourcePrimKey()),
899                                            Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
900                                            Double.valueOf(wikiPageModelImpl.getOriginalVersion())
901                                    };
902    
903                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_V, args);
904                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V, args);
905                    }
906    
907                    args = new Object[] {
908                                    Long.valueOf(wikiPage.getNodeId()),
909                                    
910                                    wikiPage.getTitle(), Double.valueOf(wikiPage.getVersion())
911                            };
912    
913                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_V, args);
914                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V, args);
915    
916                    if ((wikiPageModelImpl.getColumnBitmask() &
917                                    FINDER_PATH_FETCH_BY_N_T_V.getColumnBitmask()) != 0) {
918                            args = new Object[] {
919                                            Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
920                                            
921                                            wikiPageModelImpl.getOriginalTitle(),
922                                            Double.valueOf(wikiPageModelImpl.getOriginalVersion())
923                                    };
924    
925                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_V, args);
926                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V, args);
927                    }
928            }
929    
930            /**
931             * Creates a new wiki page with the primary key. Does not add the wiki page to the database.
932             *
933             * @param pageId the primary key for the new wiki page
934             * @return the new wiki page
935             */
936            public WikiPage create(long pageId) {
937                    WikiPage wikiPage = new WikiPageImpl();
938    
939                    wikiPage.setNew(true);
940                    wikiPage.setPrimaryKey(pageId);
941    
942                    String uuid = PortalUUIDUtil.generate();
943    
944                    wikiPage.setUuid(uuid);
945    
946                    return wikiPage;
947            }
948    
949            /**
950             * Removes the wiki page with the primary key from the database. Also notifies the appropriate model listeners.
951             *
952             * @param pageId the primary key of the wiki page
953             * @return the wiki page that was removed
954             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
955             * @throws SystemException if a system exception occurred
956             */
957            public WikiPage remove(long pageId)
958                    throws NoSuchPageException, SystemException {
959                    return remove(Long.valueOf(pageId));
960            }
961    
962            /**
963             * Removes the wiki page with the primary key from the database. Also notifies the appropriate model listeners.
964             *
965             * @param primaryKey the primary key of the wiki page
966             * @return the wiki page that was removed
967             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
968             * @throws SystemException if a system exception occurred
969             */
970            @Override
971            public WikiPage remove(Serializable primaryKey)
972                    throws NoSuchPageException, SystemException {
973                    Session session = null;
974    
975                    try {
976                            session = openSession();
977    
978                            WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
979                                            primaryKey);
980    
981                            if (wikiPage == null) {
982                                    if (_log.isWarnEnabled()) {
983                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
984                                    }
985    
986                                    throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
987                                            primaryKey);
988                            }
989    
990                            return remove(wikiPage);
991                    }
992                    catch (NoSuchPageException nsee) {
993                            throw nsee;
994                    }
995                    catch (Exception e) {
996                            throw processException(e);
997                    }
998                    finally {
999                            closeSession(session);
1000                    }
1001            }
1002    
1003            @Override
1004            protected WikiPage removeImpl(WikiPage wikiPage) throws SystemException {
1005                    wikiPage = toUnwrappedModel(wikiPage);
1006    
1007                    Session session = null;
1008    
1009                    try {
1010                            session = openSession();
1011    
1012                            BatchSessionUtil.delete(session, wikiPage);
1013                    }
1014                    catch (Exception e) {
1015                            throw processException(e);
1016                    }
1017                    finally {
1018                            closeSession(session);
1019                    }
1020    
1021                    clearCache(wikiPage);
1022    
1023                    return wikiPage;
1024            }
1025    
1026            @Override
1027            public WikiPage updateImpl(
1028                    com.liferay.portlet.wiki.model.WikiPage wikiPage, boolean merge)
1029                    throws SystemException {
1030                    wikiPage = toUnwrappedModel(wikiPage);
1031    
1032                    boolean isNew = wikiPage.isNew();
1033    
1034                    WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
1035    
1036                    if (Validator.isNull(wikiPage.getUuid())) {
1037                            String uuid = PortalUUIDUtil.generate();
1038    
1039                            wikiPage.setUuid(uuid);
1040                    }
1041    
1042                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
1043    
1044                    if (userId > 0) {
1045                            long companyId = wikiPage.getCompanyId();
1046    
1047                            long groupId = wikiPage.getGroupId();
1048    
1049                            long pageId = 0;
1050    
1051                            if (!isNew) {
1052                                    pageId = wikiPage.getPrimaryKey();
1053                            }
1054    
1055                            try {
1056                                    wikiPage.setTitle(SanitizerUtil.sanitize(companyId, groupId,
1057                                                    userId,
1058                                                    com.liferay.portlet.wiki.model.WikiPage.class.getName(),
1059                                                    pageId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
1060                                                    wikiPage.getTitle(), null));
1061                            }
1062                            catch (SanitizerException se) {
1063                                    throw new SystemException(se);
1064                            }
1065                    }
1066    
1067                    Session session = null;
1068    
1069                    try {
1070                            session = openSession();
1071    
1072                            BatchSessionUtil.update(session, wikiPage, merge);
1073    
1074                            wikiPage.setNew(false);
1075                    }
1076                    catch (Exception e) {
1077                            throw processException(e);
1078                    }
1079                    finally {
1080                            closeSession(session);
1081                    }
1082    
1083                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1084    
1085                    if (isNew || !WikiPageModelImpl.COLUMN_BITMASK_ENABLED) {
1086                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1087                    }
1088    
1089                    else {
1090                            if ((wikiPageModelImpl.getColumnBitmask() &
1091                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
1092                                    Object[] args = new Object[] { wikiPageModelImpl.getOriginalUuid() };
1093    
1094                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
1095                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
1096                                            args);
1097    
1098                                    args = new Object[] { wikiPageModelImpl.getUuid() };
1099    
1100                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
1101                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
1102                                            args);
1103                            }
1104    
1105                            if ((wikiPageModelImpl.getColumnBitmask() &
1106                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID.getColumnBitmask()) != 0) {
1107                                    Object[] args = new Object[] {
1108                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId())
1109                                            };
1110    
1111                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NODEID, args);
1112                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID,
1113                                            args);
1114    
1115                                    args = new Object[] { Long.valueOf(wikiPageModelImpl.getNodeId()) };
1116    
1117                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NODEID, args);
1118                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID,
1119                                            args);
1120                            }
1121    
1122                            if ((wikiPageModelImpl.getColumnBitmask() &
1123                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT.getColumnBitmask()) != 0) {
1124                                    Object[] args = new Object[] {
1125                                                    wikiPageModelImpl.getOriginalFormat()
1126                                            };
1127    
1128                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FORMAT, args);
1129                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT,
1130                                            args);
1131    
1132                                    args = new Object[] { wikiPageModelImpl.getFormat() };
1133    
1134                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FORMAT, args);
1135                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT,
1136                                            args);
1137                            }
1138    
1139                            if ((wikiPageModelImpl.getColumnBitmask() &
1140                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N.getColumnBitmask()) != 0) {
1141                                    Object[] args = new Object[] {
1142                                                    Long.valueOf(wikiPageModelImpl.getOriginalResourcePrimKey()),
1143                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId())
1144                                            };
1145    
1146                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N, args);
1147                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N,
1148                                            args);
1149    
1150                                    args = new Object[] {
1151                                                    Long.valueOf(wikiPageModelImpl.getResourcePrimKey()),
1152                                                    Long.valueOf(wikiPageModelImpl.getNodeId())
1153                                            };
1154    
1155                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N, args);
1156                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N,
1157                                            args);
1158                            }
1159    
1160                            if ((wikiPageModelImpl.getColumnBitmask() &
1161                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T.getColumnBitmask()) != 0) {
1162                                    Object[] args = new Object[] {
1163                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1164                                                    
1165                                                    wikiPageModelImpl.getOriginalTitle()
1166                                            };
1167    
1168                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T, args);
1169                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T,
1170                                            args);
1171    
1172                                    args = new Object[] {
1173                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1174                                                    
1175                                                    wikiPageModelImpl.getTitle()
1176                                            };
1177    
1178                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T, args);
1179                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T,
1180                                            args);
1181                            }
1182    
1183                            if ((wikiPageModelImpl.getColumnBitmask() &
1184                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H.getColumnBitmask()) != 0) {
1185                                    Object[] args = new Object[] {
1186                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1187                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead())
1188                                            };
1189    
1190                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H, args);
1191                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H,
1192                                            args);
1193    
1194                                    args = new Object[] {
1195                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1196                                                    Boolean.valueOf(wikiPageModelImpl.getHead())
1197                                            };
1198    
1199                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H, args);
1200                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H,
1201                                            args);
1202                            }
1203    
1204                            if ((wikiPageModelImpl.getColumnBitmask() &
1205                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P.getColumnBitmask()) != 0) {
1206                                    Object[] args = new Object[] {
1207                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1208                                                    
1209                                                    wikiPageModelImpl.getOriginalParentTitle()
1210                                            };
1211    
1212                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_P, args);
1213                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P,
1214                                            args);
1215    
1216                                    args = new Object[] {
1217                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1218                                                    
1219                                                    wikiPageModelImpl.getParentTitle()
1220                                            };
1221    
1222                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_P, args);
1223                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P,
1224                                            args);
1225                            }
1226    
1227                            if ((wikiPageModelImpl.getColumnBitmask() &
1228                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R.getColumnBitmask()) != 0) {
1229                                    Object[] args = new Object[] {
1230                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1231                                                    
1232                                                    wikiPageModelImpl.getOriginalRedirectTitle()
1233                                            };
1234    
1235                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_R, args);
1236                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R,
1237                                            args);
1238    
1239                                    args = new Object[] {
1240                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1241                                                    
1242                                                    wikiPageModelImpl.getRedirectTitle()
1243                                            };
1244    
1245                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_R, args);
1246                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R,
1247                                            args);
1248                            }
1249    
1250                            if ((wikiPageModelImpl.getColumnBitmask() &
1251                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S.getColumnBitmask()) != 0) {
1252                                    Object[] args = new Object[] {
1253                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1254                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1255                                            };
1256    
1257                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_S, args);
1258                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S,
1259                                            args);
1260    
1261                                    args = new Object[] {
1262                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1263                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1264                                            };
1265    
1266                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_S, args);
1267                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S,
1268                                            args);
1269                            }
1270    
1271                            if ((wikiPageModelImpl.getColumnBitmask() &
1272                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S.getColumnBitmask()) != 0) {
1273                                    Object[] args = new Object[] {
1274                                                    Long.valueOf(wikiPageModelImpl.getOriginalResourcePrimKey()),
1275                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1276                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1277                                            };
1278    
1279                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_S, args);
1280                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S,
1281                                            args);
1282    
1283                                    args = new Object[] {
1284                                                    Long.valueOf(wikiPageModelImpl.getResourcePrimKey()),
1285                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1286                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1287                                            };
1288    
1289                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_N_S, args);
1290                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S,
1291                                            args);
1292                            }
1293    
1294                            if ((wikiPageModelImpl.getColumnBitmask() &
1295                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H.getColumnBitmask()) != 0) {
1296                                    Object[] args = new Object[] {
1297                                                    Long.valueOf(wikiPageModelImpl.getOriginalGroupId()),
1298                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1299                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead())
1300                                            };
1301    
1302                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H, args);
1303                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H,
1304                                            args);
1305    
1306                                    args = new Object[] {
1307                                                    Long.valueOf(wikiPageModelImpl.getGroupId()),
1308                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1309                                                    Boolean.valueOf(wikiPageModelImpl.getHead())
1310                                            };
1311    
1312                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H, args);
1313                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H,
1314                                            args);
1315                            }
1316    
1317                            if ((wikiPageModelImpl.getColumnBitmask() &
1318                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S.getColumnBitmask()) != 0) {
1319                                    Object[] args = new Object[] {
1320                                                    Long.valueOf(wikiPageModelImpl.getOriginalGroupId()),
1321                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1322                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1323                                            };
1324    
1325                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_S, args);
1326                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S,
1327                                            args);
1328    
1329                                    args = new Object[] {
1330                                                    Long.valueOf(wikiPageModelImpl.getGroupId()),
1331                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1332                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1333                                            };
1334    
1335                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_S, args);
1336                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S,
1337                                            args);
1338                            }
1339    
1340                            if ((wikiPageModelImpl.getColumnBitmask() &
1341                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S.getColumnBitmask()) != 0) {
1342                                    Object[] args = new Object[] {
1343                                                    Long.valueOf(wikiPageModelImpl.getOriginalUserId()),
1344                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1345                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1346                                            };
1347    
1348                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_N_S, args);
1349                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S,
1350                                            args);
1351    
1352                                    args = new Object[] {
1353                                                    Long.valueOf(wikiPageModelImpl.getUserId()),
1354                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1355                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1356                                            };
1357    
1358                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_N_S, args);
1359                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S,
1360                                            args);
1361                            }
1362    
1363                            if ((wikiPageModelImpl.getColumnBitmask() &
1364                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H.getColumnBitmask()) != 0) {
1365                                    Object[] args = new Object[] {
1366                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1367                                                    
1368                                                    wikiPageModelImpl.getOriginalTitle(),
1369                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead())
1370                                            };
1371    
1372                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_H, args);
1373                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H,
1374                                            args);
1375    
1376                                    args = new Object[] {
1377                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1378                                                    
1379                                                    wikiPageModelImpl.getTitle(),
1380                                                    Boolean.valueOf(wikiPageModelImpl.getHead())
1381                                            };
1382    
1383                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_H, args);
1384                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H,
1385                                            args);
1386                            }
1387    
1388                            if ((wikiPageModelImpl.getColumnBitmask() &
1389                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S.getColumnBitmask()) != 0) {
1390                                    Object[] args = new Object[] {
1391                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1392                                                    
1393                                                    wikiPageModelImpl.getOriginalTitle(),
1394                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1395                                            };
1396    
1397                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_S, args);
1398                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S,
1399                                            args);
1400    
1401                                    args = new Object[] {
1402                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1403                                                    
1404                                                    wikiPageModelImpl.getTitle(),
1405                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1406                                            };
1407    
1408                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_T_S, args);
1409                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S,
1410                                            args);
1411                            }
1412    
1413                            if ((wikiPageModelImpl.getColumnBitmask() &
1414                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P.getColumnBitmask()) != 0) {
1415                                    Object[] args = new Object[] {
1416                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1417                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead()),
1418                                                    
1419                                                    wikiPageModelImpl.getOriginalParentTitle()
1420                                            };
1421    
1422                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P, args);
1423                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P,
1424                                            args);
1425    
1426                                    args = new Object[] {
1427                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1428                                                    Boolean.valueOf(wikiPageModelImpl.getHead()),
1429                                                    
1430                                                    wikiPageModelImpl.getParentTitle()
1431                                            };
1432    
1433                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P, args);
1434                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P,
1435                                            args);
1436                            }
1437    
1438                            if ((wikiPageModelImpl.getColumnBitmask() &
1439                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S.getColumnBitmask()) != 0) {
1440                                    Object[] args = new Object[] {
1441                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1442                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead()),
1443                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1444                                            };
1445    
1446                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_S, args);
1447                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S,
1448                                            args);
1449    
1450                                    args = new Object[] {
1451                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1452                                                    Boolean.valueOf(wikiPageModelImpl.getHead()),
1453                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1454                                            };
1455    
1456                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_S, args);
1457                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S,
1458                                            args);
1459                            }
1460    
1461                            if ((wikiPageModelImpl.getColumnBitmask() &
1462                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S.getColumnBitmask()) != 0) {
1463                                    Object[] args = new Object[] {
1464                                                    Long.valueOf(wikiPageModelImpl.getOriginalGroupId()),
1465                                                    Long.valueOf(wikiPageModelImpl.getOriginalUserId()),
1466                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1467                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1468                                            };
1469    
1470                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_N_S, args);
1471                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S,
1472                                            args);
1473    
1474                                    args = new Object[] {
1475                                                    Long.valueOf(wikiPageModelImpl.getGroupId()),
1476                                                    Long.valueOf(wikiPageModelImpl.getUserId()),
1477                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1478                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1479                                            };
1480    
1481                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_N_S, args);
1482                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S,
1483                                            args);
1484                            }
1485    
1486                            if ((wikiPageModelImpl.getColumnBitmask() &
1487                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H.getColumnBitmask()) != 0) {
1488                                    Object[] args = new Object[] {
1489                                                    Long.valueOf(wikiPageModelImpl.getOriginalGroupId()),
1490                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1491                                                    
1492                                                    wikiPageModelImpl.getOriginalTitle(),
1493                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead())
1494                                            };
1495    
1496                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_T_H, args);
1497                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H,
1498                                            args);
1499    
1500                                    args = new Object[] {
1501                                                    Long.valueOf(wikiPageModelImpl.getGroupId()),
1502                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1503                                                    
1504                                                    wikiPageModelImpl.getTitle(),
1505                                                    Boolean.valueOf(wikiPageModelImpl.getHead())
1506                                            };
1507    
1508                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_T_H, args);
1509                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H,
1510                                            args);
1511                            }
1512    
1513                            if ((wikiPageModelImpl.getColumnBitmask() &
1514                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S.getColumnBitmask()) != 0) {
1515                                    Object[] args = new Object[] {
1516                                                    Long.valueOf(wikiPageModelImpl.getOriginalGroupId()),
1517                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1518                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead()),
1519                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1520                                            };
1521    
1522                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_S, args);
1523                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S,
1524                                            args);
1525    
1526                                    args = new Object[] {
1527                                                    Long.valueOf(wikiPageModelImpl.getGroupId()),
1528                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1529                                                    Boolean.valueOf(wikiPageModelImpl.getHead()),
1530                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1531                                            };
1532    
1533                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_S, args);
1534                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S,
1535                                            args);
1536                            }
1537    
1538                            if ((wikiPageModelImpl.getColumnBitmask() &
1539                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S.getColumnBitmask()) != 0) {
1540                                    Object[] args = new Object[] {
1541                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1542                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead()),
1543                                                    
1544                                                    wikiPageModelImpl.getOriginalParentTitle(),
1545                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1546                                            };
1547    
1548                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P_S, args);
1549                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S,
1550                                            args);
1551    
1552                                    args = new Object[] {
1553                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1554                                                    Boolean.valueOf(wikiPageModelImpl.getHead()),
1555                                                    
1556                                                    wikiPageModelImpl.getParentTitle(),
1557                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1558                                            };
1559    
1560                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_H_P_S, args);
1561                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S,
1562                                            args);
1563                            }
1564    
1565                            if ((wikiPageModelImpl.getColumnBitmask() &
1566                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S.getColumnBitmask()) != 0) {
1567                                    Object[] args = new Object[] {
1568                                                    Long.valueOf(wikiPageModelImpl.getOriginalGroupId()),
1569                                                    Long.valueOf(wikiPageModelImpl.getOriginalNodeId()),
1570                                                    Boolean.valueOf(wikiPageModelImpl.getOriginalHead()),
1571                                                    
1572                                                    wikiPageModelImpl.getOriginalParentTitle(),
1573                                                    Integer.valueOf(wikiPageModelImpl.getOriginalStatus())
1574                                            };
1575    
1576                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_P_S,
1577                                            args);
1578                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S,
1579                                            args);
1580    
1581                                    args = new Object[] {
1582                                                    Long.valueOf(wikiPageModelImpl.getGroupId()),
1583                                                    Long.valueOf(wikiPageModelImpl.getNodeId()),
1584                                                    Boolean.valueOf(wikiPageModelImpl.getHead()),
1585                                                    
1586                                                    wikiPageModelImpl.getParentTitle(),
1587                                                    Integer.valueOf(wikiPageModelImpl.getStatus())
1588                                            };
1589    
1590                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_H_P_S,
1591                                            args);
1592                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S,
1593                                            args);
1594                            }
1595                    }
1596    
1597                    EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1598                            WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
1599    
1600                    clearUniqueFindersCache(wikiPage);
1601                    cacheUniqueFindersCache(wikiPage);
1602    
1603                    return wikiPage;
1604            }
1605    
1606            protected WikiPage toUnwrappedModel(WikiPage wikiPage) {
1607                    if (wikiPage instanceof WikiPageImpl) {
1608                            return wikiPage;
1609                    }
1610    
1611                    WikiPageImpl wikiPageImpl = new WikiPageImpl();
1612    
1613                    wikiPageImpl.setNew(wikiPage.isNew());
1614                    wikiPageImpl.setPrimaryKey(wikiPage.getPrimaryKey());
1615    
1616                    wikiPageImpl.setUuid(wikiPage.getUuid());
1617                    wikiPageImpl.setPageId(wikiPage.getPageId());
1618                    wikiPageImpl.setResourcePrimKey(wikiPage.getResourcePrimKey());
1619                    wikiPageImpl.setGroupId(wikiPage.getGroupId());
1620                    wikiPageImpl.setCompanyId(wikiPage.getCompanyId());
1621                    wikiPageImpl.setUserId(wikiPage.getUserId());
1622                    wikiPageImpl.setUserName(wikiPage.getUserName());
1623                    wikiPageImpl.setCreateDate(wikiPage.getCreateDate());
1624                    wikiPageImpl.setModifiedDate(wikiPage.getModifiedDate());
1625                    wikiPageImpl.setNodeId(wikiPage.getNodeId());
1626                    wikiPageImpl.setTitle(wikiPage.getTitle());
1627                    wikiPageImpl.setVersion(wikiPage.getVersion());
1628                    wikiPageImpl.setMinorEdit(wikiPage.isMinorEdit());
1629                    wikiPageImpl.setContent(wikiPage.getContent());
1630                    wikiPageImpl.setSummary(wikiPage.getSummary());
1631                    wikiPageImpl.setFormat(wikiPage.getFormat());
1632                    wikiPageImpl.setHead(wikiPage.isHead());
1633                    wikiPageImpl.setParentTitle(wikiPage.getParentTitle());
1634                    wikiPageImpl.setRedirectTitle(wikiPage.getRedirectTitle());
1635                    wikiPageImpl.setStatus(wikiPage.getStatus());
1636                    wikiPageImpl.setStatusByUserId(wikiPage.getStatusByUserId());
1637                    wikiPageImpl.setStatusByUserName(wikiPage.getStatusByUserName());
1638                    wikiPageImpl.setStatusDate(wikiPage.getStatusDate());
1639    
1640                    return wikiPageImpl;
1641            }
1642    
1643            /**
1644             * Returns the wiki page with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1645             *
1646             * @param primaryKey the primary key of the wiki page
1647             * @return the wiki page
1648             * @throws com.liferay.portal.NoSuchModelException if a wiki page with the primary key could not be found
1649             * @throws SystemException if a system exception occurred
1650             */
1651            @Override
1652            public WikiPage findByPrimaryKey(Serializable primaryKey)
1653                    throws NoSuchModelException, SystemException {
1654                    return findByPrimaryKey(((Long)primaryKey).longValue());
1655            }
1656    
1657            /**
1658             * Returns the wiki page with the primary key or throws a {@link com.liferay.portlet.wiki.NoSuchPageException} if it could not be found.
1659             *
1660             * @param pageId the primary key of the wiki page
1661             * @return the wiki page
1662             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1663             * @throws SystemException if a system exception occurred
1664             */
1665            public WikiPage findByPrimaryKey(long pageId)
1666                    throws NoSuchPageException, SystemException {
1667                    WikiPage wikiPage = fetchByPrimaryKey(pageId);
1668    
1669                    if (wikiPage == null) {
1670                            if (_log.isWarnEnabled()) {
1671                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + pageId);
1672                            }
1673    
1674                            throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1675                                    pageId);
1676                    }
1677    
1678                    return wikiPage;
1679            }
1680    
1681            /**
1682             * Returns the wiki page with the primary key or returns <code>null</code> if it could not be found.
1683             *
1684             * @param primaryKey the primary key of the wiki page
1685             * @return the wiki page, or <code>null</code> if a wiki page with the primary key could not be found
1686             * @throws SystemException if a system exception occurred
1687             */
1688            @Override
1689            public WikiPage fetchByPrimaryKey(Serializable primaryKey)
1690                    throws SystemException {
1691                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1692            }
1693    
1694            /**
1695             * Returns the wiki page with the primary key or returns <code>null</code> if it could not be found.
1696             *
1697             * @param pageId the primary key of the wiki page
1698             * @return the wiki page, or <code>null</code> if a wiki page with the primary key could not be found
1699             * @throws SystemException if a system exception occurred
1700             */
1701            public WikiPage fetchByPrimaryKey(long pageId) throws SystemException {
1702                    WikiPage wikiPage = (WikiPage)EntityCacheUtil.getResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1703                                    WikiPageImpl.class, pageId);
1704    
1705                    if (wikiPage == _nullWikiPage) {
1706                            return null;
1707                    }
1708    
1709                    if (wikiPage == null) {
1710                            Session session = null;
1711    
1712                            boolean hasException = false;
1713    
1714                            try {
1715                                    session = openSession();
1716    
1717                                    wikiPage = (WikiPage)session.get(WikiPageImpl.class,
1718                                                    Long.valueOf(pageId));
1719                            }
1720                            catch (Exception e) {
1721                                    hasException = true;
1722    
1723                                    throw processException(e);
1724                            }
1725                            finally {
1726                                    if (wikiPage != null) {
1727                                            cacheResult(wikiPage);
1728                                    }
1729                                    else if (!hasException) {
1730                                            EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
1731                                                    WikiPageImpl.class, pageId, _nullWikiPage);
1732                                    }
1733    
1734                                    closeSession(session);
1735                            }
1736                    }
1737    
1738                    return wikiPage;
1739            }
1740    
1741            /**
1742             * Returns all the wiki pages where uuid = &#63;.
1743             *
1744             * @param uuid the uuid
1745             * @return the matching wiki pages
1746             * @throws SystemException if a system exception occurred
1747             */
1748            public List<WikiPage> findByUuid(String uuid) throws SystemException {
1749                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1750            }
1751    
1752            /**
1753             * Returns a range of all the wiki pages where uuid = &#63;.
1754             *
1755             * <p>
1756             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1757             * </p>
1758             *
1759             * @param uuid the uuid
1760             * @param start the lower bound of the range of wiki pages
1761             * @param end the upper bound of the range of wiki pages (not inclusive)
1762             * @return the range of matching wiki pages
1763             * @throws SystemException if a system exception occurred
1764             */
1765            public List<WikiPage> findByUuid(String uuid, int start, int end)
1766                    throws SystemException {
1767                    return findByUuid(uuid, start, end, null);
1768            }
1769    
1770            /**
1771             * Returns an ordered range of all the wiki pages where uuid = &#63;.
1772             *
1773             * <p>
1774             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1775             * </p>
1776             *
1777             * @param uuid the uuid
1778             * @param start the lower bound of the range of wiki pages
1779             * @param end the upper bound of the range of wiki pages (not inclusive)
1780             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1781             * @return the ordered range of matching wiki pages
1782             * @throws SystemException if a system exception occurred
1783             */
1784            public List<WikiPage> findByUuid(String uuid, int start, int end,
1785                    OrderByComparator orderByComparator) throws SystemException {
1786                    FinderPath finderPath = null;
1787                    Object[] finderArgs = null;
1788    
1789                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1790                                    (orderByComparator == null)) {
1791                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1792                            finderArgs = new Object[] { uuid };
1793                    }
1794                    else {
1795                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1796                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1797                    }
1798    
1799                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
1800                                    finderArgs, this);
1801    
1802                    if ((list != null) && !list.isEmpty()) {
1803                            for (WikiPage wikiPage : list) {
1804                                    if (!Validator.equals(uuid, wikiPage.getUuid())) {
1805                                            list = null;
1806    
1807                                            break;
1808                                    }
1809                            }
1810                    }
1811    
1812                    if (list == null) {
1813                            StringBundler query = null;
1814    
1815                            if (orderByComparator != null) {
1816                                    query = new StringBundler(3 +
1817                                                    (orderByComparator.getOrderByFields().length * 3));
1818                            }
1819                            else {
1820                                    query = new StringBundler(3);
1821                            }
1822    
1823                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1824    
1825                            if (uuid == null) {
1826                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1827                            }
1828                            else {
1829                                    if (uuid.equals(StringPool.BLANK)) {
1830                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1831                                    }
1832                                    else {
1833                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1834                                    }
1835                            }
1836    
1837                            if (orderByComparator != null) {
1838                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1839                                            orderByComparator);
1840                            }
1841    
1842                            else {
1843                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1844                            }
1845    
1846                            String sql = query.toString();
1847    
1848                            Session session = null;
1849    
1850                            try {
1851                                    session = openSession();
1852    
1853                                    Query q = session.createQuery(sql);
1854    
1855                                    QueryPos qPos = QueryPos.getInstance(q);
1856    
1857                                    if (uuid != null) {
1858                                            qPos.add(uuid);
1859                                    }
1860    
1861                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1862                                                    end);
1863                            }
1864                            catch (Exception e) {
1865                                    throw processException(e);
1866                            }
1867                            finally {
1868                                    if (list == null) {
1869                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1870                                    }
1871                                    else {
1872                                            cacheResult(list);
1873    
1874                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1875                                    }
1876    
1877                                    closeSession(session);
1878                            }
1879                    }
1880    
1881                    return list;
1882            }
1883    
1884            /**
1885             * Returns the first wiki page in the ordered set where uuid = &#63;.
1886             *
1887             * @param uuid the uuid
1888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1889             * @return the first matching wiki page
1890             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1891             * @throws SystemException if a system exception occurred
1892             */
1893            public WikiPage findByUuid_First(String uuid,
1894                    OrderByComparator orderByComparator)
1895                    throws NoSuchPageException, SystemException {
1896                    WikiPage wikiPage = fetchByUuid_First(uuid, orderByComparator);
1897    
1898                    if (wikiPage != null) {
1899                            return wikiPage;
1900                    }
1901    
1902                    StringBundler msg = new StringBundler(4);
1903    
1904                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1905    
1906                    msg.append("uuid=");
1907                    msg.append(uuid);
1908    
1909                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1910    
1911                    throw new NoSuchPageException(msg.toString());
1912            }
1913    
1914            /**
1915             * Returns the first wiki page in the ordered set where uuid = &#63;.
1916             *
1917             * @param uuid the uuid
1918             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1919             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
1920             * @throws SystemException if a system exception occurred
1921             */
1922            public WikiPage fetchByUuid_First(String uuid,
1923                    OrderByComparator orderByComparator) throws SystemException {
1924                    List<WikiPage> list = findByUuid(uuid, 0, 1, orderByComparator);
1925    
1926                    if (!list.isEmpty()) {
1927                            return list.get(0);
1928                    }
1929    
1930                    return null;
1931            }
1932    
1933            /**
1934             * Returns the last wiki page in the ordered set where uuid = &#63;.
1935             *
1936             * @param uuid the uuid
1937             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1938             * @return the last matching wiki page
1939             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
1940             * @throws SystemException if a system exception occurred
1941             */
1942            public WikiPage findByUuid_Last(String uuid,
1943                    OrderByComparator orderByComparator)
1944                    throws NoSuchPageException, SystemException {
1945                    WikiPage wikiPage = fetchByUuid_Last(uuid, orderByComparator);
1946    
1947                    if (wikiPage != null) {
1948                            return wikiPage;
1949                    }
1950    
1951                    StringBundler msg = new StringBundler(4);
1952    
1953                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1954    
1955                    msg.append("uuid=");
1956                    msg.append(uuid);
1957    
1958                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1959    
1960                    throw new NoSuchPageException(msg.toString());
1961            }
1962    
1963            /**
1964             * Returns the last wiki page in the ordered set where uuid = &#63;.
1965             *
1966             * @param uuid the uuid
1967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1968             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
1969             * @throws SystemException if a system exception occurred
1970             */
1971            public WikiPage fetchByUuid_Last(String uuid,
1972                    OrderByComparator orderByComparator) throws SystemException {
1973                    int count = countByUuid(uuid);
1974    
1975                    List<WikiPage> list = findByUuid(uuid, count - 1, count,
1976                                    orderByComparator);
1977    
1978                    if (!list.isEmpty()) {
1979                            return list.get(0);
1980                    }
1981    
1982                    return null;
1983            }
1984    
1985            /**
1986             * Returns the wiki pages before and after the current wiki page in the ordered set where uuid = &#63;.
1987             *
1988             * @param pageId the primary key of the current wiki page
1989             * @param uuid the uuid
1990             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1991             * @return the previous, current, and next wiki page
1992             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
1993             * @throws SystemException if a system exception occurred
1994             */
1995            public WikiPage[] findByUuid_PrevAndNext(long pageId, String uuid,
1996                    OrderByComparator orderByComparator)
1997                    throws NoSuchPageException, SystemException {
1998                    WikiPage wikiPage = findByPrimaryKey(pageId);
1999    
2000                    Session session = null;
2001    
2002                    try {
2003                            session = openSession();
2004    
2005                            WikiPage[] array = new WikiPageImpl[3];
2006    
2007                            array[0] = getByUuid_PrevAndNext(session, wikiPage, uuid,
2008                                            orderByComparator, true);
2009    
2010                            array[1] = wikiPage;
2011    
2012                            array[2] = getByUuid_PrevAndNext(session, wikiPage, uuid,
2013                                            orderByComparator, false);
2014    
2015                            return array;
2016                    }
2017                    catch (Exception e) {
2018                            throw processException(e);
2019                    }
2020                    finally {
2021                            closeSession(session);
2022                    }
2023            }
2024    
2025            protected WikiPage getByUuid_PrevAndNext(Session session,
2026                    WikiPage wikiPage, String uuid, OrderByComparator orderByComparator,
2027                    boolean previous) {
2028                    StringBundler query = null;
2029    
2030                    if (orderByComparator != null) {
2031                            query = new StringBundler(6 +
2032                                            (orderByComparator.getOrderByFields().length * 6));
2033                    }
2034                    else {
2035                            query = new StringBundler(3);
2036                    }
2037    
2038                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2039    
2040                    if (uuid == null) {
2041                            query.append(_FINDER_COLUMN_UUID_UUID_1);
2042                    }
2043                    else {
2044                            if (uuid.equals(StringPool.BLANK)) {
2045                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
2046                            }
2047                            else {
2048                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
2049                            }
2050                    }
2051    
2052                    if (orderByComparator != null) {
2053                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2054    
2055                            if (orderByConditionFields.length > 0) {
2056                                    query.append(WHERE_AND);
2057                            }
2058    
2059                            for (int i = 0; i < orderByConditionFields.length; i++) {
2060                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2061                                    query.append(orderByConditionFields[i]);
2062    
2063                                    if ((i + 1) < orderByConditionFields.length) {
2064                                            if (orderByComparator.isAscending() ^ previous) {
2065                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2066                                            }
2067                                            else {
2068                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2069                                            }
2070                                    }
2071                                    else {
2072                                            if (orderByComparator.isAscending() ^ previous) {
2073                                                    query.append(WHERE_GREATER_THAN);
2074                                            }
2075                                            else {
2076                                                    query.append(WHERE_LESSER_THAN);
2077                                            }
2078                                    }
2079                            }
2080    
2081                            query.append(ORDER_BY_CLAUSE);
2082    
2083                            String[] orderByFields = orderByComparator.getOrderByFields();
2084    
2085                            for (int i = 0; i < orderByFields.length; i++) {
2086                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2087                                    query.append(orderByFields[i]);
2088    
2089                                    if ((i + 1) < orderByFields.length) {
2090                                            if (orderByComparator.isAscending() ^ previous) {
2091                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2092                                            }
2093                                            else {
2094                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2095                                            }
2096                                    }
2097                                    else {
2098                                            if (orderByComparator.isAscending() ^ previous) {
2099                                                    query.append(ORDER_BY_ASC);
2100                                            }
2101                                            else {
2102                                                    query.append(ORDER_BY_DESC);
2103                                            }
2104                                    }
2105                            }
2106                    }
2107    
2108                    else {
2109                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2110                    }
2111    
2112                    String sql = query.toString();
2113    
2114                    Query q = session.createQuery(sql);
2115    
2116                    q.setFirstResult(0);
2117                    q.setMaxResults(2);
2118    
2119                    QueryPos qPos = QueryPos.getInstance(q);
2120    
2121                    if (uuid != null) {
2122                            qPos.add(uuid);
2123                    }
2124    
2125                    if (orderByComparator != null) {
2126                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
2127    
2128                            for (Object value : values) {
2129                                    qPos.add(value);
2130                            }
2131                    }
2132    
2133                    List<WikiPage> list = q.list();
2134    
2135                    if (list.size() == 2) {
2136                            return list.get(1);
2137                    }
2138                    else {
2139                            return null;
2140                    }
2141            }
2142    
2143            /**
2144             * 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.
2145             *
2146             * @param uuid the uuid
2147             * @param groupId the group ID
2148             * @return the matching wiki page
2149             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2150             * @throws SystemException if a system exception occurred
2151             */
2152            public WikiPage findByUUID_G(String uuid, long groupId)
2153                    throws NoSuchPageException, SystemException {
2154                    WikiPage wikiPage = fetchByUUID_G(uuid, groupId);
2155    
2156                    if (wikiPage == null) {
2157                            StringBundler msg = new StringBundler(6);
2158    
2159                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2160    
2161                            msg.append("uuid=");
2162                            msg.append(uuid);
2163    
2164                            msg.append(", groupId=");
2165                            msg.append(groupId);
2166    
2167                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2168    
2169                            if (_log.isWarnEnabled()) {
2170                                    _log.warn(msg.toString());
2171                            }
2172    
2173                            throw new NoSuchPageException(msg.toString());
2174                    }
2175    
2176                    return wikiPage;
2177            }
2178    
2179            /**
2180             * 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.
2181             *
2182             * @param uuid the uuid
2183             * @param groupId the group ID
2184             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
2185             * @throws SystemException if a system exception occurred
2186             */
2187            public WikiPage fetchByUUID_G(String uuid, long groupId)
2188                    throws SystemException {
2189                    return fetchByUUID_G(uuid, groupId, true);
2190            }
2191    
2192            /**
2193             * 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.
2194             *
2195             * @param uuid the uuid
2196             * @param groupId the group ID
2197             * @param retrieveFromCache whether to use the finder cache
2198             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
2199             * @throws SystemException if a system exception occurred
2200             */
2201            public WikiPage fetchByUUID_G(String uuid, long groupId,
2202                    boolean retrieveFromCache) throws SystemException {
2203                    Object[] finderArgs = new Object[] { uuid, groupId };
2204    
2205                    Object result = null;
2206    
2207                    if (retrieveFromCache) {
2208                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
2209                                            finderArgs, this);
2210                    }
2211    
2212                    if (result instanceof WikiPage) {
2213                            WikiPage wikiPage = (WikiPage)result;
2214    
2215                            if (!Validator.equals(uuid, wikiPage.getUuid()) ||
2216                                            (groupId != wikiPage.getGroupId())) {
2217                                    result = null;
2218                            }
2219                    }
2220    
2221                    if (result == null) {
2222                            StringBundler query = new StringBundler(4);
2223    
2224                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2225    
2226                            if (uuid == null) {
2227                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2228                            }
2229                            else {
2230                                    if (uuid.equals(StringPool.BLANK)) {
2231                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2232                                    }
2233                                    else {
2234                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2235                                    }
2236                            }
2237    
2238                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2239    
2240                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2241    
2242                            String sql = query.toString();
2243    
2244                            Session session = null;
2245    
2246                            try {
2247                                    session = openSession();
2248    
2249                                    Query q = session.createQuery(sql);
2250    
2251                                    QueryPos qPos = QueryPos.getInstance(q);
2252    
2253                                    if (uuid != null) {
2254                                            qPos.add(uuid);
2255                                    }
2256    
2257                                    qPos.add(groupId);
2258    
2259                                    List<WikiPage> list = q.list();
2260    
2261                                    result = list;
2262    
2263                                    WikiPage wikiPage = null;
2264    
2265                                    if (list.isEmpty()) {
2266                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2267                                                    finderArgs, list);
2268                                    }
2269                                    else {
2270                                            wikiPage = list.get(0);
2271    
2272                                            cacheResult(wikiPage);
2273    
2274                                            if ((wikiPage.getUuid() == null) ||
2275                                                            !wikiPage.getUuid().equals(uuid) ||
2276                                                            (wikiPage.getGroupId() != groupId)) {
2277                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2278                                                            finderArgs, wikiPage);
2279                                            }
2280                                    }
2281    
2282                                    return wikiPage;
2283                            }
2284                            catch (Exception e) {
2285                                    throw processException(e);
2286                            }
2287                            finally {
2288                                    if (result == null) {
2289                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
2290                                                    finderArgs);
2291                                    }
2292    
2293                                    closeSession(session);
2294                            }
2295                    }
2296                    else {
2297                            if (result instanceof List<?>) {
2298                                    return null;
2299                            }
2300                            else {
2301                                    return (WikiPage)result;
2302                            }
2303                    }
2304            }
2305    
2306            /**
2307             * Returns all the wiki pages where nodeId = &#63;.
2308             *
2309             * @param nodeId the node ID
2310             * @return the matching wiki pages
2311             * @throws SystemException if a system exception occurred
2312             */
2313            public List<WikiPage> findByNodeId(long nodeId) throws SystemException {
2314                    return findByNodeId(nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2315            }
2316    
2317            /**
2318             * Returns a range of all the wiki pages where nodeId = &#63;.
2319             *
2320             * <p>
2321             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2322             * </p>
2323             *
2324             * @param nodeId the node ID
2325             * @param start the lower bound of the range of wiki pages
2326             * @param end the upper bound of the range of wiki pages (not inclusive)
2327             * @return the range of matching wiki pages
2328             * @throws SystemException if a system exception occurred
2329             */
2330            public List<WikiPage> findByNodeId(long nodeId, int start, int end)
2331                    throws SystemException {
2332                    return findByNodeId(nodeId, start, end, null);
2333            }
2334    
2335            /**
2336             * Returns an ordered range of all the wiki pages where nodeId = &#63;.
2337             *
2338             * <p>
2339             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2340             * </p>
2341             *
2342             * @param nodeId the node ID
2343             * @param start the lower bound of the range of wiki pages
2344             * @param end the upper bound of the range of wiki pages (not inclusive)
2345             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2346             * @return the ordered range of matching wiki pages
2347             * @throws SystemException if a system exception occurred
2348             */
2349            public List<WikiPage> findByNodeId(long nodeId, int start, int end,
2350                    OrderByComparator orderByComparator) throws SystemException {
2351                    FinderPath finderPath = null;
2352                    Object[] finderArgs = null;
2353    
2354                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2355                                    (orderByComparator == null)) {
2356                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NODEID;
2357                            finderArgs = new Object[] { nodeId };
2358                    }
2359                    else {
2360                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NODEID;
2361                            finderArgs = new Object[] { nodeId, start, end, orderByComparator };
2362                    }
2363    
2364                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
2365                                    finderArgs, this);
2366    
2367                    if ((list != null) && !list.isEmpty()) {
2368                            for (WikiPage wikiPage : list) {
2369                                    if ((nodeId != wikiPage.getNodeId())) {
2370                                            list = null;
2371    
2372                                            break;
2373                                    }
2374                            }
2375                    }
2376    
2377                    if (list == null) {
2378                            StringBundler query = null;
2379    
2380                            if (orderByComparator != null) {
2381                                    query = new StringBundler(3 +
2382                                                    (orderByComparator.getOrderByFields().length * 3));
2383                            }
2384                            else {
2385                                    query = new StringBundler(3);
2386                            }
2387    
2388                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2389    
2390                            query.append(_FINDER_COLUMN_NODEID_NODEID_2);
2391    
2392                            if (orderByComparator != null) {
2393                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2394                                            orderByComparator);
2395                            }
2396    
2397                            else {
2398                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2399                            }
2400    
2401                            String sql = query.toString();
2402    
2403                            Session session = null;
2404    
2405                            try {
2406                                    session = openSession();
2407    
2408                                    Query q = session.createQuery(sql);
2409    
2410                                    QueryPos qPos = QueryPos.getInstance(q);
2411    
2412                                    qPos.add(nodeId);
2413    
2414                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2415                                                    end);
2416                            }
2417                            catch (Exception e) {
2418                                    throw processException(e);
2419                            }
2420                            finally {
2421                                    if (list == null) {
2422                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2423                                    }
2424                                    else {
2425                                            cacheResult(list);
2426    
2427                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2428                                    }
2429    
2430                                    closeSession(session);
2431                            }
2432                    }
2433    
2434                    return list;
2435            }
2436    
2437            /**
2438             * Returns the first wiki page in the ordered set where nodeId = &#63;.
2439             *
2440             * @param nodeId the node ID
2441             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2442             * @return the first matching wiki page
2443             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2444             * @throws SystemException if a system exception occurred
2445             */
2446            public WikiPage findByNodeId_First(long nodeId,
2447                    OrderByComparator orderByComparator)
2448                    throws NoSuchPageException, SystemException {
2449                    WikiPage wikiPage = fetchByNodeId_First(nodeId, orderByComparator);
2450    
2451                    if (wikiPage != null) {
2452                            return wikiPage;
2453                    }
2454    
2455                    StringBundler msg = new StringBundler(4);
2456    
2457                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2458    
2459                    msg.append("nodeId=");
2460                    msg.append(nodeId);
2461    
2462                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2463    
2464                    throw new NoSuchPageException(msg.toString());
2465            }
2466    
2467            /**
2468             * Returns the first wiki page in the ordered set where nodeId = &#63;.
2469             *
2470             * @param nodeId the node ID
2471             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2472             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
2473             * @throws SystemException if a system exception occurred
2474             */
2475            public WikiPage fetchByNodeId_First(long nodeId,
2476                    OrderByComparator orderByComparator) throws SystemException {
2477                    List<WikiPage> list = findByNodeId(nodeId, 0, 1, orderByComparator);
2478    
2479                    if (!list.isEmpty()) {
2480                            return list.get(0);
2481                    }
2482    
2483                    return null;
2484            }
2485    
2486            /**
2487             * Returns the last wiki page in the ordered set where nodeId = &#63;.
2488             *
2489             * @param nodeId the node ID
2490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2491             * @return the last matching wiki page
2492             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2493             * @throws SystemException if a system exception occurred
2494             */
2495            public WikiPage findByNodeId_Last(long nodeId,
2496                    OrderByComparator orderByComparator)
2497                    throws NoSuchPageException, SystemException {
2498                    WikiPage wikiPage = fetchByNodeId_Last(nodeId, orderByComparator);
2499    
2500                    if (wikiPage != null) {
2501                            return wikiPage;
2502                    }
2503    
2504                    StringBundler msg = new StringBundler(4);
2505    
2506                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2507    
2508                    msg.append("nodeId=");
2509                    msg.append(nodeId);
2510    
2511                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2512    
2513                    throw new NoSuchPageException(msg.toString());
2514            }
2515    
2516            /**
2517             * Returns the last wiki page in the ordered set where nodeId = &#63;.
2518             *
2519             * @param nodeId the node ID
2520             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2521             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
2522             * @throws SystemException if a system exception occurred
2523             */
2524            public WikiPage fetchByNodeId_Last(long nodeId,
2525                    OrderByComparator orderByComparator) throws SystemException {
2526                    int count = countByNodeId(nodeId);
2527    
2528                    List<WikiPage> list = findByNodeId(nodeId, count - 1, count,
2529                                    orderByComparator);
2530    
2531                    if (!list.isEmpty()) {
2532                            return list.get(0);
2533                    }
2534    
2535                    return null;
2536            }
2537    
2538            /**
2539             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63;.
2540             *
2541             * @param pageId the primary key of the current wiki page
2542             * @param nodeId the node ID
2543             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2544             * @return the previous, current, and next wiki page
2545             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2546             * @throws SystemException if a system exception occurred
2547             */
2548            public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
2549                    OrderByComparator orderByComparator)
2550                    throws NoSuchPageException, SystemException {
2551                    WikiPage wikiPage = findByPrimaryKey(pageId);
2552    
2553                    Session session = null;
2554    
2555                    try {
2556                            session = openSession();
2557    
2558                            WikiPage[] array = new WikiPageImpl[3];
2559    
2560                            array[0] = getByNodeId_PrevAndNext(session, wikiPage, nodeId,
2561                                            orderByComparator, true);
2562    
2563                            array[1] = wikiPage;
2564    
2565                            array[2] = getByNodeId_PrevAndNext(session, wikiPage, nodeId,
2566                                            orderByComparator, false);
2567    
2568                            return array;
2569                    }
2570                    catch (Exception e) {
2571                            throw processException(e);
2572                    }
2573                    finally {
2574                            closeSession(session);
2575                    }
2576            }
2577    
2578            protected WikiPage getByNodeId_PrevAndNext(Session session,
2579                    WikiPage wikiPage, long nodeId, OrderByComparator orderByComparator,
2580                    boolean previous) {
2581                    StringBundler query = null;
2582    
2583                    if (orderByComparator != null) {
2584                            query = new StringBundler(6 +
2585                                            (orderByComparator.getOrderByFields().length * 6));
2586                    }
2587                    else {
2588                            query = new StringBundler(3);
2589                    }
2590    
2591                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2592    
2593                    query.append(_FINDER_COLUMN_NODEID_NODEID_2);
2594    
2595                    if (orderByComparator != null) {
2596                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2597    
2598                            if (orderByConditionFields.length > 0) {
2599                                    query.append(WHERE_AND);
2600                            }
2601    
2602                            for (int i = 0; i < orderByConditionFields.length; i++) {
2603                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2604                                    query.append(orderByConditionFields[i]);
2605    
2606                                    if ((i + 1) < orderByConditionFields.length) {
2607                                            if (orderByComparator.isAscending() ^ previous) {
2608                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2609                                            }
2610                                            else {
2611                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2612                                            }
2613                                    }
2614                                    else {
2615                                            if (orderByComparator.isAscending() ^ previous) {
2616                                                    query.append(WHERE_GREATER_THAN);
2617                                            }
2618                                            else {
2619                                                    query.append(WHERE_LESSER_THAN);
2620                                            }
2621                                    }
2622                            }
2623    
2624                            query.append(ORDER_BY_CLAUSE);
2625    
2626                            String[] orderByFields = orderByComparator.getOrderByFields();
2627    
2628                            for (int i = 0; i < orderByFields.length; i++) {
2629                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2630                                    query.append(orderByFields[i]);
2631    
2632                                    if ((i + 1) < orderByFields.length) {
2633                                            if (orderByComparator.isAscending() ^ previous) {
2634                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2635                                            }
2636                                            else {
2637                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2638                                            }
2639                                    }
2640                                    else {
2641                                            if (orderByComparator.isAscending() ^ previous) {
2642                                                    query.append(ORDER_BY_ASC);
2643                                            }
2644                                            else {
2645                                                    query.append(ORDER_BY_DESC);
2646                                            }
2647                                    }
2648                            }
2649                    }
2650    
2651                    else {
2652                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2653                    }
2654    
2655                    String sql = query.toString();
2656    
2657                    Query q = session.createQuery(sql);
2658    
2659                    q.setFirstResult(0);
2660                    q.setMaxResults(2);
2661    
2662                    QueryPos qPos = QueryPos.getInstance(q);
2663    
2664                    qPos.add(nodeId);
2665    
2666                    if (orderByComparator != null) {
2667                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
2668    
2669                            for (Object value : values) {
2670                                    qPos.add(value);
2671                            }
2672                    }
2673    
2674                    List<WikiPage> list = q.list();
2675    
2676                    if (list.size() == 2) {
2677                            return list.get(1);
2678                    }
2679                    else {
2680                            return null;
2681                    }
2682            }
2683    
2684            /**
2685             * Returns all the wiki pages where format = &#63;.
2686             *
2687             * @param format the format
2688             * @return the matching wiki pages
2689             * @throws SystemException if a system exception occurred
2690             */
2691            public List<WikiPage> findByFormat(String format) throws SystemException {
2692                    return findByFormat(format, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2693            }
2694    
2695            /**
2696             * Returns a range of all the wiki pages where format = &#63;.
2697             *
2698             * <p>
2699             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2700             * </p>
2701             *
2702             * @param format the format
2703             * @param start the lower bound of the range of wiki pages
2704             * @param end the upper bound of the range of wiki pages (not inclusive)
2705             * @return the range of matching wiki pages
2706             * @throws SystemException if a system exception occurred
2707             */
2708            public List<WikiPage> findByFormat(String format, int start, int end)
2709                    throws SystemException {
2710                    return findByFormat(format, start, end, null);
2711            }
2712    
2713            /**
2714             * Returns an ordered range of all the wiki pages where format = &#63;.
2715             *
2716             * <p>
2717             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2718             * </p>
2719             *
2720             * @param format the format
2721             * @param start the lower bound of the range of wiki pages
2722             * @param end the upper bound of the range of wiki pages (not inclusive)
2723             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2724             * @return the ordered range of matching wiki pages
2725             * @throws SystemException if a system exception occurred
2726             */
2727            public List<WikiPage> findByFormat(String format, int start, int end,
2728                    OrderByComparator orderByComparator) throws SystemException {
2729                    FinderPath finderPath = null;
2730                    Object[] finderArgs = null;
2731    
2732                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2733                                    (orderByComparator == null)) {
2734                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FORMAT;
2735                            finderArgs = new Object[] { format };
2736                    }
2737                    else {
2738                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FORMAT;
2739                            finderArgs = new Object[] { format, start, end, orderByComparator };
2740                    }
2741    
2742                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
2743                                    finderArgs, this);
2744    
2745                    if ((list != null) && !list.isEmpty()) {
2746                            for (WikiPage wikiPage : list) {
2747                                    if (!Validator.equals(format, wikiPage.getFormat())) {
2748                                            list = null;
2749    
2750                                            break;
2751                                    }
2752                            }
2753                    }
2754    
2755                    if (list == null) {
2756                            StringBundler query = null;
2757    
2758                            if (orderByComparator != null) {
2759                                    query = new StringBundler(3 +
2760                                                    (orderByComparator.getOrderByFields().length * 3));
2761                            }
2762                            else {
2763                                    query = new StringBundler(3);
2764                            }
2765    
2766                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2767    
2768                            if (format == null) {
2769                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
2770                            }
2771                            else {
2772                                    if (format.equals(StringPool.BLANK)) {
2773                                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
2774                                    }
2775                                    else {
2776                                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
2777                                    }
2778                            }
2779    
2780                            if (orderByComparator != null) {
2781                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2782                                            orderByComparator);
2783                            }
2784    
2785                            else {
2786                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2787                            }
2788    
2789                            String sql = query.toString();
2790    
2791                            Session session = null;
2792    
2793                            try {
2794                                    session = openSession();
2795    
2796                                    Query q = session.createQuery(sql);
2797    
2798                                    QueryPos qPos = QueryPos.getInstance(q);
2799    
2800                                    if (format != null) {
2801                                            qPos.add(format);
2802                                    }
2803    
2804                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2805                                                    end);
2806                            }
2807                            catch (Exception e) {
2808                                    throw processException(e);
2809                            }
2810                            finally {
2811                                    if (list == null) {
2812                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2813                                    }
2814                                    else {
2815                                            cacheResult(list);
2816    
2817                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2818                                    }
2819    
2820                                    closeSession(session);
2821                            }
2822                    }
2823    
2824                    return list;
2825            }
2826    
2827            /**
2828             * Returns the first wiki page in the ordered set where format = &#63;.
2829             *
2830             * @param format the format
2831             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2832             * @return the first matching wiki page
2833             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2834             * @throws SystemException if a system exception occurred
2835             */
2836            public WikiPage findByFormat_First(String format,
2837                    OrderByComparator orderByComparator)
2838                    throws NoSuchPageException, SystemException {
2839                    WikiPage wikiPage = fetchByFormat_First(format, orderByComparator);
2840    
2841                    if (wikiPage != null) {
2842                            return wikiPage;
2843                    }
2844    
2845                    StringBundler msg = new StringBundler(4);
2846    
2847                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2848    
2849                    msg.append("format=");
2850                    msg.append(format);
2851    
2852                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2853    
2854                    throw new NoSuchPageException(msg.toString());
2855            }
2856    
2857            /**
2858             * Returns the first wiki page in the ordered set where format = &#63;.
2859             *
2860             * @param format the format
2861             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2862             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
2863             * @throws SystemException if a system exception occurred
2864             */
2865            public WikiPage fetchByFormat_First(String format,
2866                    OrderByComparator orderByComparator) throws SystemException {
2867                    List<WikiPage> list = findByFormat(format, 0, 1, orderByComparator);
2868    
2869                    if (!list.isEmpty()) {
2870                            return list.get(0);
2871                    }
2872    
2873                    return null;
2874            }
2875    
2876            /**
2877             * Returns the last wiki page in the ordered set where format = &#63;.
2878             *
2879             * @param format the format
2880             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2881             * @return the last matching wiki page
2882             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
2883             * @throws SystemException if a system exception occurred
2884             */
2885            public WikiPage findByFormat_Last(String format,
2886                    OrderByComparator orderByComparator)
2887                    throws NoSuchPageException, SystemException {
2888                    WikiPage wikiPage = fetchByFormat_Last(format, orderByComparator);
2889    
2890                    if (wikiPage != null) {
2891                            return wikiPage;
2892                    }
2893    
2894                    StringBundler msg = new StringBundler(4);
2895    
2896                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2897    
2898                    msg.append("format=");
2899                    msg.append(format);
2900    
2901                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2902    
2903                    throw new NoSuchPageException(msg.toString());
2904            }
2905    
2906            /**
2907             * Returns the last wiki page in the ordered set where format = &#63;.
2908             *
2909             * @param format the format
2910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2911             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
2912             * @throws SystemException if a system exception occurred
2913             */
2914            public WikiPage fetchByFormat_Last(String format,
2915                    OrderByComparator orderByComparator) throws SystemException {
2916                    int count = countByFormat(format);
2917    
2918                    List<WikiPage> list = findByFormat(format, count - 1, count,
2919                                    orderByComparator);
2920    
2921                    if (!list.isEmpty()) {
2922                            return list.get(0);
2923                    }
2924    
2925                    return null;
2926            }
2927    
2928            /**
2929             * Returns the wiki pages before and after the current wiki page in the ordered set where format = &#63;.
2930             *
2931             * @param pageId the primary key of the current wiki page
2932             * @param format the format
2933             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2934             * @return the previous, current, and next wiki page
2935             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
2936             * @throws SystemException if a system exception occurred
2937             */
2938            public WikiPage[] findByFormat_PrevAndNext(long pageId, String format,
2939                    OrderByComparator orderByComparator)
2940                    throws NoSuchPageException, SystemException {
2941                    WikiPage wikiPage = findByPrimaryKey(pageId);
2942    
2943                    Session session = null;
2944    
2945                    try {
2946                            session = openSession();
2947    
2948                            WikiPage[] array = new WikiPageImpl[3];
2949    
2950                            array[0] = getByFormat_PrevAndNext(session, wikiPage, format,
2951                                            orderByComparator, true);
2952    
2953                            array[1] = wikiPage;
2954    
2955                            array[2] = getByFormat_PrevAndNext(session, wikiPage, format,
2956                                            orderByComparator, false);
2957    
2958                            return array;
2959                    }
2960                    catch (Exception e) {
2961                            throw processException(e);
2962                    }
2963                    finally {
2964                            closeSession(session);
2965                    }
2966            }
2967    
2968            protected WikiPage getByFormat_PrevAndNext(Session session,
2969                    WikiPage wikiPage, String format, OrderByComparator orderByComparator,
2970                    boolean previous) {
2971                    StringBundler query = null;
2972    
2973                    if (orderByComparator != null) {
2974                            query = new StringBundler(6 +
2975                                            (orderByComparator.getOrderByFields().length * 6));
2976                    }
2977                    else {
2978                            query = new StringBundler(3);
2979                    }
2980    
2981                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2982    
2983                    if (format == null) {
2984                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
2985                    }
2986                    else {
2987                            if (format.equals(StringPool.BLANK)) {
2988                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
2989                            }
2990                            else {
2991                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
2992                            }
2993                    }
2994    
2995                    if (orderByComparator != null) {
2996                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2997    
2998                            if (orderByConditionFields.length > 0) {
2999                                    query.append(WHERE_AND);
3000                            }
3001    
3002                            for (int i = 0; i < orderByConditionFields.length; i++) {
3003                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3004                                    query.append(orderByConditionFields[i]);
3005    
3006                                    if ((i + 1) < orderByConditionFields.length) {
3007                                            if (orderByComparator.isAscending() ^ previous) {
3008                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3009                                            }
3010                                            else {
3011                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3012                                            }
3013                                    }
3014                                    else {
3015                                            if (orderByComparator.isAscending() ^ previous) {
3016                                                    query.append(WHERE_GREATER_THAN);
3017                                            }
3018                                            else {
3019                                                    query.append(WHERE_LESSER_THAN);
3020                                            }
3021                                    }
3022                            }
3023    
3024                            query.append(ORDER_BY_CLAUSE);
3025    
3026                            String[] orderByFields = orderByComparator.getOrderByFields();
3027    
3028                            for (int i = 0; i < orderByFields.length; i++) {
3029                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3030                                    query.append(orderByFields[i]);
3031    
3032                                    if ((i + 1) < orderByFields.length) {
3033                                            if (orderByComparator.isAscending() ^ previous) {
3034                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3035                                            }
3036                                            else {
3037                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3038                                            }
3039                                    }
3040                                    else {
3041                                            if (orderByComparator.isAscending() ^ previous) {
3042                                                    query.append(ORDER_BY_ASC);
3043                                            }
3044                                            else {
3045                                                    query.append(ORDER_BY_DESC);
3046                                            }
3047                                    }
3048                            }
3049                    }
3050    
3051                    else {
3052                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3053                    }
3054    
3055                    String sql = query.toString();
3056    
3057                    Query q = session.createQuery(sql);
3058    
3059                    q.setFirstResult(0);
3060                    q.setMaxResults(2);
3061    
3062                    QueryPos qPos = QueryPos.getInstance(q);
3063    
3064                    if (format != null) {
3065                            qPos.add(format);
3066                    }
3067    
3068                    if (orderByComparator != null) {
3069                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
3070    
3071                            for (Object value : values) {
3072                                    qPos.add(value);
3073                            }
3074                    }
3075    
3076                    List<WikiPage> list = q.list();
3077    
3078                    if (list.size() == 2) {
3079                            return list.get(1);
3080                    }
3081                    else {
3082                            return null;
3083                    }
3084            }
3085    
3086            /**
3087             * Returns all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
3088             *
3089             * @param resourcePrimKey the resource prim key
3090             * @param nodeId the node ID
3091             * @return the matching wiki pages
3092             * @throws SystemException if a system exception occurred
3093             */
3094            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId)
3095                    throws SystemException {
3096                    return findByR_N(resourcePrimKey, nodeId, QueryUtil.ALL_POS,
3097                            QueryUtil.ALL_POS, null);
3098            }
3099    
3100            /**
3101             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
3102             *
3103             * <p>
3104             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3105             * </p>
3106             *
3107             * @param resourcePrimKey the resource prim key
3108             * @param nodeId the node ID
3109             * @param start the lower bound of the range of wiki pages
3110             * @param end the upper bound of the range of wiki pages (not inclusive)
3111             * @return the range of matching wiki pages
3112             * @throws SystemException if a system exception occurred
3113             */
3114            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId,
3115                    int start, int end) throws SystemException {
3116                    return findByR_N(resourcePrimKey, nodeId, start, end, null);
3117            }
3118    
3119            /**
3120             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
3121             *
3122             * <p>
3123             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3124             * </p>
3125             *
3126             * @param resourcePrimKey the resource prim key
3127             * @param nodeId the node ID
3128             * @param start the lower bound of the range of wiki pages
3129             * @param end the upper bound of the range of wiki pages (not inclusive)
3130             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3131             * @return the ordered range of matching wiki pages
3132             * @throws SystemException if a system exception occurred
3133             */
3134            public List<WikiPage> findByR_N(long resourcePrimKey, long nodeId,
3135                    int start, int end, OrderByComparator orderByComparator)
3136                    throws SystemException {
3137                    FinderPath finderPath = null;
3138                    Object[] finderArgs = null;
3139    
3140                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3141                                    (orderByComparator == null)) {
3142                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N;
3143                            finderArgs = new Object[] { resourcePrimKey, nodeId };
3144                    }
3145                    else {
3146                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N;
3147                            finderArgs = new Object[] {
3148                                            resourcePrimKey, nodeId,
3149                                            
3150                                            start, end, orderByComparator
3151                                    };
3152                    }
3153    
3154                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
3155                                    finderArgs, this);
3156    
3157                    if ((list != null) && !list.isEmpty()) {
3158                            for (WikiPage wikiPage : list) {
3159                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
3160                                                    (nodeId != wikiPage.getNodeId())) {
3161                                            list = null;
3162    
3163                                            break;
3164                                    }
3165                            }
3166                    }
3167    
3168                    if (list == null) {
3169                            StringBundler query = null;
3170    
3171                            if (orderByComparator != null) {
3172                                    query = new StringBundler(4 +
3173                                                    (orderByComparator.getOrderByFields().length * 3));
3174                            }
3175                            else {
3176                                    query = new StringBundler(4);
3177                            }
3178    
3179                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3180    
3181                            query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
3182    
3183                            query.append(_FINDER_COLUMN_R_N_NODEID_2);
3184    
3185                            if (orderByComparator != null) {
3186                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3187                                            orderByComparator);
3188                            }
3189    
3190                            else {
3191                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3192                            }
3193    
3194                            String sql = query.toString();
3195    
3196                            Session session = null;
3197    
3198                            try {
3199                                    session = openSession();
3200    
3201                                    Query q = session.createQuery(sql);
3202    
3203                                    QueryPos qPos = QueryPos.getInstance(q);
3204    
3205                                    qPos.add(resourcePrimKey);
3206    
3207                                    qPos.add(nodeId);
3208    
3209                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
3210                                                    end);
3211                            }
3212                            catch (Exception e) {
3213                                    throw processException(e);
3214                            }
3215                            finally {
3216                                    if (list == null) {
3217                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3218                                    }
3219                                    else {
3220                                            cacheResult(list);
3221    
3222                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3223                                    }
3224    
3225                                    closeSession(session);
3226                            }
3227                    }
3228    
3229                    return list;
3230            }
3231    
3232            /**
3233             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3234             *
3235             * @param resourcePrimKey the resource prim key
3236             * @param nodeId the node ID
3237             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3238             * @return the first matching wiki page
3239             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3240             * @throws SystemException if a system exception occurred
3241             */
3242            public WikiPage findByR_N_First(long resourcePrimKey, long nodeId,
3243                    OrderByComparator orderByComparator)
3244                    throws NoSuchPageException, SystemException {
3245                    WikiPage wikiPage = fetchByR_N_First(resourcePrimKey, nodeId,
3246                                    orderByComparator);
3247    
3248                    if (wikiPage != null) {
3249                            return wikiPage;
3250                    }
3251    
3252                    StringBundler msg = new StringBundler(6);
3253    
3254                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3255    
3256                    msg.append("resourcePrimKey=");
3257                    msg.append(resourcePrimKey);
3258    
3259                    msg.append(", nodeId=");
3260                    msg.append(nodeId);
3261    
3262                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3263    
3264                    throw new NoSuchPageException(msg.toString());
3265            }
3266    
3267            /**
3268             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3269             *
3270             * @param resourcePrimKey the resource prim key
3271             * @param nodeId the node ID
3272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3273             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
3274             * @throws SystemException if a system exception occurred
3275             */
3276            public WikiPage fetchByR_N_First(long resourcePrimKey, long nodeId,
3277                    OrderByComparator orderByComparator) throws SystemException {
3278                    List<WikiPage> list = findByR_N(resourcePrimKey, nodeId, 0, 1,
3279                                    orderByComparator);
3280    
3281                    if (!list.isEmpty()) {
3282                            return list.get(0);
3283                    }
3284    
3285                    return null;
3286            }
3287    
3288            /**
3289             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3290             *
3291             * @param resourcePrimKey the resource prim key
3292             * @param nodeId the node ID
3293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3294             * @return the last matching wiki page
3295             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3296             * @throws SystemException if a system exception occurred
3297             */
3298            public WikiPage findByR_N_Last(long resourcePrimKey, long nodeId,
3299                    OrderByComparator orderByComparator)
3300                    throws NoSuchPageException, SystemException {
3301                    WikiPage wikiPage = fetchByR_N_Last(resourcePrimKey, nodeId,
3302                                    orderByComparator);
3303    
3304                    if (wikiPage != null) {
3305                            return wikiPage;
3306                    }
3307    
3308                    StringBundler msg = new StringBundler(6);
3309    
3310                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3311    
3312                    msg.append("resourcePrimKey=");
3313                    msg.append(resourcePrimKey);
3314    
3315                    msg.append(", nodeId=");
3316                    msg.append(nodeId);
3317    
3318                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3319    
3320                    throw new NoSuchPageException(msg.toString());
3321            }
3322    
3323            /**
3324             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3325             *
3326             * @param resourcePrimKey the resource prim key
3327             * @param nodeId the node ID
3328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3329             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
3330             * @throws SystemException if a system exception occurred
3331             */
3332            public WikiPage fetchByR_N_Last(long resourcePrimKey, long nodeId,
3333                    OrderByComparator orderByComparator) throws SystemException {
3334                    int count = countByR_N(resourcePrimKey, nodeId);
3335    
3336                    List<WikiPage> list = findByR_N(resourcePrimKey, nodeId, count - 1,
3337                                    count, orderByComparator);
3338    
3339                    if (!list.isEmpty()) {
3340                            return list.get(0);
3341                    }
3342    
3343                    return null;
3344            }
3345    
3346            /**
3347             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63;.
3348             *
3349             * @param pageId the primary key of the current wiki page
3350             * @param resourcePrimKey the resource prim key
3351             * @param nodeId the node ID
3352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3353             * @return the previous, current, and next wiki page
3354             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
3355             * @throws SystemException if a system exception occurred
3356             */
3357            public WikiPage[] findByR_N_PrevAndNext(long pageId, long resourcePrimKey,
3358                    long nodeId, OrderByComparator orderByComparator)
3359                    throws NoSuchPageException, SystemException {
3360                    WikiPage wikiPage = findByPrimaryKey(pageId);
3361    
3362                    Session session = null;
3363    
3364                    try {
3365                            session = openSession();
3366    
3367                            WikiPage[] array = new WikiPageImpl[3];
3368    
3369                            array[0] = getByR_N_PrevAndNext(session, wikiPage, resourcePrimKey,
3370                                            nodeId, orderByComparator, true);
3371    
3372                            array[1] = wikiPage;
3373    
3374                            array[2] = getByR_N_PrevAndNext(session, wikiPage, resourcePrimKey,
3375                                            nodeId, orderByComparator, false);
3376    
3377                            return array;
3378                    }
3379                    catch (Exception e) {
3380                            throw processException(e);
3381                    }
3382                    finally {
3383                            closeSession(session);
3384                    }
3385            }
3386    
3387            protected WikiPage getByR_N_PrevAndNext(Session session, WikiPage wikiPage,
3388                    long resourcePrimKey, long nodeId, OrderByComparator orderByComparator,
3389                    boolean previous) {
3390                    StringBundler query = null;
3391    
3392                    if (orderByComparator != null) {
3393                            query = new StringBundler(6 +
3394                                            (orderByComparator.getOrderByFields().length * 6));
3395                    }
3396                    else {
3397                            query = new StringBundler(3);
3398                    }
3399    
3400                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3401    
3402                    query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
3403    
3404                    query.append(_FINDER_COLUMN_R_N_NODEID_2);
3405    
3406                    if (orderByComparator != null) {
3407                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3408    
3409                            if (orderByConditionFields.length > 0) {
3410                                    query.append(WHERE_AND);
3411                            }
3412    
3413                            for (int i = 0; i < orderByConditionFields.length; i++) {
3414                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3415                                    query.append(orderByConditionFields[i]);
3416    
3417                                    if ((i + 1) < orderByConditionFields.length) {
3418                                            if (orderByComparator.isAscending() ^ previous) {
3419                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3420                                            }
3421                                            else {
3422                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3423                                            }
3424                                    }
3425                                    else {
3426                                            if (orderByComparator.isAscending() ^ previous) {
3427                                                    query.append(WHERE_GREATER_THAN);
3428                                            }
3429                                            else {
3430                                                    query.append(WHERE_LESSER_THAN);
3431                                            }
3432                                    }
3433                            }
3434    
3435                            query.append(ORDER_BY_CLAUSE);
3436    
3437                            String[] orderByFields = orderByComparator.getOrderByFields();
3438    
3439                            for (int i = 0; i < orderByFields.length; i++) {
3440                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3441                                    query.append(orderByFields[i]);
3442    
3443                                    if ((i + 1) < orderByFields.length) {
3444                                            if (orderByComparator.isAscending() ^ previous) {
3445                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3446                                            }
3447                                            else {
3448                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3449                                            }
3450                                    }
3451                                    else {
3452                                            if (orderByComparator.isAscending() ^ previous) {
3453                                                    query.append(ORDER_BY_ASC);
3454                                            }
3455                                            else {
3456                                                    query.append(ORDER_BY_DESC);
3457                                            }
3458                                    }
3459                            }
3460                    }
3461    
3462                    else {
3463                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3464                    }
3465    
3466                    String sql = query.toString();
3467    
3468                    Query q = session.createQuery(sql);
3469    
3470                    q.setFirstResult(0);
3471                    q.setMaxResults(2);
3472    
3473                    QueryPos qPos = QueryPos.getInstance(q);
3474    
3475                    qPos.add(resourcePrimKey);
3476    
3477                    qPos.add(nodeId);
3478    
3479                    if (orderByComparator != null) {
3480                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
3481    
3482                            for (Object value : values) {
3483                                    qPos.add(value);
3484                            }
3485                    }
3486    
3487                    List<WikiPage> list = q.list();
3488    
3489                    if (list.size() == 2) {
3490                            return list.get(1);
3491                    }
3492                    else {
3493                            return null;
3494                    }
3495            }
3496    
3497            /**
3498             * Returns all the wiki pages where nodeId = &#63; and title = &#63;.
3499             *
3500             * @param nodeId the node ID
3501             * @param title the title
3502             * @return the matching wiki pages
3503             * @throws SystemException if a system exception occurred
3504             */
3505            public List<WikiPage> findByN_T(long nodeId, String title)
3506                    throws SystemException {
3507                    return findByN_T(nodeId, title, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3508                            null);
3509            }
3510    
3511            /**
3512             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63;.
3513             *
3514             * <p>
3515             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3516             * </p>
3517             *
3518             * @param nodeId the node ID
3519             * @param title the title
3520             * @param start the lower bound of the range of wiki pages
3521             * @param end the upper bound of the range of wiki pages (not inclusive)
3522             * @return the range of matching wiki pages
3523             * @throws SystemException if a system exception occurred
3524             */
3525            public List<WikiPage> findByN_T(long nodeId, String title, int start,
3526                    int end) throws SystemException {
3527                    return findByN_T(nodeId, title, start, end, null);
3528            }
3529    
3530            /**
3531             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63;.
3532             *
3533             * <p>
3534             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3535             * </p>
3536             *
3537             * @param nodeId the node ID
3538             * @param title the title
3539             * @param start the lower bound of the range of wiki pages
3540             * @param end the upper bound of the range of wiki pages (not inclusive)
3541             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3542             * @return the ordered range of matching wiki pages
3543             * @throws SystemException if a system exception occurred
3544             */
3545            public List<WikiPage> findByN_T(long nodeId, String title, int start,
3546                    int end, OrderByComparator orderByComparator) throws SystemException {
3547                    FinderPath finderPath = null;
3548                    Object[] finderArgs = null;
3549    
3550                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3551                                    (orderByComparator == null)) {
3552                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T;
3553                            finderArgs = new Object[] { nodeId, title };
3554                    }
3555                    else {
3556                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T;
3557                            finderArgs = new Object[] {
3558                                            nodeId, title,
3559                                            
3560                                            start, end, orderByComparator
3561                                    };
3562                    }
3563    
3564                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
3565                                    finderArgs, this);
3566    
3567                    if ((list != null) && !list.isEmpty()) {
3568                            for (WikiPage wikiPage : list) {
3569                                    if ((nodeId != wikiPage.getNodeId()) ||
3570                                                    !Validator.equals(title, wikiPage.getTitle())) {
3571                                            list = null;
3572    
3573                                            break;
3574                                    }
3575                            }
3576                    }
3577    
3578                    if (list == null) {
3579                            StringBundler query = null;
3580    
3581                            if (orderByComparator != null) {
3582                                    query = new StringBundler(4 +
3583                                                    (orderByComparator.getOrderByFields().length * 3));
3584                            }
3585                            else {
3586                                    query = new StringBundler(4);
3587                            }
3588    
3589                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3590    
3591                            query.append(_FINDER_COLUMN_N_T_NODEID_2);
3592    
3593                            if (title == null) {
3594                                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
3595                            }
3596                            else {
3597                                    if (title.equals(StringPool.BLANK)) {
3598                                            query.append(_FINDER_COLUMN_N_T_TITLE_3);
3599                                    }
3600                                    else {
3601                                            query.append(_FINDER_COLUMN_N_T_TITLE_2);
3602                                    }
3603                            }
3604    
3605                            if (orderByComparator != null) {
3606                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3607                                            orderByComparator);
3608                            }
3609    
3610                            else {
3611                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3612                            }
3613    
3614                            String sql = query.toString();
3615    
3616                            Session session = null;
3617    
3618                            try {
3619                                    session = openSession();
3620    
3621                                    Query q = session.createQuery(sql);
3622    
3623                                    QueryPos qPos = QueryPos.getInstance(q);
3624    
3625                                    qPos.add(nodeId);
3626    
3627                                    if (title != null) {
3628                                            qPos.add(title);
3629                                    }
3630    
3631                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
3632                                                    end);
3633                            }
3634                            catch (Exception e) {
3635                                    throw processException(e);
3636                            }
3637                            finally {
3638                                    if (list == null) {
3639                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3640                                    }
3641                                    else {
3642                                            cacheResult(list);
3643    
3644                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3645                                    }
3646    
3647                                    closeSession(session);
3648                            }
3649                    }
3650    
3651                    return list;
3652            }
3653    
3654            /**
3655             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3656             *
3657             * @param nodeId the node ID
3658             * @param title the title
3659             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3660             * @return the first matching wiki page
3661             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3662             * @throws SystemException if a system exception occurred
3663             */
3664            public WikiPage findByN_T_First(long nodeId, String title,
3665                    OrderByComparator orderByComparator)
3666                    throws NoSuchPageException, SystemException {
3667                    WikiPage wikiPage = fetchByN_T_First(nodeId, title, orderByComparator);
3668    
3669                    if (wikiPage != null) {
3670                            return wikiPage;
3671                    }
3672    
3673                    StringBundler msg = new StringBundler(6);
3674    
3675                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3676    
3677                    msg.append("nodeId=");
3678                    msg.append(nodeId);
3679    
3680                    msg.append(", title=");
3681                    msg.append(title);
3682    
3683                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3684    
3685                    throw new NoSuchPageException(msg.toString());
3686            }
3687    
3688            /**
3689             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3690             *
3691             * @param nodeId the node ID
3692             * @param title the title
3693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3694             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
3695             * @throws SystemException if a system exception occurred
3696             */
3697            public WikiPage fetchByN_T_First(long nodeId, String title,
3698                    OrderByComparator orderByComparator) throws SystemException {
3699                    List<WikiPage> list = findByN_T(nodeId, title, 0, 1, orderByComparator);
3700    
3701                    if (!list.isEmpty()) {
3702                            return list.get(0);
3703                    }
3704    
3705                    return null;
3706            }
3707    
3708            /**
3709             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3710             *
3711             * @param nodeId the node ID
3712             * @param title the title
3713             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3714             * @return the last matching wiki page
3715             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
3716             * @throws SystemException if a system exception occurred
3717             */
3718            public WikiPage findByN_T_Last(long nodeId, String title,
3719                    OrderByComparator orderByComparator)
3720                    throws NoSuchPageException, SystemException {
3721                    WikiPage wikiPage = fetchByN_T_Last(nodeId, title, orderByComparator);
3722    
3723                    if (wikiPage != null) {
3724                            return wikiPage;
3725                    }
3726    
3727                    StringBundler msg = new StringBundler(6);
3728    
3729                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3730    
3731                    msg.append("nodeId=");
3732                    msg.append(nodeId);
3733    
3734                    msg.append(", title=");
3735                    msg.append(title);
3736    
3737                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3738    
3739                    throw new NoSuchPageException(msg.toString());
3740            }
3741    
3742            /**
3743             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3744             *
3745             * @param nodeId the node ID
3746             * @param title the title
3747             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3748             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
3749             * @throws SystemException if a system exception occurred
3750             */
3751            public WikiPage fetchByN_T_Last(long nodeId, String title,
3752                    OrderByComparator orderByComparator) throws SystemException {
3753                    int count = countByN_T(nodeId, title);
3754    
3755                    List<WikiPage> list = findByN_T(nodeId, title, count - 1, count,
3756                                    orderByComparator);
3757    
3758                    if (!list.isEmpty()) {
3759                            return list.get(0);
3760                    }
3761    
3762                    return null;
3763            }
3764    
3765            /**
3766             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63;.
3767             *
3768             * @param pageId the primary key of the current wiki page
3769             * @param nodeId the node ID
3770             * @param title the title
3771             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3772             * @return the previous, current, and next wiki page
3773             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
3774             * @throws SystemException if a system exception occurred
3775             */
3776            public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
3777                    String title, OrderByComparator orderByComparator)
3778                    throws NoSuchPageException, SystemException {
3779                    WikiPage wikiPage = findByPrimaryKey(pageId);
3780    
3781                    Session session = null;
3782    
3783                    try {
3784                            session = openSession();
3785    
3786                            WikiPage[] array = new WikiPageImpl[3];
3787    
3788                            array[0] = getByN_T_PrevAndNext(session, wikiPage, nodeId, title,
3789                                            orderByComparator, true);
3790    
3791                            array[1] = wikiPage;
3792    
3793                            array[2] = getByN_T_PrevAndNext(session, wikiPage, nodeId, title,
3794                                            orderByComparator, false);
3795    
3796                            return array;
3797                    }
3798                    catch (Exception e) {
3799                            throw processException(e);
3800                    }
3801                    finally {
3802                            closeSession(session);
3803                    }
3804            }
3805    
3806            protected WikiPage getByN_T_PrevAndNext(Session session, WikiPage wikiPage,
3807                    long nodeId, String title, OrderByComparator orderByComparator,
3808                    boolean previous) {
3809                    StringBundler query = null;
3810    
3811                    if (orderByComparator != null) {
3812                            query = new StringBundler(6 +
3813                                            (orderByComparator.getOrderByFields().length * 6));
3814                    }
3815                    else {
3816                            query = new StringBundler(3);
3817                    }
3818    
3819                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3820    
3821                    query.append(_FINDER_COLUMN_N_T_NODEID_2);
3822    
3823                    if (title == null) {
3824                            query.append(_FINDER_COLUMN_N_T_TITLE_1);
3825                    }
3826                    else {
3827                            if (title.equals(StringPool.BLANK)) {
3828                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
3829                            }
3830                            else {
3831                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
3832                            }
3833                    }
3834    
3835                    if (orderByComparator != null) {
3836                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3837    
3838                            if (orderByConditionFields.length > 0) {
3839                                    query.append(WHERE_AND);
3840                            }
3841    
3842                            for (int i = 0; i < orderByConditionFields.length; i++) {
3843                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3844                                    query.append(orderByConditionFields[i]);
3845    
3846                                    if ((i + 1) < orderByConditionFields.length) {
3847                                            if (orderByComparator.isAscending() ^ previous) {
3848                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3849                                            }
3850                                            else {
3851                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3852                                            }
3853                                    }
3854                                    else {
3855                                            if (orderByComparator.isAscending() ^ previous) {
3856                                                    query.append(WHERE_GREATER_THAN);
3857                                            }
3858                                            else {
3859                                                    query.append(WHERE_LESSER_THAN);
3860                                            }
3861                                    }
3862                            }
3863    
3864                            query.append(ORDER_BY_CLAUSE);
3865    
3866                            String[] orderByFields = orderByComparator.getOrderByFields();
3867    
3868                            for (int i = 0; i < orderByFields.length; i++) {
3869                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3870                                    query.append(orderByFields[i]);
3871    
3872                                    if ((i + 1) < orderByFields.length) {
3873                                            if (orderByComparator.isAscending() ^ previous) {
3874                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3875                                            }
3876                                            else {
3877                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3878                                            }
3879                                    }
3880                                    else {
3881                                            if (orderByComparator.isAscending() ^ previous) {
3882                                                    query.append(ORDER_BY_ASC);
3883                                            }
3884                                            else {
3885                                                    query.append(ORDER_BY_DESC);
3886                                            }
3887                                    }
3888                            }
3889                    }
3890    
3891                    else {
3892                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3893                    }
3894    
3895                    String sql = query.toString();
3896    
3897                    Query q = session.createQuery(sql);
3898    
3899                    q.setFirstResult(0);
3900                    q.setMaxResults(2);
3901    
3902                    QueryPos qPos = QueryPos.getInstance(q);
3903    
3904                    qPos.add(nodeId);
3905    
3906                    if (title != null) {
3907                            qPos.add(title);
3908                    }
3909    
3910                    if (orderByComparator != null) {
3911                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
3912    
3913                            for (Object value : values) {
3914                                    qPos.add(value);
3915                            }
3916                    }
3917    
3918                    List<WikiPage> list = q.list();
3919    
3920                    if (list.size() == 2) {
3921                            return list.get(1);
3922                    }
3923                    else {
3924                            return null;
3925                    }
3926            }
3927    
3928            /**
3929             * Returns all the wiki pages where nodeId = &#63; and head = &#63;.
3930             *
3931             * @param nodeId the node ID
3932             * @param head the head
3933             * @return the matching wiki pages
3934             * @throws SystemException if a system exception occurred
3935             */
3936            public List<WikiPage> findByN_H(long nodeId, boolean head)
3937                    throws SystemException {
3938                    return findByN_H(nodeId, head, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3939                            null);
3940            }
3941    
3942            /**
3943             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63;.
3944             *
3945             * <p>
3946             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3947             * </p>
3948             *
3949             * @param nodeId the node ID
3950             * @param head the head
3951             * @param start the lower bound of the range of wiki pages
3952             * @param end the upper bound of the range of wiki pages (not inclusive)
3953             * @return the range of matching wiki pages
3954             * @throws SystemException if a system exception occurred
3955             */
3956            public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
3957                    int end) throws SystemException {
3958                    return findByN_H(nodeId, head, start, end, null);
3959            }
3960    
3961            /**
3962             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63;.
3963             *
3964             * <p>
3965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3966             * </p>
3967             *
3968             * @param nodeId the node ID
3969             * @param head the head
3970             * @param start the lower bound of the range of wiki pages
3971             * @param end the upper bound of the range of wiki pages (not inclusive)
3972             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3973             * @return the ordered range of matching wiki pages
3974             * @throws SystemException if a system exception occurred
3975             */
3976            public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
3977                    int end, OrderByComparator orderByComparator) throws SystemException {
3978                    FinderPath finderPath = null;
3979                    Object[] finderArgs = null;
3980    
3981                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3982                                    (orderByComparator == null)) {
3983                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H;
3984                            finderArgs = new Object[] { nodeId, head };
3985                    }
3986                    else {
3987                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H;
3988                            finderArgs = new Object[] {
3989                                            nodeId, head,
3990                                            
3991                                            start, end, orderByComparator
3992                                    };
3993                    }
3994    
3995                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
3996                                    finderArgs, this);
3997    
3998                    if ((list != null) && !list.isEmpty()) {
3999                            for (WikiPage wikiPage : list) {
4000                                    if ((nodeId != wikiPage.getNodeId()) ||
4001                                                    (head != wikiPage.getHead())) {
4002                                            list = null;
4003    
4004                                            break;
4005                                    }
4006                            }
4007                    }
4008    
4009                    if (list == null) {
4010                            StringBundler query = null;
4011    
4012                            if (orderByComparator != null) {
4013                                    query = new StringBundler(4 +
4014                                                    (orderByComparator.getOrderByFields().length * 3));
4015                            }
4016                            else {
4017                                    query = new StringBundler(4);
4018                            }
4019    
4020                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4021    
4022                            query.append(_FINDER_COLUMN_N_H_NODEID_2);
4023    
4024                            query.append(_FINDER_COLUMN_N_H_HEAD_2);
4025    
4026                            if (orderByComparator != null) {
4027                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4028                                            orderByComparator);
4029                            }
4030    
4031                            else {
4032                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4033                            }
4034    
4035                            String sql = query.toString();
4036    
4037                            Session session = null;
4038    
4039                            try {
4040                                    session = openSession();
4041    
4042                                    Query q = session.createQuery(sql);
4043    
4044                                    QueryPos qPos = QueryPos.getInstance(q);
4045    
4046                                    qPos.add(nodeId);
4047    
4048                                    qPos.add(head);
4049    
4050                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
4051                                                    end);
4052                            }
4053                            catch (Exception e) {
4054                                    throw processException(e);
4055                            }
4056                            finally {
4057                                    if (list == null) {
4058                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4059                                    }
4060                                    else {
4061                                            cacheResult(list);
4062    
4063                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4064                                    }
4065    
4066                                    closeSession(session);
4067                            }
4068                    }
4069    
4070                    return list;
4071            }
4072    
4073            /**
4074             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4075             *
4076             * @param nodeId the node ID
4077             * @param head the head
4078             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4079             * @return the first matching wiki page
4080             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4081             * @throws SystemException if a system exception occurred
4082             */
4083            public WikiPage findByN_H_First(long nodeId, boolean head,
4084                    OrderByComparator orderByComparator)
4085                    throws NoSuchPageException, SystemException {
4086                    WikiPage wikiPage = fetchByN_H_First(nodeId, head, orderByComparator);
4087    
4088                    if (wikiPage != null) {
4089                            return wikiPage;
4090                    }
4091    
4092                    StringBundler msg = new StringBundler(6);
4093    
4094                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4095    
4096                    msg.append("nodeId=");
4097                    msg.append(nodeId);
4098    
4099                    msg.append(", head=");
4100                    msg.append(head);
4101    
4102                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4103    
4104                    throw new NoSuchPageException(msg.toString());
4105            }
4106    
4107            /**
4108             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4109             *
4110             * @param nodeId the node ID
4111             * @param head the head
4112             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4113             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
4114             * @throws SystemException if a system exception occurred
4115             */
4116            public WikiPage fetchByN_H_First(long nodeId, boolean head,
4117                    OrderByComparator orderByComparator) throws SystemException {
4118                    List<WikiPage> list = findByN_H(nodeId, head, 0, 1, orderByComparator);
4119    
4120                    if (!list.isEmpty()) {
4121                            return list.get(0);
4122                    }
4123    
4124                    return null;
4125            }
4126    
4127            /**
4128             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4129             *
4130             * @param nodeId the node ID
4131             * @param head the head
4132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4133             * @return the last matching wiki page
4134             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4135             * @throws SystemException if a system exception occurred
4136             */
4137            public WikiPage findByN_H_Last(long nodeId, boolean head,
4138                    OrderByComparator orderByComparator)
4139                    throws NoSuchPageException, SystemException {
4140                    WikiPage wikiPage = fetchByN_H_Last(nodeId, head, orderByComparator);
4141    
4142                    if (wikiPage != null) {
4143                            return wikiPage;
4144                    }
4145    
4146                    StringBundler msg = new StringBundler(6);
4147    
4148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4149    
4150                    msg.append("nodeId=");
4151                    msg.append(nodeId);
4152    
4153                    msg.append(", head=");
4154                    msg.append(head);
4155    
4156                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4157    
4158                    throw new NoSuchPageException(msg.toString());
4159            }
4160    
4161            /**
4162             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4163             *
4164             * @param nodeId the node ID
4165             * @param head the head
4166             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4167             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
4168             * @throws SystemException if a system exception occurred
4169             */
4170            public WikiPage fetchByN_H_Last(long nodeId, boolean head,
4171                    OrderByComparator orderByComparator) throws SystemException {
4172                    int count = countByN_H(nodeId, head);
4173    
4174                    List<WikiPage> list = findByN_H(nodeId, head, count - 1, count,
4175                                    orderByComparator);
4176    
4177                    if (!list.isEmpty()) {
4178                            return list.get(0);
4179                    }
4180    
4181                    return null;
4182            }
4183    
4184            /**
4185             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63;.
4186             *
4187             * @param pageId the primary key of the current wiki page
4188             * @param nodeId the node ID
4189             * @param head the head
4190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4191             * @return the previous, current, and next wiki page
4192             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
4193             * @throws SystemException if a system exception occurred
4194             */
4195            public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
4196                    boolean head, OrderByComparator orderByComparator)
4197                    throws NoSuchPageException, SystemException {
4198                    WikiPage wikiPage = findByPrimaryKey(pageId);
4199    
4200                    Session session = null;
4201    
4202                    try {
4203                            session = openSession();
4204    
4205                            WikiPage[] array = new WikiPageImpl[3];
4206    
4207                            array[0] = getByN_H_PrevAndNext(session, wikiPage, nodeId, head,
4208                                            orderByComparator, true);
4209    
4210                            array[1] = wikiPage;
4211    
4212                            array[2] = getByN_H_PrevAndNext(session, wikiPage, nodeId, head,
4213                                            orderByComparator, false);
4214    
4215                            return array;
4216                    }
4217                    catch (Exception e) {
4218                            throw processException(e);
4219                    }
4220                    finally {
4221                            closeSession(session);
4222                    }
4223            }
4224    
4225            protected WikiPage getByN_H_PrevAndNext(Session session, WikiPage wikiPage,
4226                    long nodeId, boolean head, OrderByComparator orderByComparator,
4227                    boolean previous) {
4228                    StringBundler query = null;
4229    
4230                    if (orderByComparator != null) {
4231                            query = new StringBundler(6 +
4232                                            (orderByComparator.getOrderByFields().length * 6));
4233                    }
4234                    else {
4235                            query = new StringBundler(3);
4236                    }
4237    
4238                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4239    
4240                    query.append(_FINDER_COLUMN_N_H_NODEID_2);
4241    
4242                    query.append(_FINDER_COLUMN_N_H_HEAD_2);
4243    
4244                    if (orderByComparator != null) {
4245                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4246    
4247                            if (orderByConditionFields.length > 0) {
4248                                    query.append(WHERE_AND);
4249                            }
4250    
4251                            for (int i = 0; i < orderByConditionFields.length; i++) {
4252                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4253                                    query.append(orderByConditionFields[i]);
4254    
4255                                    if ((i + 1) < orderByConditionFields.length) {
4256                                            if (orderByComparator.isAscending() ^ previous) {
4257                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4258                                            }
4259                                            else {
4260                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4261                                            }
4262                                    }
4263                                    else {
4264                                            if (orderByComparator.isAscending() ^ previous) {
4265                                                    query.append(WHERE_GREATER_THAN);
4266                                            }
4267                                            else {
4268                                                    query.append(WHERE_LESSER_THAN);
4269                                            }
4270                                    }
4271                            }
4272    
4273                            query.append(ORDER_BY_CLAUSE);
4274    
4275                            String[] orderByFields = orderByComparator.getOrderByFields();
4276    
4277                            for (int i = 0; i < orderByFields.length; i++) {
4278                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4279                                    query.append(orderByFields[i]);
4280    
4281                                    if ((i + 1) < orderByFields.length) {
4282                                            if (orderByComparator.isAscending() ^ previous) {
4283                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4284                                            }
4285                                            else {
4286                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4287                                            }
4288                                    }
4289                                    else {
4290                                            if (orderByComparator.isAscending() ^ previous) {
4291                                                    query.append(ORDER_BY_ASC);
4292                                            }
4293                                            else {
4294                                                    query.append(ORDER_BY_DESC);
4295                                            }
4296                                    }
4297                            }
4298                    }
4299    
4300                    else {
4301                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4302                    }
4303    
4304                    String sql = query.toString();
4305    
4306                    Query q = session.createQuery(sql);
4307    
4308                    q.setFirstResult(0);
4309                    q.setMaxResults(2);
4310    
4311                    QueryPos qPos = QueryPos.getInstance(q);
4312    
4313                    qPos.add(nodeId);
4314    
4315                    qPos.add(head);
4316    
4317                    if (orderByComparator != null) {
4318                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
4319    
4320                            for (Object value : values) {
4321                                    qPos.add(value);
4322                            }
4323                    }
4324    
4325                    List<WikiPage> list = q.list();
4326    
4327                    if (list.size() == 2) {
4328                            return list.get(1);
4329                    }
4330                    else {
4331                            return null;
4332                    }
4333            }
4334    
4335            /**
4336             * Returns all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
4337             *
4338             * @param nodeId the node ID
4339             * @param parentTitle the parent title
4340             * @return the matching wiki pages
4341             * @throws SystemException if a system exception occurred
4342             */
4343            public List<WikiPage> findByN_P(long nodeId, String parentTitle)
4344                    throws SystemException {
4345                    return findByN_P(nodeId, parentTitle, QueryUtil.ALL_POS,
4346                            QueryUtil.ALL_POS, null);
4347            }
4348    
4349            /**
4350             * Returns a range of all the wiki pages where nodeId = &#63; and parentTitle = &#63;.
4351             *
4352             * <p>
4353             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4354             * </p>
4355             *
4356             * @param nodeId the node ID
4357             * @param parentTitle the parent title
4358             * @param start the lower bound of the range of wiki pages
4359             * @param end the upper bound of the range of wiki pages (not inclusive)
4360             * @return the range of matching wiki pages
4361             * @throws SystemException if a system exception occurred
4362             */
4363            public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
4364                    int end) throws SystemException {
4365                    return findByN_P(nodeId, parentTitle, start, end, null);
4366            }
4367    
4368            /**
4369             * Returns an ordered range of all the wiki pages where nodeId = &#63; and parentTitle = &#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 parentTitle the parent title
4377             * @param start the lower bound of the range of wiki pages
4378             * @param end the upper bound of the range of wiki pages (not inclusive)
4379             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4380             * @return the ordered range of matching wiki pages
4381             * @throws SystemException if a system exception occurred
4382             */
4383            public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
4384                    int end, OrderByComparator orderByComparator) throws SystemException {
4385                    FinderPath finderPath = null;
4386                    Object[] finderArgs = null;
4387    
4388                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4389                                    (orderByComparator == null)) {
4390                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_P;
4391                            finderArgs = new Object[] { nodeId, parentTitle };
4392                    }
4393                    else {
4394                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_P;
4395                            finderArgs = new Object[] {
4396                                            nodeId, parentTitle,
4397                                            
4398                                            start, end, orderByComparator
4399                                    };
4400                    }
4401    
4402                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
4403                                    finderArgs, this);
4404    
4405                    if ((list != null) && !list.isEmpty()) {
4406                            for (WikiPage wikiPage : list) {
4407                                    if ((nodeId != wikiPage.getNodeId()) ||
4408                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle())) {
4409                                            list = null;
4410    
4411                                            break;
4412                                    }
4413                            }
4414                    }
4415    
4416                    if (list == null) {
4417                            StringBundler query = null;
4418    
4419                            if (orderByComparator != null) {
4420                                    query = new StringBundler(4 +
4421                                                    (orderByComparator.getOrderByFields().length * 3));
4422                            }
4423                            else {
4424                                    query = new StringBundler(4);
4425                            }
4426    
4427                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4428    
4429                            query.append(_FINDER_COLUMN_N_P_NODEID_2);
4430    
4431                            if (parentTitle == null) {
4432                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
4433                            }
4434                            else {
4435                                    if (parentTitle.equals(StringPool.BLANK)) {
4436                                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
4437                                    }
4438                                    else {
4439                                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
4440                                    }
4441                            }
4442    
4443                            if (orderByComparator != null) {
4444                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4445                                            orderByComparator);
4446                            }
4447    
4448                            else {
4449                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4450                            }
4451    
4452                            String sql = query.toString();
4453    
4454                            Session session = null;
4455    
4456                            try {
4457                                    session = openSession();
4458    
4459                                    Query q = session.createQuery(sql);
4460    
4461                                    QueryPos qPos = QueryPos.getInstance(q);
4462    
4463                                    qPos.add(nodeId);
4464    
4465                                    if (parentTitle != null) {
4466                                            qPos.add(parentTitle);
4467                                    }
4468    
4469                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
4470                                                    end);
4471                            }
4472                            catch (Exception e) {
4473                                    throw processException(e);
4474                            }
4475                            finally {
4476                                    if (list == null) {
4477                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4478                                    }
4479                                    else {
4480                                            cacheResult(list);
4481    
4482                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4483                                    }
4484    
4485                                    closeSession(session);
4486                            }
4487                    }
4488    
4489                    return list;
4490            }
4491    
4492            /**
4493             * Returns the first wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4494             *
4495             * @param nodeId the node ID
4496             * @param parentTitle the parent title
4497             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4498             * @return the first matching wiki page
4499             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4500             * @throws SystemException if a system exception occurred
4501             */
4502            public WikiPage findByN_P_First(long nodeId, String parentTitle,
4503                    OrderByComparator orderByComparator)
4504                    throws NoSuchPageException, SystemException {
4505                    WikiPage wikiPage = fetchByN_P_First(nodeId, parentTitle,
4506                                    orderByComparator);
4507    
4508                    if (wikiPage != null) {
4509                            return wikiPage;
4510                    }
4511    
4512                    StringBundler msg = new StringBundler(6);
4513    
4514                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4515    
4516                    msg.append("nodeId=");
4517                    msg.append(nodeId);
4518    
4519                    msg.append(", parentTitle=");
4520                    msg.append(parentTitle);
4521    
4522                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4523    
4524                    throw new NoSuchPageException(msg.toString());
4525            }
4526    
4527            /**
4528             * Returns the first wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4529             *
4530             * @param nodeId the node ID
4531             * @param parentTitle the parent title
4532             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4533             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
4534             * @throws SystemException if a system exception occurred
4535             */
4536            public WikiPage fetchByN_P_First(long nodeId, String parentTitle,
4537                    OrderByComparator orderByComparator) throws SystemException {
4538                    List<WikiPage> list = findByN_P(nodeId, parentTitle, 0, 1,
4539                                    orderByComparator);
4540    
4541                    if (!list.isEmpty()) {
4542                            return list.get(0);
4543                    }
4544    
4545                    return null;
4546            }
4547    
4548            /**
4549             * Returns the last wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4550             *
4551             * @param nodeId the node ID
4552             * @param parentTitle the parent title
4553             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4554             * @return the last matching wiki page
4555             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4556             * @throws SystemException if a system exception occurred
4557             */
4558            public WikiPage findByN_P_Last(long nodeId, String parentTitle,
4559                    OrderByComparator orderByComparator)
4560                    throws NoSuchPageException, SystemException {
4561                    WikiPage wikiPage = fetchByN_P_Last(nodeId, parentTitle,
4562                                    orderByComparator);
4563    
4564                    if (wikiPage != null) {
4565                            return wikiPage;
4566                    }
4567    
4568                    StringBundler msg = new StringBundler(6);
4569    
4570                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4571    
4572                    msg.append("nodeId=");
4573                    msg.append(nodeId);
4574    
4575                    msg.append(", parentTitle=");
4576                    msg.append(parentTitle);
4577    
4578                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4579    
4580                    throw new NoSuchPageException(msg.toString());
4581            }
4582    
4583            /**
4584             * Returns the last wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4585             *
4586             * @param nodeId the node ID
4587             * @param parentTitle the parent title
4588             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4589             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
4590             * @throws SystemException if a system exception occurred
4591             */
4592            public WikiPage fetchByN_P_Last(long nodeId, String parentTitle,
4593                    OrderByComparator orderByComparator) throws SystemException {
4594                    int count = countByN_P(nodeId, parentTitle);
4595    
4596                    List<WikiPage> list = findByN_P(nodeId, parentTitle, count - 1, count,
4597                                    orderByComparator);
4598    
4599                    if (!list.isEmpty()) {
4600                            return list.get(0);
4601                    }
4602    
4603                    return null;
4604            }
4605    
4606            /**
4607             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and parentTitle = &#63;.
4608             *
4609             * @param pageId the primary key of the current wiki page
4610             * @param nodeId the node ID
4611             * @param parentTitle the parent title
4612             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4613             * @return the previous, current, and next wiki page
4614             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
4615             * @throws SystemException if a system exception occurred
4616             */
4617            public WikiPage[] findByN_P_PrevAndNext(long pageId, long nodeId,
4618                    String parentTitle, OrderByComparator orderByComparator)
4619                    throws NoSuchPageException, SystemException {
4620                    WikiPage wikiPage = findByPrimaryKey(pageId);
4621    
4622                    Session session = null;
4623    
4624                    try {
4625                            session = openSession();
4626    
4627                            WikiPage[] array = new WikiPageImpl[3];
4628    
4629                            array[0] = getByN_P_PrevAndNext(session, wikiPage, nodeId,
4630                                            parentTitle, orderByComparator, true);
4631    
4632                            array[1] = wikiPage;
4633    
4634                            array[2] = getByN_P_PrevAndNext(session, wikiPage, nodeId,
4635                                            parentTitle, orderByComparator, false);
4636    
4637                            return array;
4638                    }
4639                    catch (Exception e) {
4640                            throw processException(e);
4641                    }
4642                    finally {
4643                            closeSession(session);
4644                    }
4645            }
4646    
4647            protected WikiPage getByN_P_PrevAndNext(Session session, WikiPage wikiPage,
4648                    long nodeId, String parentTitle, OrderByComparator orderByComparator,
4649                    boolean previous) {
4650                    StringBundler query = null;
4651    
4652                    if (orderByComparator != null) {
4653                            query = new StringBundler(6 +
4654                                            (orderByComparator.getOrderByFields().length * 6));
4655                    }
4656                    else {
4657                            query = new StringBundler(3);
4658                    }
4659    
4660                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4661    
4662                    query.append(_FINDER_COLUMN_N_P_NODEID_2);
4663    
4664                    if (parentTitle == null) {
4665                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
4666                    }
4667                    else {
4668                            if (parentTitle.equals(StringPool.BLANK)) {
4669                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
4670                            }
4671                            else {
4672                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
4673                            }
4674                    }
4675    
4676                    if (orderByComparator != null) {
4677                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4678    
4679                            if (orderByConditionFields.length > 0) {
4680                                    query.append(WHERE_AND);
4681                            }
4682    
4683                            for (int i = 0; i < orderByConditionFields.length; i++) {
4684                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4685                                    query.append(orderByConditionFields[i]);
4686    
4687                                    if ((i + 1) < orderByConditionFields.length) {
4688                                            if (orderByComparator.isAscending() ^ previous) {
4689                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4690                                            }
4691                                            else {
4692                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4693                                            }
4694                                    }
4695                                    else {
4696                                            if (orderByComparator.isAscending() ^ previous) {
4697                                                    query.append(WHERE_GREATER_THAN);
4698                                            }
4699                                            else {
4700                                                    query.append(WHERE_LESSER_THAN);
4701                                            }
4702                                    }
4703                            }
4704    
4705                            query.append(ORDER_BY_CLAUSE);
4706    
4707                            String[] orderByFields = orderByComparator.getOrderByFields();
4708    
4709                            for (int i = 0; i < orderByFields.length; i++) {
4710                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4711                                    query.append(orderByFields[i]);
4712    
4713                                    if ((i + 1) < orderByFields.length) {
4714                                            if (orderByComparator.isAscending() ^ previous) {
4715                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4716                                            }
4717                                            else {
4718                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4719                                            }
4720                                    }
4721                                    else {
4722                                            if (orderByComparator.isAscending() ^ previous) {
4723                                                    query.append(ORDER_BY_ASC);
4724                                            }
4725                                            else {
4726                                                    query.append(ORDER_BY_DESC);
4727                                            }
4728                                    }
4729                            }
4730                    }
4731    
4732                    else {
4733                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4734                    }
4735    
4736                    String sql = query.toString();
4737    
4738                    Query q = session.createQuery(sql);
4739    
4740                    q.setFirstResult(0);
4741                    q.setMaxResults(2);
4742    
4743                    QueryPos qPos = QueryPos.getInstance(q);
4744    
4745                    qPos.add(nodeId);
4746    
4747                    if (parentTitle != null) {
4748                            qPos.add(parentTitle);
4749                    }
4750    
4751                    if (orderByComparator != null) {
4752                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
4753    
4754                            for (Object value : values) {
4755                                    qPos.add(value);
4756                            }
4757                    }
4758    
4759                    List<WikiPage> list = q.list();
4760    
4761                    if (list.size() == 2) {
4762                            return list.get(1);
4763                    }
4764                    else {
4765                            return null;
4766                    }
4767            }
4768    
4769            /**
4770             * Returns all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
4771             *
4772             * @param nodeId the node ID
4773             * @param redirectTitle the redirect title
4774             * @return the matching wiki pages
4775             * @throws SystemException if a system exception occurred
4776             */
4777            public List<WikiPage> findByN_R(long nodeId, String redirectTitle)
4778                    throws SystemException {
4779                    return findByN_R(nodeId, redirectTitle, QueryUtil.ALL_POS,
4780                            QueryUtil.ALL_POS, null);
4781            }
4782    
4783            /**
4784             * Returns a range of all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
4785             *
4786             * <p>
4787             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4788             * </p>
4789             *
4790             * @param nodeId the node ID
4791             * @param redirectTitle the redirect title
4792             * @param start the lower bound of the range of wiki pages
4793             * @param end the upper bound of the range of wiki pages (not inclusive)
4794             * @return the range of matching wiki pages
4795             * @throws SystemException if a system exception occurred
4796             */
4797            public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
4798                    int start, int end) throws SystemException {
4799                    return findByN_R(nodeId, redirectTitle, start, end, null);
4800            }
4801    
4802            /**
4803             * Returns an ordered range of all the wiki pages where nodeId = &#63; and redirectTitle = &#63;.
4804             *
4805             * <p>
4806             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4807             * </p>
4808             *
4809             * @param nodeId the node ID
4810             * @param redirectTitle the redirect title
4811             * @param start the lower bound of the range of wiki pages
4812             * @param end the upper bound of the range of wiki pages (not inclusive)
4813             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4814             * @return the ordered range of matching wiki pages
4815             * @throws SystemException if a system exception occurred
4816             */
4817            public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
4818                    int start, int end, OrderByComparator orderByComparator)
4819                    throws SystemException {
4820                    FinderPath finderPath = null;
4821                    Object[] finderArgs = null;
4822    
4823                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4824                                    (orderByComparator == null)) {
4825                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_R;
4826                            finderArgs = new Object[] { nodeId, redirectTitle };
4827                    }
4828                    else {
4829                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_R;
4830                            finderArgs = new Object[] {
4831                                            nodeId, redirectTitle,
4832                                            
4833                                            start, end, orderByComparator
4834                                    };
4835                    }
4836    
4837                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
4838                                    finderArgs, this);
4839    
4840                    if ((list != null) && !list.isEmpty()) {
4841                            for (WikiPage wikiPage : list) {
4842                                    if ((nodeId != wikiPage.getNodeId()) ||
4843                                                    !Validator.equals(redirectTitle,
4844                                                            wikiPage.getRedirectTitle())) {
4845                                            list = null;
4846    
4847                                            break;
4848                                    }
4849                            }
4850                    }
4851    
4852                    if (list == null) {
4853                            StringBundler query = null;
4854    
4855                            if (orderByComparator != null) {
4856                                    query = new StringBundler(4 +
4857                                                    (orderByComparator.getOrderByFields().length * 3));
4858                            }
4859                            else {
4860                                    query = new StringBundler(4);
4861                            }
4862    
4863                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
4864    
4865                            query.append(_FINDER_COLUMN_N_R_NODEID_2);
4866    
4867                            if (redirectTitle == null) {
4868                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
4869                            }
4870                            else {
4871                                    if (redirectTitle.equals(StringPool.BLANK)) {
4872                                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
4873                                    }
4874                                    else {
4875                                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
4876                                    }
4877                            }
4878    
4879                            if (orderByComparator != null) {
4880                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4881                                            orderByComparator);
4882                            }
4883    
4884                            else {
4885                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
4886                            }
4887    
4888                            String sql = query.toString();
4889    
4890                            Session session = null;
4891    
4892                            try {
4893                                    session = openSession();
4894    
4895                                    Query q = session.createQuery(sql);
4896    
4897                                    QueryPos qPos = QueryPos.getInstance(q);
4898    
4899                                    qPos.add(nodeId);
4900    
4901                                    if (redirectTitle != null) {
4902                                            qPos.add(redirectTitle);
4903                                    }
4904    
4905                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
4906                                                    end);
4907                            }
4908                            catch (Exception e) {
4909                                    throw processException(e);
4910                            }
4911                            finally {
4912                                    if (list == null) {
4913                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4914                                    }
4915                                    else {
4916                                            cacheResult(list);
4917    
4918                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4919                                    }
4920    
4921                                    closeSession(session);
4922                            }
4923                    }
4924    
4925                    return list;
4926            }
4927    
4928            /**
4929             * Returns the first wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
4930             *
4931             * @param nodeId the node ID
4932             * @param redirectTitle the redirect title
4933             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4934             * @return the first matching wiki page
4935             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4936             * @throws SystemException if a system exception occurred
4937             */
4938            public WikiPage findByN_R_First(long nodeId, String redirectTitle,
4939                    OrderByComparator orderByComparator)
4940                    throws NoSuchPageException, SystemException {
4941                    WikiPage wikiPage = fetchByN_R_First(nodeId, redirectTitle,
4942                                    orderByComparator);
4943    
4944                    if (wikiPage != null) {
4945                            return wikiPage;
4946                    }
4947    
4948                    StringBundler msg = new StringBundler(6);
4949    
4950                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4951    
4952                    msg.append("nodeId=");
4953                    msg.append(nodeId);
4954    
4955                    msg.append(", redirectTitle=");
4956                    msg.append(redirectTitle);
4957    
4958                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4959    
4960                    throw new NoSuchPageException(msg.toString());
4961            }
4962    
4963            /**
4964             * Returns the first wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
4965             *
4966             * @param nodeId the node ID
4967             * @param redirectTitle the redirect title
4968             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4969             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
4970             * @throws SystemException if a system exception occurred
4971             */
4972            public WikiPage fetchByN_R_First(long nodeId, String redirectTitle,
4973                    OrderByComparator orderByComparator) throws SystemException {
4974                    List<WikiPage> list = findByN_R(nodeId, redirectTitle, 0, 1,
4975                                    orderByComparator);
4976    
4977                    if (!list.isEmpty()) {
4978                            return list.get(0);
4979                    }
4980    
4981                    return null;
4982            }
4983    
4984            /**
4985             * Returns the last wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
4986             *
4987             * @param nodeId the node ID
4988             * @param redirectTitle the redirect title
4989             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4990             * @return the last matching wiki page
4991             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
4992             * @throws SystemException if a system exception occurred
4993             */
4994            public WikiPage findByN_R_Last(long nodeId, String redirectTitle,
4995                    OrderByComparator orderByComparator)
4996                    throws NoSuchPageException, SystemException {
4997                    WikiPage wikiPage = fetchByN_R_Last(nodeId, redirectTitle,
4998                                    orderByComparator);
4999    
5000                    if (wikiPage != null) {
5001                            return wikiPage;
5002                    }
5003    
5004                    StringBundler msg = new StringBundler(6);
5005    
5006                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5007    
5008                    msg.append("nodeId=");
5009                    msg.append(nodeId);
5010    
5011                    msg.append(", redirectTitle=");
5012                    msg.append(redirectTitle);
5013    
5014                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5015    
5016                    throw new NoSuchPageException(msg.toString());
5017            }
5018    
5019            /**
5020             * Returns the last wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
5021             *
5022             * @param nodeId the node ID
5023             * @param redirectTitle the redirect title
5024             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5025             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
5026             * @throws SystemException if a system exception occurred
5027             */
5028            public WikiPage fetchByN_R_Last(long nodeId, String redirectTitle,
5029                    OrderByComparator orderByComparator) throws SystemException {
5030                    int count = countByN_R(nodeId, redirectTitle);
5031    
5032                    List<WikiPage> list = findByN_R(nodeId, redirectTitle, count - 1,
5033                                    count, orderByComparator);
5034    
5035                    if (!list.isEmpty()) {
5036                            return list.get(0);
5037                    }
5038    
5039                    return null;
5040            }
5041    
5042            /**
5043             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and redirectTitle = &#63;.
5044             *
5045             * @param pageId the primary key of the current wiki page
5046             * @param nodeId the node ID
5047             * @param redirectTitle the redirect title
5048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5049             * @return the previous, current, and next wiki page
5050             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
5051             * @throws SystemException if a system exception occurred
5052             */
5053            public WikiPage[] findByN_R_PrevAndNext(long pageId, long nodeId,
5054                    String redirectTitle, OrderByComparator orderByComparator)
5055                    throws NoSuchPageException, SystemException {
5056                    WikiPage wikiPage = findByPrimaryKey(pageId);
5057    
5058                    Session session = null;
5059    
5060                    try {
5061                            session = openSession();
5062    
5063                            WikiPage[] array = new WikiPageImpl[3];
5064    
5065                            array[0] = getByN_R_PrevAndNext(session, wikiPage, nodeId,
5066                                            redirectTitle, orderByComparator, true);
5067    
5068                            array[1] = wikiPage;
5069    
5070                            array[2] = getByN_R_PrevAndNext(session, wikiPage, nodeId,
5071                                            redirectTitle, orderByComparator, false);
5072    
5073                            return array;
5074                    }
5075                    catch (Exception e) {
5076                            throw processException(e);
5077                    }
5078                    finally {
5079                            closeSession(session);
5080                    }
5081            }
5082    
5083            protected WikiPage getByN_R_PrevAndNext(Session session, WikiPage wikiPage,
5084                    long nodeId, String redirectTitle, OrderByComparator orderByComparator,
5085                    boolean previous) {
5086                    StringBundler query = null;
5087    
5088                    if (orderByComparator != null) {
5089                            query = new StringBundler(6 +
5090                                            (orderByComparator.getOrderByFields().length * 6));
5091                    }
5092                    else {
5093                            query = new StringBundler(3);
5094                    }
5095    
5096                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5097    
5098                    query.append(_FINDER_COLUMN_N_R_NODEID_2);
5099    
5100                    if (redirectTitle == null) {
5101                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
5102                    }
5103                    else {
5104                            if (redirectTitle.equals(StringPool.BLANK)) {
5105                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
5106                            }
5107                            else {
5108                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
5109                            }
5110                    }
5111    
5112                    if (orderByComparator != null) {
5113                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5114    
5115                            if (orderByConditionFields.length > 0) {
5116                                    query.append(WHERE_AND);
5117                            }
5118    
5119                            for (int i = 0; i < orderByConditionFields.length; i++) {
5120                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5121                                    query.append(orderByConditionFields[i]);
5122    
5123                                    if ((i + 1) < orderByConditionFields.length) {
5124                                            if (orderByComparator.isAscending() ^ previous) {
5125                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5126                                            }
5127                                            else {
5128                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5129                                            }
5130                                    }
5131                                    else {
5132                                            if (orderByComparator.isAscending() ^ previous) {
5133                                                    query.append(WHERE_GREATER_THAN);
5134                                            }
5135                                            else {
5136                                                    query.append(WHERE_LESSER_THAN);
5137                                            }
5138                                    }
5139                            }
5140    
5141                            query.append(ORDER_BY_CLAUSE);
5142    
5143                            String[] orderByFields = orderByComparator.getOrderByFields();
5144    
5145                            for (int i = 0; i < orderByFields.length; i++) {
5146                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5147                                    query.append(orderByFields[i]);
5148    
5149                                    if ((i + 1) < orderByFields.length) {
5150                                            if (orderByComparator.isAscending() ^ previous) {
5151                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5152                                            }
5153                                            else {
5154                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5155                                            }
5156                                    }
5157                                    else {
5158                                            if (orderByComparator.isAscending() ^ previous) {
5159                                                    query.append(ORDER_BY_ASC);
5160                                            }
5161                                            else {
5162                                                    query.append(ORDER_BY_DESC);
5163                                            }
5164                                    }
5165                            }
5166                    }
5167    
5168                    else {
5169                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5170                    }
5171    
5172                    String sql = query.toString();
5173    
5174                    Query q = session.createQuery(sql);
5175    
5176                    q.setFirstResult(0);
5177                    q.setMaxResults(2);
5178    
5179                    QueryPos qPos = QueryPos.getInstance(q);
5180    
5181                    qPos.add(nodeId);
5182    
5183                    if (redirectTitle != null) {
5184                            qPos.add(redirectTitle);
5185                    }
5186    
5187                    if (orderByComparator != null) {
5188                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
5189    
5190                            for (Object value : values) {
5191                                    qPos.add(value);
5192                            }
5193                    }
5194    
5195                    List<WikiPage> list = q.list();
5196    
5197                    if (list.size() == 2) {
5198                            return list.get(1);
5199                    }
5200                    else {
5201                            return null;
5202                    }
5203            }
5204    
5205            /**
5206             * Returns all the wiki pages where nodeId = &#63; and status = &#63;.
5207             *
5208             * @param nodeId the node ID
5209             * @param status the status
5210             * @return the matching wiki pages
5211             * @throws SystemException if a system exception occurred
5212             */
5213            public List<WikiPage> findByN_S(long nodeId, int status)
5214                    throws SystemException {
5215                    return findByN_S(nodeId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
5216                            null);
5217            }
5218    
5219            /**
5220             * Returns a range of all the wiki pages where nodeId = &#63; and status = &#63;.
5221             *
5222             * <p>
5223             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5224             * </p>
5225             *
5226             * @param nodeId the node ID
5227             * @param status the status
5228             * @param start the lower bound of the range of wiki pages
5229             * @param end the upper bound of the range of wiki pages (not inclusive)
5230             * @return the range of matching wiki pages
5231             * @throws SystemException if a system exception occurred
5232             */
5233            public List<WikiPage> findByN_S(long nodeId, int status, int start, int end)
5234                    throws SystemException {
5235                    return findByN_S(nodeId, status, start, end, null);
5236            }
5237    
5238            /**
5239             * Returns an ordered range of all the wiki pages where nodeId = &#63; and status = &#63;.
5240             *
5241             * <p>
5242             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5243             * </p>
5244             *
5245             * @param nodeId the node ID
5246             * @param status the status
5247             * @param start the lower bound of the range of wiki pages
5248             * @param end the upper bound of the range of wiki pages (not inclusive)
5249             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5250             * @return the ordered range of matching wiki pages
5251             * @throws SystemException if a system exception occurred
5252             */
5253            public List<WikiPage> findByN_S(long nodeId, int status, int start,
5254                    int end, OrderByComparator orderByComparator) throws SystemException {
5255                    FinderPath finderPath = null;
5256                    Object[] finderArgs = null;
5257    
5258                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5259                                    (orderByComparator == null)) {
5260                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_S;
5261                            finderArgs = new Object[] { nodeId, status };
5262                    }
5263                    else {
5264                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_S;
5265                            finderArgs = new Object[] {
5266                                            nodeId, status,
5267                                            
5268                                            start, end, orderByComparator
5269                                    };
5270                    }
5271    
5272                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
5273                                    finderArgs, this);
5274    
5275                    if ((list != null) && !list.isEmpty()) {
5276                            for (WikiPage wikiPage : list) {
5277                                    if ((nodeId != wikiPage.getNodeId()) ||
5278                                                    (status != wikiPage.getStatus())) {
5279                                            list = null;
5280    
5281                                            break;
5282                                    }
5283                            }
5284                    }
5285    
5286                    if (list == null) {
5287                            StringBundler query = null;
5288    
5289                            if (orderByComparator != null) {
5290                                    query = new StringBundler(4 +
5291                                                    (orderByComparator.getOrderByFields().length * 3));
5292                            }
5293                            else {
5294                                    query = new StringBundler(4);
5295                            }
5296    
5297                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5298    
5299                            query.append(_FINDER_COLUMN_N_S_NODEID_2);
5300    
5301                            query.append(_FINDER_COLUMN_N_S_STATUS_2);
5302    
5303                            if (orderByComparator != null) {
5304                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5305                                            orderByComparator);
5306                            }
5307    
5308                            else {
5309                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5310                            }
5311    
5312                            String sql = query.toString();
5313    
5314                            Session session = null;
5315    
5316                            try {
5317                                    session = openSession();
5318    
5319                                    Query q = session.createQuery(sql);
5320    
5321                                    QueryPos qPos = QueryPos.getInstance(q);
5322    
5323                                    qPos.add(nodeId);
5324    
5325                                    qPos.add(status);
5326    
5327                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
5328                                                    end);
5329                            }
5330                            catch (Exception e) {
5331                                    throw processException(e);
5332                            }
5333                            finally {
5334                                    if (list == null) {
5335                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5336                                    }
5337                                    else {
5338                                            cacheResult(list);
5339    
5340                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5341                                    }
5342    
5343                                    closeSession(session);
5344                            }
5345                    }
5346    
5347                    return list;
5348            }
5349    
5350            /**
5351             * Returns the first wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5352             *
5353             * @param nodeId the node ID
5354             * @param status the status
5355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5356             * @return the first matching wiki page
5357             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5358             * @throws SystemException if a system exception occurred
5359             */
5360            public WikiPage findByN_S_First(long nodeId, int status,
5361                    OrderByComparator orderByComparator)
5362                    throws NoSuchPageException, SystemException {
5363                    WikiPage wikiPage = fetchByN_S_First(nodeId, status, orderByComparator);
5364    
5365                    if (wikiPage != null) {
5366                            return wikiPage;
5367                    }
5368    
5369                    StringBundler msg = new StringBundler(6);
5370    
5371                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5372    
5373                    msg.append("nodeId=");
5374                    msg.append(nodeId);
5375    
5376                    msg.append(", status=");
5377                    msg.append(status);
5378    
5379                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5380    
5381                    throw new NoSuchPageException(msg.toString());
5382            }
5383    
5384            /**
5385             * Returns the first wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5386             *
5387             * @param nodeId the node ID
5388             * @param status the status
5389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5390             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
5391             * @throws SystemException if a system exception occurred
5392             */
5393            public WikiPage fetchByN_S_First(long nodeId, int status,
5394                    OrderByComparator orderByComparator) throws SystemException {
5395                    List<WikiPage> list = findByN_S(nodeId, status, 0, 1, orderByComparator);
5396    
5397                    if (!list.isEmpty()) {
5398                            return list.get(0);
5399                    }
5400    
5401                    return null;
5402            }
5403    
5404            /**
5405             * Returns the last wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5406             *
5407             * @param nodeId the node ID
5408             * @param status the status
5409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5410             * @return the last matching wiki page
5411             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5412             * @throws SystemException if a system exception occurred
5413             */
5414            public WikiPage findByN_S_Last(long nodeId, int status,
5415                    OrderByComparator orderByComparator)
5416                    throws NoSuchPageException, SystemException {
5417                    WikiPage wikiPage = fetchByN_S_Last(nodeId, status, orderByComparator);
5418    
5419                    if (wikiPage != null) {
5420                            return wikiPage;
5421                    }
5422    
5423                    StringBundler msg = new StringBundler(6);
5424    
5425                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5426    
5427                    msg.append("nodeId=");
5428                    msg.append(nodeId);
5429    
5430                    msg.append(", status=");
5431                    msg.append(status);
5432    
5433                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5434    
5435                    throw new NoSuchPageException(msg.toString());
5436            }
5437    
5438            /**
5439             * Returns the last wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5440             *
5441             * @param nodeId the node ID
5442             * @param status the status
5443             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5444             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
5445             * @throws SystemException if a system exception occurred
5446             */
5447            public WikiPage fetchByN_S_Last(long nodeId, int status,
5448                    OrderByComparator orderByComparator) throws SystemException {
5449                    int count = countByN_S(nodeId, status);
5450    
5451                    List<WikiPage> list = findByN_S(nodeId, status, count - 1, count,
5452                                    orderByComparator);
5453    
5454                    if (!list.isEmpty()) {
5455                            return list.get(0);
5456                    }
5457    
5458                    return null;
5459            }
5460    
5461            /**
5462             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and status = &#63;.
5463             *
5464             * @param pageId the primary key of the current wiki page
5465             * @param nodeId the node ID
5466             * @param status the status
5467             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5468             * @return the previous, current, and next wiki page
5469             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
5470             * @throws SystemException if a system exception occurred
5471             */
5472            public WikiPage[] findByN_S_PrevAndNext(long pageId, long nodeId,
5473                    int status, OrderByComparator orderByComparator)
5474                    throws NoSuchPageException, SystemException {
5475                    WikiPage wikiPage = findByPrimaryKey(pageId);
5476    
5477                    Session session = null;
5478    
5479                    try {
5480                            session = openSession();
5481    
5482                            WikiPage[] array = new WikiPageImpl[3];
5483    
5484                            array[0] = getByN_S_PrevAndNext(session, wikiPage, nodeId, status,
5485                                            orderByComparator, true);
5486    
5487                            array[1] = wikiPage;
5488    
5489                            array[2] = getByN_S_PrevAndNext(session, wikiPage, nodeId, status,
5490                                            orderByComparator, false);
5491    
5492                            return array;
5493                    }
5494                    catch (Exception e) {
5495                            throw processException(e);
5496                    }
5497                    finally {
5498                            closeSession(session);
5499                    }
5500            }
5501    
5502            protected WikiPage getByN_S_PrevAndNext(Session session, WikiPage wikiPage,
5503                    long nodeId, int status, OrderByComparator orderByComparator,
5504                    boolean previous) {
5505                    StringBundler query = null;
5506    
5507                    if (orderByComparator != null) {
5508                            query = new StringBundler(6 +
5509                                            (orderByComparator.getOrderByFields().length * 6));
5510                    }
5511                    else {
5512                            query = new StringBundler(3);
5513                    }
5514    
5515                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5516    
5517                    query.append(_FINDER_COLUMN_N_S_NODEID_2);
5518    
5519                    query.append(_FINDER_COLUMN_N_S_STATUS_2);
5520    
5521                    if (orderByComparator != null) {
5522                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5523    
5524                            if (orderByConditionFields.length > 0) {
5525                                    query.append(WHERE_AND);
5526                            }
5527    
5528                            for (int i = 0; i < orderByConditionFields.length; i++) {
5529                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5530                                    query.append(orderByConditionFields[i]);
5531    
5532                                    if ((i + 1) < orderByConditionFields.length) {
5533                                            if (orderByComparator.isAscending() ^ previous) {
5534                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5535                                            }
5536                                            else {
5537                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5538                                            }
5539                                    }
5540                                    else {
5541                                            if (orderByComparator.isAscending() ^ previous) {
5542                                                    query.append(WHERE_GREATER_THAN);
5543                                            }
5544                                            else {
5545                                                    query.append(WHERE_LESSER_THAN);
5546                                            }
5547                                    }
5548                            }
5549    
5550                            query.append(ORDER_BY_CLAUSE);
5551    
5552                            String[] orderByFields = orderByComparator.getOrderByFields();
5553    
5554                            for (int i = 0; i < orderByFields.length; i++) {
5555                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5556                                    query.append(orderByFields[i]);
5557    
5558                                    if ((i + 1) < orderByFields.length) {
5559                                            if (orderByComparator.isAscending() ^ previous) {
5560                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5561                                            }
5562                                            else {
5563                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5564                                            }
5565                                    }
5566                                    else {
5567                                            if (orderByComparator.isAscending() ^ previous) {
5568                                                    query.append(ORDER_BY_ASC);
5569                                            }
5570                                            else {
5571                                                    query.append(ORDER_BY_DESC);
5572                                            }
5573                                    }
5574                            }
5575                    }
5576    
5577                    else {
5578                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5579                    }
5580    
5581                    String sql = query.toString();
5582    
5583                    Query q = session.createQuery(sql);
5584    
5585                    q.setFirstResult(0);
5586                    q.setMaxResults(2);
5587    
5588                    QueryPos qPos = QueryPos.getInstance(q);
5589    
5590                    qPos.add(nodeId);
5591    
5592                    qPos.add(status);
5593    
5594                    if (orderByComparator != null) {
5595                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
5596    
5597                            for (Object value : values) {
5598                                    qPos.add(value);
5599                            }
5600                    }
5601    
5602                    List<WikiPage> list = q.list();
5603    
5604                    if (list.size() == 2) {
5605                            return list.get(1);
5606                    }
5607                    else {
5608                            return null;
5609                    }
5610            }
5611    
5612            /**
5613             * 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.
5614             *
5615             * @param resourcePrimKey the resource prim key
5616             * @param nodeId the node ID
5617             * @param version the version
5618             * @return the matching wiki page
5619             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5620             * @throws SystemException if a system exception occurred
5621             */
5622            public WikiPage findByR_N_V(long resourcePrimKey, long nodeId,
5623                    double version) throws NoSuchPageException, SystemException {
5624                    WikiPage wikiPage = fetchByR_N_V(resourcePrimKey, nodeId, version);
5625    
5626                    if (wikiPage == null) {
5627                            StringBundler msg = new StringBundler(8);
5628    
5629                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5630    
5631                            msg.append("resourcePrimKey=");
5632                            msg.append(resourcePrimKey);
5633    
5634                            msg.append(", nodeId=");
5635                            msg.append(nodeId);
5636    
5637                            msg.append(", version=");
5638                            msg.append(version);
5639    
5640                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5641    
5642                            if (_log.isWarnEnabled()) {
5643                                    _log.warn(msg.toString());
5644                            }
5645    
5646                            throw new NoSuchPageException(msg.toString());
5647                    }
5648    
5649                    return wikiPage;
5650            }
5651    
5652            /**
5653             * 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.
5654             *
5655             * @param resourcePrimKey the resource prim key
5656             * @param nodeId the node ID
5657             * @param version the version
5658             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
5659             * @throws SystemException if a system exception occurred
5660             */
5661            public WikiPage fetchByR_N_V(long resourcePrimKey, long nodeId,
5662                    double version) throws SystemException {
5663                    return fetchByR_N_V(resourcePrimKey, nodeId, version, true);
5664            }
5665    
5666            /**
5667             * 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.
5668             *
5669             * @param resourcePrimKey the resource prim key
5670             * @param nodeId the node ID
5671             * @param version the version
5672             * @param retrieveFromCache whether to use the finder cache
5673             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
5674             * @throws SystemException if a system exception occurred
5675             */
5676            public WikiPage fetchByR_N_V(long resourcePrimKey, long nodeId,
5677                    double version, boolean retrieveFromCache) throws SystemException {
5678                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, version };
5679    
5680                    Object result = null;
5681    
5682                    if (retrieveFromCache) {
5683                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_N_V,
5684                                            finderArgs, this);
5685                    }
5686    
5687                    if (result instanceof WikiPage) {
5688                            WikiPage wikiPage = (WikiPage)result;
5689    
5690                            if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
5691                                            (nodeId != wikiPage.getNodeId()) ||
5692                                            (version != wikiPage.getVersion())) {
5693                                    result = null;
5694                            }
5695                    }
5696    
5697                    if (result == null) {
5698                            StringBundler query = new StringBundler(5);
5699    
5700                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5701    
5702                            query.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
5703    
5704                            query.append(_FINDER_COLUMN_R_N_V_NODEID_2);
5705    
5706                            query.append(_FINDER_COLUMN_R_N_V_VERSION_2);
5707    
5708                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5709    
5710                            String sql = query.toString();
5711    
5712                            Session session = null;
5713    
5714                            try {
5715                                    session = openSession();
5716    
5717                                    Query q = session.createQuery(sql);
5718    
5719                                    QueryPos qPos = QueryPos.getInstance(q);
5720    
5721                                    qPos.add(resourcePrimKey);
5722    
5723                                    qPos.add(nodeId);
5724    
5725                                    qPos.add(version);
5726    
5727                                    List<WikiPage> list = q.list();
5728    
5729                                    result = list;
5730    
5731                                    WikiPage wikiPage = null;
5732    
5733                                    if (list.isEmpty()) {
5734                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
5735                                                    finderArgs, list);
5736                                    }
5737                                    else {
5738                                            wikiPage = list.get(0);
5739    
5740                                            cacheResult(wikiPage);
5741    
5742                                            if ((wikiPage.getResourcePrimKey() != resourcePrimKey) ||
5743                                                            (wikiPage.getNodeId() != nodeId) ||
5744                                                            (wikiPage.getVersion() != version)) {
5745                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_N_V,
5746                                                            finderArgs, wikiPage);
5747                                            }
5748                                    }
5749    
5750                                    return wikiPage;
5751                            }
5752                            catch (Exception e) {
5753                                    throw processException(e);
5754                            }
5755                            finally {
5756                                    if (result == null) {
5757                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_N_V,
5758                                                    finderArgs);
5759                                    }
5760    
5761                                    closeSession(session);
5762                            }
5763                    }
5764                    else {
5765                            if (result instanceof List<?>) {
5766                                    return null;
5767                            }
5768                            else {
5769                                    return (WikiPage)result;
5770                            }
5771                    }
5772            }
5773    
5774            /**
5775             * Returns all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
5776             *
5777             * @param resourcePrimKey the resource prim key
5778             * @param nodeId the node ID
5779             * @param status the status
5780             * @return the matching wiki pages
5781             * @throws SystemException if a system exception occurred
5782             */
5783            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
5784                    int status) throws SystemException {
5785                    return findByR_N_S(resourcePrimKey, nodeId, status, QueryUtil.ALL_POS,
5786                            QueryUtil.ALL_POS, null);
5787            }
5788    
5789            /**
5790             * Returns a range of all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
5791             *
5792             * <p>
5793             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5794             * </p>
5795             *
5796             * @param resourcePrimKey the resource prim key
5797             * @param nodeId the node ID
5798             * @param status the status
5799             * @param start the lower bound of the range of wiki pages
5800             * @param end the upper bound of the range of wiki pages (not inclusive)
5801             * @return the range of matching wiki pages
5802             * @throws SystemException if a system exception occurred
5803             */
5804            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
5805                    int status, int start, int end) throws SystemException {
5806                    return findByR_N_S(resourcePrimKey, nodeId, status, start, end, null);
5807            }
5808    
5809            /**
5810             * Returns an ordered range of all the wiki pages where resourcePrimKey = &#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 resourcePrimKey the resource prim key
5817             * @param nodeId the node ID
5818             * @param status the status
5819             * @param start the lower bound of the range of wiki pages
5820             * @param end the upper bound of the range of wiki pages (not inclusive)
5821             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5822             * @return the ordered range of matching wiki pages
5823             * @throws SystemException if a system exception occurred
5824             */
5825            public List<WikiPage> findByR_N_S(long resourcePrimKey, long nodeId,
5826                    int status, int start, int end, OrderByComparator orderByComparator)
5827                    throws SystemException {
5828                    FinderPath finderPath = null;
5829                    Object[] finderArgs = null;
5830    
5831                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5832                                    (orderByComparator == null)) {
5833                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_N_S;
5834                            finderArgs = new Object[] { resourcePrimKey, nodeId, status };
5835                    }
5836                    else {
5837                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_N_S;
5838                            finderArgs = new Object[] {
5839                                            resourcePrimKey, nodeId, status,
5840                                            
5841                                            start, end, orderByComparator
5842                                    };
5843                    }
5844    
5845                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
5846                                    finderArgs, this);
5847    
5848                    if ((list != null) && !list.isEmpty()) {
5849                            for (WikiPage wikiPage : list) {
5850                                    if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
5851                                                    (nodeId != wikiPage.getNodeId()) ||
5852                                                    (status != wikiPage.getStatus())) {
5853                                            list = null;
5854    
5855                                            break;
5856                                    }
5857                            }
5858                    }
5859    
5860                    if (list == null) {
5861                            StringBundler query = null;
5862    
5863                            if (orderByComparator != null) {
5864                                    query = new StringBundler(5 +
5865                                                    (orderByComparator.getOrderByFields().length * 3));
5866                            }
5867                            else {
5868                                    query = new StringBundler(5);
5869                            }
5870    
5871                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
5872    
5873                            query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
5874    
5875                            query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
5876    
5877                            query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
5878    
5879                            if (orderByComparator != null) {
5880                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5881                                            orderByComparator);
5882                            }
5883    
5884                            else {
5885                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
5886                            }
5887    
5888                            String sql = query.toString();
5889    
5890                            Session session = null;
5891    
5892                            try {
5893                                    session = openSession();
5894    
5895                                    Query q = session.createQuery(sql);
5896    
5897                                    QueryPos qPos = QueryPos.getInstance(q);
5898    
5899                                    qPos.add(resourcePrimKey);
5900    
5901                                    qPos.add(nodeId);
5902    
5903                                    qPos.add(status);
5904    
5905                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
5906                                                    end);
5907                            }
5908                            catch (Exception e) {
5909                                    throw processException(e);
5910                            }
5911                            finally {
5912                                    if (list == null) {
5913                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5914                                    }
5915                                    else {
5916                                            cacheResult(list);
5917    
5918                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5919                                    }
5920    
5921                                    closeSession(session);
5922                            }
5923                    }
5924    
5925                    return list;
5926            }
5927    
5928            /**
5929             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
5930             *
5931             * @param resourcePrimKey the resource prim key
5932             * @param nodeId the node ID
5933             * @param status the status
5934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5935             * @return the first matching wiki page
5936             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5937             * @throws SystemException if a system exception occurred
5938             */
5939            public WikiPage findByR_N_S_First(long resourcePrimKey, long nodeId,
5940                    int status, OrderByComparator orderByComparator)
5941                    throws NoSuchPageException, SystemException {
5942                    WikiPage wikiPage = fetchByR_N_S_First(resourcePrimKey, nodeId, status,
5943                                    orderByComparator);
5944    
5945                    if (wikiPage != null) {
5946                            return wikiPage;
5947                    }
5948    
5949                    StringBundler msg = new StringBundler(8);
5950    
5951                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5952    
5953                    msg.append("resourcePrimKey=");
5954                    msg.append(resourcePrimKey);
5955    
5956                    msg.append(", nodeId=");
5957                    msg.append(nodeId);
5958    
5959                    msg.append(", status=");
5960                    msg.append(status);
5961    
5962                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5963    
5964                    throw new NoSuchPageException(msg.toString());
5965            }
5966    
5967            /**
5968             * Returns the first wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
5969             *
5970             * @param resourcePrimKey the resource prim key
5971             * @param nodeId the node ID
5972             * @param status the status
5973             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5974             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
5975             * @throws SystemException if a system exception occurred
5976             */
5977            public WikiPage fetchByR_N_S_First(long resourcePrimKey, long nodeId,
5978                    int status, OrderByComparator orderByComparator)
5979                    throws SystemException {
5980                    List<WikiPage> list = findByR_N_S(resourcePrimKey, nodeId, status, 0,
5981                                    1, orderByComparator);
5982    
5983                    if (!list.isEmpty()) {
5984                            return list.get(0);
5985                    }
5986    
5987                    return null;
5988            }
5989    
5990            /**
5991             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
5992             *
5993             * @param resourcePrimKey the resource prim key
5994             * @param nodeId the node ID
5995             * @param status the status
5996             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5997             * @return the last matching wiki page
5998             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
5999             * @throws SystemException if a system exception occurred
6000             */
6001            public WikiPage findByR_N_S_Last(long resourcePrimKey, long nodeId,
6002                    int status, OrderByComparator orderByComparator)
6003                    throws NoSuchPageException, SystemException {
6004                    WikiPage wikiPage = fetchByR_N_S_Last(resourcePrimKey, nodeId, status,
6005                                    orderByComparator);
6006    
6007                    if (wikiPage != null) {
6008                            return wikiPage;
6009                    }
6010    
6011                    StringBundler msg = new StringBundler(8);
6012    
6013                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6014    
6015                    msg.append("resourcePrimKey=");
6016                    msg.append(resourcePrimKey);
6017    
6018                    msg.append(", nodeId=");
6019                    msg.append(nodeId);
6020    
6021                    msg.append(", status=");
6022                    msg.append(status);
6023    
6024                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6025    
6026                    throw new NoSuchPageException(msg.toString());
6027            }
6028    
6029            /**
6030             * Returns the last wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6031             *
6032             * @param resourcePrimKey the resource prim key
6033             * @param nodeId the node ID
6034             * @param status the status
6035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6036             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
6037             * @throws SystemException if a system exception occurred
6038             */
6039            public WikiPage fetchByR_N_S_Last(long resourcePrimKey, long nodeId,
6040                    int status, OrderByComparator orderByComparator)
6041                    throws SystemException {
6042                    int count = countByR_N_S(resourcePrimKey, nodeId, status);
6043    
6044                    List<WikiPage> list = findByR_N_S(resourcePrimKey, nodeId, status,
6045                                    count - 1, count, orderByComparator);
6046    
6047                    if (!list.isEmpty()) {
6048                            return list.get(0);
6049                    }
6050    
6051                    return null;
6052            }
6053    
6054            /**
6055             * Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
6056             *
6057             * @param pageId the primary key of the current wiki page
6058             * @param resourcePrimKey the resource prim key
6059             * @param nodeId the node ID
6060             * @param status the status
6061             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6062             * @return the previous, current, and next wiki page
6063             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
6064             * @throws SystemException if a system exception occurred
6065             */
6066            public WikiPage[] findByR_N_S_PrevAndNext(long pageId,
6067                    long resourcePrimKey, long nodeId, int status,
6068                    OrderByComparator orderByComparator)
6069                    throws NoSuchPageException, SystemException {
6070                    WikiPage wikiPage = findByPrimaryKey(pageId);
6071    
6072                    Session session = null;
6073    
6074                    try {
6075                            session = openSession();
6076    
6077                            WikiPage[] array = new WikiPageImpl[3];
6078    
6079                            array[0] = getByR_N_S_PrevAndNext(session, wikiPage,
6080                                            resourcePrimKey, nodeId, status, orderByComparator, true);
6081    
6082                            array[1] = wikiPage;
6083    
6084                            array[2] = getByR_N_S_PrevAndNext(session, wikiPage,
6085                                            resourcePrimKey, nodeId, status, orderByComparator, false);
6086    
6087                            return array;
6088                    }
6089                    catch (Exception e) {
6090                            throw processException(e);
6091                    }
6092                    finally {
6093                            closeSession(session);
6094                    }
6095            }
6096    
6097            protected WikiPage getByR_N_S_PrevAndNext(Session session,
6098                    WikiPage wikiPage, long resourcePrimKey, long nodeId, int status,
6099                    OrderByComparator orderByComparator, boolean previous) {
6100                    StringBundler query = null;
6101    
6102                    if (orderByComparator != null) {
6103                            query = new StringBundler(6 +
6104                                            (orderByComparator.getOrderByFields().length * 6));
6105                    }
6106                    else {
6107                            query = new StringBundler(3);
6108                    }
6109    
6110                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6111    
6112                    query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
6113    
6114                    query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
6115    
6116                    query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
6117    
6118                    if (orderByComparator != null) {
6119                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6120    
6121                            if (orderByConditionFields.length > 0) {
6122                                    query.append(WHERE_AND);
6123                            }
6124    
6125                            for (int i = 0; i < orderByConditionFields.length; i++) {
6126                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6127                                    query.append(orderByConditionFields[i]);
6128    
6129                                    if ((i + 1) < orderByConditionFields.length) {
6130                                            if (orderByComparator.isAscending() ^ previous) {
6131                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6132                                            }
6133                                            else {
6134                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6135                                            }
6136                                    }
6137                                    else {
6138                                            if (orderByComparator.isAscending() ^ previous) {
6139                                                    query.append(WHERE_GREATER_THAN);
6140                                            }
6141                                            else {
6142                                                    query.append(WHERE_LESSER_THAN);
6143                                            }
6144                                    }
6145                            }
6146    
6147                            query.append(ORDER_BY_CLAUSE);
6148    
6149                            String[] orderByFields = orderByComparator.getOrderByFields();
6150    
6151                            for (int i = 0; i < orderByFields.length; i++) {
6152                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6153                                    query.append(orderByFields[i]);
6154    
6155                                    if ((i + 1) < orderByFields.length) {
6156                                            if (orderByComparator.isAscending() ^ previous) {
6157                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6158                                            }
6159                                            else {
6160                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6161                                            }
6162                                    }
6163                                    else {
6164                                            if (orderByComparator.isAscending() ^ previous) {
6165                                                    query.append(ORDER_BY_ASC);
6166                                            }
6167                                            else {
6168                                                    query.append(ORDER_BY_DESC);
6169                                            }
6170                                    }
6171                            }
6172                    }
6173    
6174                    else {
6175                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6176                    }
6177    
6178                    String sql = query.toString();
6179    
6180                    Query q = session.createQuery(sql);
6181    
6182                    q.setFirstResult(0);
6183                    q.setMaxResults(2);
6184    
6185                    QueryPos qPos = QueryPos.getInstance(q);
6186    
6187                    qPos.add(resourcePrimKey);
6188    
6189                    qPos.add(nodeId);
6190    
6191                    qPos.add(status);
6192    
6193                    if (orderByComparator != null) {
6194                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
6195    
6196                            for (Object value : values) {
6197                                    qPos.add(value);
6198                            }
6199                    }
6200    
6201                    List<WikiPage> list = q.list();
6202    
6203                    if (list.size() == 2) {
6204                            return list.get(1);
6205                    }
6206                    else {
6207                            return null;
6208                    }
6209            }
6210    
6211            /**
6212             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
6213             *
6214             * @param groupId the group ID
6215             * @param nodeId the node ID
6216             * @param head the head
6217             * @return the matching wiki pages
6218             * @throws SystemException if a system exception occurred
6219             */
6220            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head)
6221                    throws SystemException {
6222                    return findByG_N_H(groupId, nodeId, head, QueryUtil.ALL_POS,
6223                            QueryUtil.ALL_POS, null);
6224            }
6225    
6226            /**
6227             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
6228             *
6229             * <p>
6230             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6231             * </p>
6232             *
6233             * @param groupId the group ID
6234             * @param nodeId the node ID
6235             * @param head the head
6236             * @param start the lower bound of the range of wiki pages
6237             * @param end the upper bound of the range of wiki pages (not inclusive)
6238             * @return the range of matching wiki pages
6239             * @throws SystemException if a system exception occurred
6240             */
6241            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head,
6242                    int start, int end) throws SystemException {
6243                    return findByG_N_H(groupId, nodeId, head, start, end, null);
6244            }
6245    
6246            /**
6247             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
6248             *
6249             * <p>
6250             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6251             * </p>
6252             *
6253             * @param groupId the group ID
6254             * @param nodeId the node ID
6255             * @param head the head
6256             * @param start the lower bound of the range of wiki pages
6257             * @param end the upper bound of the range of wiki pages (not inclusive)
6258             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6259             * @return the ordered range of matching wiki pages
6260             * @throws SystemException if a system exception occurred
6261             */
6262            public List<WikiPage> findByG_N_H(long groupId, long nodeId, boolean head,
6263                    int start, int end, OrderByComparator orderByComparator)
6264                    throws SystemException {
6265                    FinderPath finderPath = null;
6266                    Object[] finderArgs = null;
6267    
6268                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6269                                    (orderByComparator == null)) {
6270                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H;
6271                            finderArgs = new Object[] { groupId, nodeId, head };
6272                    }
6273                    else {
6274                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H;
6275                            finderArgs = new Object[] {
6276                                            groupId, nodeId, head,
6277                                            
6278                                            start, end, orderByComparator
6279                                    };
6280                    }
6281    
6282                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
6283                                    finderArgs, this);
6284    
6285                    if ((list != null) && !list.isEmpty()) {
6286                            for (WikiPage wikiPage : list) {
6287                                    if ((groupId != wikiPage.getGroupId()) ||
6288                                                    (nodeId != wikiPage.getNodeId()) ||
6289                                                    (head != wikiPage.getHead())) {
6290                                            list = null;
6291    
6292                                            break;
6293                                    }
6294                            }
6295                    }
6296    
6297                    if (list == null) {
6298                            StringBundler query = null;
6299    
6300                            if (orderByComparator != null) {
6301                                    query = new StringBundler(5 +
6302                                                    (orderByComparator.getOrderByFields().length * 3));
6303                            }
6304                            else {
6305                                    query = new StringBundler(5);
6306                            }
6307    
6308                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6309    
6310                            query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
6311    
6312                            query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
6313    
6314                            query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
6315    
6316                            if (orderByComparator != null) {
6317                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6318                                            orderByComparator);
6319                            }
6320    
6321                            else {
6322                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6323                            }
6324    
6325                            String sql = query.toString();
6326    
6327                            Session session = null;
6328    
6329                            try {
6330                                    session = openSession();
6331    
6332                                    Query q = session.createQuery(sql);
6333    
6334                                    QueryPos qPos = QueryPos.getInstance(q);
6335    
6336                                    qPos.add(groupId);
6337    
6338                                    qPos.add(nodeId);
6339    
6340                                    qPos.add(head);
6341    
6342                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
6343                                                    end);
6344                            }
6345                            catch (Exception e) {
6346                                    throw processException(e);
6347                            }
6348                            finally {
6349                                    if (list == null) {
6350                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6351                                    }
6352                                    else {
6353                                            cacheResult(list);
6354    
6355                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6356                                    }
6357    
6358                                    closeSession(session);
6359                            }
6360                    }
6361    
6362                    return list;
6363            }
6364    
6365            /**
6366             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
6367             *
6368             * @param groupId the group ID
6369             * @param nodeId the node ID
6370             * @param head the head
6371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6372             * @return the first matching wiki page
6373             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6374             * @throws SystemException if a system exception occurred
6375             */
6376            public WikiPage findByG_N_H_First(long groupId, long nodeId, boolean head,
6377                    OrderByComparator orderByComparator)
6378                    throws NoSuchPageException, SystemException {
6379                    WikiPage wikiPage = fetchByG_N_H_First(groupId, nodeId, head,
6380                                    orderByComparator);
6381    
6382                    if (wikiPage != null) {
6383                            return wikiPage;
6384                    }
6385    
6386                    StringBundler msg = new StringBundler(8);
6387    
6388                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6389    
6390                    msg.append("groupId=");
6391                    msg.append(groupId);
6392    
6393                    msg.append(", nodeId=");
6394                    msg.append(nodeId);
6395    
6396                    msg.append(", head=");
6397                    msg.append(head);
6398    
6399                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6400    
6401                    throw new NoSuchPageException(msg.toString());
6402            }
6403    
6404            /**
6405             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
6406             *
6407             * @param groupId the group ID
6408             * @param nodeId the node ID
6409             * @param head the head
6410             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6411             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
6412             * @throws SystemException if a system exception occurred
6413             */
6414            public WikiPage fetchByG_N_H_First(long groupId, long nodeId, boolean head,
6415                    OrderByComparator orderByComparator) throws SystemException {
6416                    List<WikiPage> list = findByG_N_H(groupId, nodeId, head, 0, 1,
6417                                    orderByComparator);
6418    
6419                    if (!list.isEmpty()) {
6420                            return list.get(0);
6421                    }
6422    
6423                    return null;
6424            }
6425    
6426            /**
6427             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
6428             *
6429             * @param groupId the group ID
6430             * @param nodeId the node ID
6431             * @param head the head
6432             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6433             * @return the last matching wiki page
6434             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
6435             * @throws SystemException if a system exception occurred
6436             */
6437            public WikiPage findByG_N_H_Last(long groupId, long nodeId, boolean head,
6438                    OrderByComparator orderByComparator)
6439                    throws NoSuchPageException, SystemException {
6440                    WikiPage wikiPage = fetchByG_N_H_Last(groupId, nodeId, head,
6441                                    orderByComparator);
6442    
6443                    if (wikiPage != null) {
6444                            return wikiPage;
6445                    }
6446    
6447                    StringBundler msg = new StringBundler(8);
6448    
6449                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6450    
6451                    msg.append("groupId=");
6452                    msg.append(groupId);
6453    
6454                    msg.append(", nodeId=");
6455                    msg.append(nodeId);
6456    
6457                    msg.append(", head=");
6458                    msg.append(head);
6459    
6460                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6461    
6462                    throw new NoSuchPageException(msg.toString());
6463            }
6464    
6465            /**
6466             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
6467             *
6468             * @param groupId the group ID
6469             * @param nodeId the node ID
6470             * @param head the head
6471             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6472             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
6473             * @throws SystemException if a system exception occurred
6474             */
6475            public WikiPage fetchByG_N_H_Last(long groupId, long nodeId, boolean head,
6476                    OrderByComparator orderByComparator) throws SystemException {
6477                    int count = countByG_N_H(groupId, nodeId, head);
6478    
6479                    List<WikiPage> list = findByG_N_H(groupId, nodeId, head, count - 1,
6480                                    count, orderByComparator);
6481    
6482                    if (!list.isEmpty()) {
6483                            return list.get(0);
6484                    }
6485    
6486                    return null;
6487            }
6488    
6489            /**
6490             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63;.
6491             *
6492             * @param pageId the primary key of the current wiki page
6493             * @param groupId the group ID
6494             * @param nodeId the node ID
6495             * @param head the head
6496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6497             * @return the previous, current, and next wiki page
6498             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
6499             * @throws SystemException if a system exception occurred
6500             */
6501            public WikiPage[] findByG_N_H_PrevAndNext(long pageId, long groupId,
6502                    long nodeId, boolean head, OrderByComparator orderByComparator)
6503                    throws NoSuchPageException, SystemException {
6504                    WikiPage wikiPage = findByPrimaryKey(pageId);
6505    
6506                    Session session = null;
6507    
6508                    try {
6509                            session = openSession();
6510    
6511                            WikiPage[] array = new WikiPageImpl[3];
6512    
6513                            array[0] = getByG_N_H_PrevAndNext(session, wikiPage, groupId,
6514                                            nodeId, head, orderByComparator, true);
6515    
6516                            array[1] = wikiPage;
6517    
6518                            array[2] = getByG_N_H_PrevAndNext(session, wikiPage, groupId,
6519                                            nodeId, head, orderByComparator, false);
6520    
6521                            return array;
6522                    }
6523                    catch (Exception e) {
6524                            throw processException(e);
6525                    }
6526                    finally {
6527                            closeSession(session);
6528                    }
6529            }
6530    
6531            protected WikiPage getByG_N_H_PrevAndNext(Session session,
6532                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
6533                    OrderByComparator orderByComparator, boolean previous) {
6534                    StringBundler query = null;
6535    
6536                    if (orderByComparator != null) {
6537                            query = new StringBundler(6 +
6538                                            (orderByComparator.getOrderByFields().length * 6));
6539                    }
6540                    else {
6541                            query = new StringBundler(3);
6542                    }
6543    
6544                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
6545    
6546                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
6547    
6548                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
6549    
6550                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
6551    
6552                    if (orderByComparator != null) {
6553                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6554    
6555                            if (orderByConditionFields.length > 0) {
6556                                    query.append(WHERE_AND);
6557                            }
6558    
6559                            for (int i = 0; i < orderByConditionFields.length; i++) {
6560                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6561                                    query.append(orderByConditionFields[i]);
6562    
6563                                    if ((i + 1) < orderByConditionFields.length) {
6564                                            if (orderByComparator.isAscending() ^ previous) {
6565                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6566                                            }
6567                                            else {
6568                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6569                                            }
6570                                    }
6571                                    else {
6572                                            if (orderByComparator.isAscending() ^ previous) {
6573                                                    query.append(WHERE_GREATER_THAN);
6574                                            }
6575                                            else {
6576                                                    query.append(WHERE_LESSER_THAN);
6577                                            }
6578                                    }
6579                            }
6580    
6581                            query.append(ORDER_BY_CLAUSE);
6582    
6583                            String[] orderByFields = orderByComparator.getOrderByFields();
6584    
6585                            for (int i = 0; i < orderByFields.length; i++) {
6586                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6587                                    query.append(orderByFields[i]);
6588    
6589                                    if ((i + 1) < orderByFields.length) {
6590                                            if (orderByComparator.isAscending() ^ previous) {
6591                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6592                                            }
6593                                            else {
6594                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6595                                            }
6596                                    }
6597                                    else {
6598                                            if (orderByComparator.isAscending() ^ previous) {
6599                                                    query.append(ORDER_BY_ASC);
6600                                            }
6601                                            else {
6602                                                    query.append(ORDER_BY_DESC);
6603                                            }
6604                                    }
6605                            }
6606                    }
6607    
6608                    else {
6609                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6610                    }
6611    
6612                    String sql = query.toString();
6613    
6614                    Query q = session.createQuery(sql);
6615    
6616                    q.setFirstResult(0);
6617                    q.setMaxResults(2);
6618    
6619                    QueryPos qPos = QueryPos.getInstance(q);
6620    
6621                    qPos.add(groupId);
6622    
6623                    qPos.add(nodeId);
6624    
6625                    qPos.add(head);
6626    
6627                    if (orderByComparator != null) {
6628                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
6629    
6630                            for (Object value : values) {
6631                                    qPos.add(value);
6632                            }
6633                    }
6634    
6635                    List<WikiPage> list = q.list();
6636    
6637                    if (list.size() == 2) {
6638                            return list.get(1);
6639                    }
6640                    else {
6641                            return null;
6642                    }
6643            }
6644    
6645            /**
6646             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
6647             *
6648             * @param groupId the group ID
6649             * @param nodeId the node ID
6650             * @param head the head
6651             * @return the matching wiki pages that the user has permission to view
6652             * @throws SystemException if a system exception occurred
6653             */
6654            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
6655                    boolean head) throws SystemException {
6656                    return filterFindByG_N_H(groupId, nodeId, head, QueryUtil.ALL_POS,
6657                            QueryUtil.ALL_POS, null);
6658            }
6659    
6660            /**
6661             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
6662             *
6663             * <p>
6664             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6665             * </p>
6666             *
6667             * @param groupId the group ID
6668             * @param nodeId the node ID
6669             * @param head the head
6670             * @param start the lower bound of the range of wiki pages
6671             * @param end the upper bound of the range of wiki pages (not inclusive)
6672             * @return the range of matching wiki pages that the user has permission to view
6673             * @throws SystemException if a system exception occurred
6674             */
6675            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
6676                    boolean head, int start, int end) throws SystemException {
6677                    return filterFindByG_N_H(groupId, nodeId, head, start, end, null);
6678            }
6679    
6680            /**
6681             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
6682             *
6683             * <p>
6684             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6685             * </p>
6686             *
6687             * @param groupId the group ID
6688             * @param nodeId the node ID
6689             * @param head the head
6690             * @param start the lower bound of the range of wiki pages
6691             * @param end the upper bound of the range of wiki pages (not inclusive)
6692             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6693             * @return the ordered range of matching wiki pages that the user has permission to view
6694             * @throws SystemException if a system exception occurred
6695             */
6696            public List<WikiPage> filterFindByG_N_H(long groupId, long nodeId,
6697                    boolean head, int start, int end, OrderByComparator orderByComparator)
6698                    throws SystemException {
6699                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6700                            return findByG_N_H(groupId, nodeId, head, start, end,
6701                                    orderByComparator);
6702                    }
6703    
6704                    StringBundler query = null;
6705    
6706                    if (orderByComparator != null) {
6707                            query = new StringBundler(5 +
6708                                            (orderByComparator.getOrderByFields().length * 3));
6709                    }
6710                    else {
6711                            query = new StringBundler(5);
6712                    }
6713    
6714                    if (getDB().isSupportsInlineDistinct()) {
6715                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
6716                    }
6717                    else {
6718                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
6719                    }
6720    
6721                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
6722    
6723                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
6724    
6725                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
6726    
6727                    if (!getDB().isSupportsInlineDistinct()) {
6728                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
6729                    }
6730    
6731                    if (orderByComparator != null) {
6732                            if (getDB().isSupportsInlineDistinct()) {
6733                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6734                                            orderByComparator);
6735                            }
6736                            else {
6737                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6738                                            orderByComparator);
6739                            }
6740                    }
6741    
6742                    else {
6743                            if (getDB().isSupportsInlineDistinct()) {
6744                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6745                            }
6746                            else {
6747                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
6748                            }
6749                    }
6750    
6751                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6752                                    WikiPage.class.getName(),
6753                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6754    
6755                    Session session = null;
6756    
6757                    try {
6758                            session = openSession();
6759    
6760                            SQLQuery q = session.createSQLQuery(sql);
6761    
6762                            if (getDB().isSupportsInlineDistinct()) {
6763                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
6764                            }
6765                            else {
6766                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
6767                            }
6768    
6769                            QueryPos qPos = QueryPos.getInstance(q);
6770    
6771                            qPos.add(groupId);
6772    
6773                            qPos.add(nodeId);
6774    
6775                            qPos.add(head);
6776    
6777                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
6778                    }
6779                    catch (Exception e) {
6780                            throw processException(e);
6781                    }
6782                    finally {
6783                            closeSession(session);
6784                    }
6785            }
6786    
6787            /**
6788             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
6789             *
6790             * @param pageId the primary key of the current wiki page
6791             * @param groupId the group ID
6792             * @param nodeId the node ID
6793             * @param head the head
6794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6795             * @return the previous, current, and next wiki page
6796             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
6797             * @throws SystemException if a system exception occurred
6798             */
6799            public WikiPage[] filterFindByG_N_H_PrevAndNext(long pageId, long groupId,
6800                    long nodeId, boolean head, OrderByComparator orderByComparator)
6801                    throws NoSuchPageException, SystemException {
6802                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6803                            return findByG_N_H_PrevAndNext(pageId, groupId, nodeId, head,
6804                                    orderByComparator);
6805                    }
6806    
6807                    WikiPage wikiPage = findByPrimaryKey(pageId);
6808    
6809                    Session session = null;
6810    
6811                    try {
6812                            session = openSession();
6813    
6814                            WikiPage[] array = new WikiPageImpl[3];
6815    
6816                            array[0] = filterGetByG_N_H_PrevAndNext(session, wikiPage, groupId,
6817                                            nodeId, head, orderByComparator, true);
6818    
6819                            array[1] = wikiPage;
6820    
6821                            array[2] = filterGetByG_N_H_PrevAndNext(session, wikiPage, groupId,
6822                                            nodeId, head, orderByComparator, false);
6823    
6824                            return array;
6825                    }
6826                    catch (Exception e) {
6827                            throw processException(e);
6828                    }
6829                    finally {
6830                            closeSession(session);
6831                    }
6832            }
6833    
6834            protected WikiPage filterGetByG_N_H_PrevAndNext(Session session,
6835                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
6836                    OrderByComparator orderByComparator, boolean previous) {
6837                    StringBundler query = null;
6838    
6839                    if (orderByComparator != null) {
6840                            query = new StringBundler(6 +
6841                                            (orderByComparator.getOrderByFields().length * 6));
6842                    }
6843                    else {
6844                            query = new StringBundler(3);
6845                    }
6846    
6847                    if (getDB().isSupportsInlineDistinct()) {
6848                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
6849                    }
6850                    else {
6851                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
6852                    }
6853    
6854                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
6855    
6856                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
6857    
6858                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
6859    
6860                    if (!getDB().isSupportsInlineDistinct()) {
6861                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
6862                    }
6863    
6864                    if (orderByComparator != null) {
6865                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6866    
6867                            if (orderByConditionFields.length > 0) {
6868                                    query.append(WHERE_AND);
6869                            }
6870    
6871                            for (int i = 0; i < orderByConditionFields.length; i++) {
6872                                    if (getDB().isSupportsInlineDistinct()) {
6873                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6874                                    }
6875                                    else {
6876                                            query.append(_ORDER_BY_ENTITY_TABLE);
6877                                    }
6878    
6879                                    query.append(orderByConditionFields[i]);
6880    
6881                                    if ((i + 1) < orderByConditionFields.length) {
6882                                            if (orderByComparator.isAscending() ^ previous) {
6883                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6884                                            }
6885                                            else {
6886                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6887                                            }
6888                                    }
6889                                    else {
6890                                            if (orderByComparator.isAscending() ^ previous) {
6891                                                    query.append(WHERE_GREATER_THAN);
6892                                            }
6893                                            else {
6894                                                    query.append(WHERE_LESSER_THAN);
6895                                            }
6896                                    }
6897                            }
6898    
6899                            query.append(ORDER_BY_CLAUSE);
6900    
6901                            String[] orderByFields = orderByComparator.getOrderByFields();
6902    
6903                            for (int i = 0; i < orderByFields.length; i++) {
6904                                    if (getDB().isSupportsInlineDistinct()) {
6905                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6906                                    }
6907                                    else {
6908                                            query.append(_ORDER_BY_ENTITY_TABLE);
6909                                    }
6910    
6911                                    query.append(orderByFields[i]);
6912    
6913                                    if ((i + 1) < orderByFields.length) {
6914                                            if (orderByComparator.isAscending() ^ previous) {
6915                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6916                                            }
6917                                            else {
6918                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6919                                            }
6920                                    }
6921                                    else {
6922                                            if (orderByComparator.isAscending() ^ previous) {
6923                                                    query.append(ORDER_BY_ASC);
6924                                            }
6925                                            else {
6926                                                    query.append(ORDER_BY_DESC);
6927                                            }
6928                                    }
6929                            }
6930                    }
6931    
6932                    else {
6933                            if (getDB().isSupportsInlineDistinct()) {
6934                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
6935                            }
6936                            else {
6937                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
6938                            }
6939                    }
6940    
6941                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6942                                    WikiPage.class.getName(),
6943                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6944    
6945                    SQLQuery q = session.createSQLQuery(sql);
6946    
6947                    q.setFirstResult(0);
6948                    q.setMaxResults(2);
6949    
6950                    if (getDB().isSupportsInlineDistinct()) {
6951                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
6952                    }
6953                    else {
6954                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
6955                    }
6956    
6957                    QueryPos qPos = QueryPos.getInstance(q);
6958    
6959                    qPos.add(groupId);
6960    
6961                    qPos.add(nodeId);
6962    
6963                    qPos.add(head);
6964    
6965                    if (orderByComparator != null) {
6966                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
6967    
6968                            for (Object value : values) {
6969                                    qPos.add(value);
6970                            }
6971                    }
6972    
6973                    List<WikiPage> list = q.list();
6974    
6975                    if (list.size() == 2) {
6976                            return list.get(1);
6977                    }
6978                    else {
6979                            return null;
6980                    }
6981            }
6982    
6983            /**
6984             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
6985             *
6986             * @param groupId the group ID
6987             * @param nodeId the node ID
6988             * @param status the status
6989             * @return the matching wiki pages
6990             * @throws SystemException if a system exception occurred
6991             */
6992            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status)
6993                    throws SystemException {
6994                    return findByG_N_S(groupId, nodeId, status, QueryUtil.ALL_POS,
6995                            QueryUtil.ALL_POS, null);
6996            }
6997    
6998            /**
6999             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
7000             *
7001             * <p>
7002             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7003             * </p>
7004             *
7005             * @param groupId the group ID
7006             * @param nodeId the node ID
7007             * @param status the status
7008             * @param start the lower bound of the range of wiki pages
7009             * @param end the upper bound of the range of wiki pages (not inclusive)
7010             * @return the range of matching wiki pages
7011             * @throws SystemException if a system exception occurred
7012             */
7013            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status,
7014                    int start, int end) throws SystemException {
7015                    return findByG_N_S(groupId, nodeId, status, start, end, null);
7016            }
7017    
7018            /**
7019             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
7020             *
7021             * <p>
7022             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7023             * </p>
7024             *
7025             * @param groupId the group ID
7026             * @param nodeId the node ID
7027             * @param status the status
7028             * @param start the lower bound of the range of wiki pages
7029             * @param end the upper bound of the range of wiki pages (not inclusive)
7030             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7031             * @return the ordered range of matching wiki pages
7032             * @throws SystemException if a system exception occurred
7033             */
7034            public List<WikiPage> findByG_N_S(long groupId, long nodeId, int status,
7035                    int start, int end, OrderByComparator orderByComparator)
7036                    throws SystemException {
7037                    FinderPath finderPath = null;
7038                    Object[] finderArgs = null;
7039    
7040                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7041                                    (orderByComparator == null)) {
7042                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_S;
7043                            finderArgs = new Object[] { groupId, nodeId, status };
7044                    }
7045                    else {
7046                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_S;
7047                            finderArgs = new Object[] {
7048                                            groupId, nodeId, status,
7049                                            
7050                                            start, end, orderByComparator
7051                                    };
7052                    }
7053    
7054                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
7055                                    finderArgs, this);
7056    
7057                    if ((list != null) && !list.isEmpty()) {
7058                            for (WikiPage wikiPage : list) {
7059                                    if ((groupId != wikiPage.getGroupId()) ||
7060                                                    (nodeId != wikiPage.getNodeId()) ||
7061                                                    (status != wikiPage.getStatus())) {
7062                                            list = null;
7063    
7064                                            break;
7065                                    }
7066                            }
7067                    }
7068    
7069                    if (list == null) {
7070                            StringBundler query = null;
7071    
7072                            if (orderByComparator != null) {
7073                                    query = new StringBundler(5 +
7074                                                    (orderByComparator.getOrderByFields().length * 3));
7075                            }
7076                            else {
7077                                    query = new StringBundler(5);
7078                            }
7079    
7080                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7081    
7082                            query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
7083    
7084                            query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
7085    
7086                            query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
7087    
7088                            if (orderByComparator != null) {
7089                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7090                                            orderByComparator);
7091                            }
7092    
7093                            else {
7094                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7095                            }
7096    
7097                            String sql = query.toString();
7098    
7099                            Session session = null;
7100    
7101                            try {
7102                                    session = openSession();
7103    
7104                                    Query q = session.createQuery(sql);
7105    
7106                                    QueryPos qPos = QueryPos.getInstance(q);
7107    
7108                                    qPos.add(groupId);
7109    
7110                                    qPos.add(nodeId);
7111    
7112                                    qPos.add(status);
7113    
7114                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
7115                                                    end);
7116                            }
7117                            catch (Exception e) {
7118                                    throw processException(e);
7119                            }
7120                            finally {
7121                                    if (list == null) {
7122                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7123                                    }
7124                                    else {
7125                                            cacheResult(list);
7126    
7127                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7128                                    }
7129    
7130                                    closeSession(session);
7131                            }
7132                    }
7133    
7134                    return list;
7135            }
7136    
7137            /**
7138             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
7139             *
7140             * @param groupId the group ID
7141             * @param nodeId the node ID
7142             * @param status the status
7143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7144             * @return the first matching wiki page
7145             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7146             * @throws SystemException if a system exception occurred
7147             */
7148            public WikiPage findByG_N_S_First(long groupId, long nodeId, int status,
7149                    OrderByComparator orderByComparator)
7150                    throws NoSuchPageException, SystemException {
7151                    WikiPage wikiPage = fetchByG_N_S_First(groupId, nodeId, status,
7152                                    orderByComparator);
7153    
7154                    if (wikiPage != null) {
7155                            return wikiPage;
7156                    }
7157    
7158                    StringBundler msg = new StringBundler(8);
7159    
7160                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7161    
7162                    msg.append("groupId=");
7163                    msg.append(groupId);
7164    
7165                    msg.append(", nodeId=");
7166                    msg.append(nodeId);
7167    
7168                    msg.append(", status=");
7169                    msg.append(status);
7170    
7171                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7172    
7173                    throw new NoSuchPageException(msg.toString());
7174            }
7175    
7176            /**
7177             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
7178             *
7179             * @param groupId the group ID
7180             * @param nodeId the node ID
7181             * @param status the status
7182             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7183             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
7184             * @throws SystemException if a system exception occurred
7185             */
7186            public WikiPage fetchByG_N_S_First(long groupId, long nodeId, int status,
7187                    OrderByComparator orderByComparator) throws SystemException {
7188                    List<WikiPage> list = findByG_N_S(groupId, nodeId, status, 0, 1,
7189                                    orderByComparator);
7190    
7191                    if (!list.isEmpty()) {
7192                            return list.get(0);
7193                    }
7194    
7195                    return null;
7196            }
7197    
7198            /**
7199             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
7200             *
7201             * @param groupId the group ID
7202             * @param nodeId the node ID
7203             * @param status the status
7204             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7205             * @return the last matching wiki page
7206             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7207             * @throws SystemException if a system exception occurred
7208             */
7209            public WikiPage findByG_N_S_Last(long groupId, long nodeId, int status,
7210                    OrderByComparator orderByComparator)
7211                    throws NoSuchPageException, SystemException {
7212                    WikiPage wikiPage = fetchByG_N_S_Last(groupId, nodeId, status,
7213                                    orderByComparator);
7214    
7215                    if (wikiPage != null) {
7216                            return wikiPage;
7217                    }
7218    
7219                    StringBundler msg = new StringBundler(8);
7220    
7221                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7222    
7223                    msg.append("groupId=");
7224                    msg.append(groupId);
7225    
7226                    msg.append(", nodeId=");
7227                    msg.append(nodeId);
7228    
7229                    msg.append(", status=");
7230                    msg.append(status);
7231    
7232                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7233    
7234                    throw new NoSuchPageException(msg.toString());
7235            }
7236    
7237            /**
7238             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
7239             *
7240             * @param groupId the group ID
7241             * @param nodeId the node ID
7242             * @param status the status
7243             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7244             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
7245             * @throws SystemException if a system exception occurred
7246             */
7247            public WikiPage fetchByG_N_S_Last(long groupId, long nodeId, int status,
7248                    OrderByComparator orderByComparator) throws SystemException {
7249                    int count = countByG_N_S(groupId, nodeId, status);
7250    
7251                    List<WikiPage> list = findByG_N_S(groupId, nodeId, status, count - 1,
7252                                    count, orderByComparator);
7253    
7254                    if (!list.isEmpty()) {
7255                            return list.get(0);
7256                    }
7257    
7258                    return null;
7259            }
7260    
7261            /**
7262             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and status = &#63;.
7263             *
7264             * @param pageId the primary key of the current wiki page
7265             * @param groupId the group ID
7266             * @param nodeId the node ID
7267             * @param status the status
7268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7269             * @return the previous, current, and next wiki page
7270             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
7271             * @throws SystemException if a system exception occurred
7272             */
7273            public WikiPage[] findByG_N_S_PrevAndNext(long pageId, long groupId,
7274                    long nodeId, int status, OrderByComparator orderByComparator)
7275                    throws NoSuchPageException, SystemException {
7276                    WikiPage wikiPage = findByPrimaryKey(pageId);
7277    
7278                    Session session = null;
7279    
7280                    try {
7281                            session = openSession();
7282    
7283                            WikiPage[] array = new WikiPageImpl[3];
7284    
7285                            array[0] = getByG_N_S_PrevAndNext(session, wikiPage, groupId,
7286                                            nodeId, status, orderByComparator, true);
7287    
7288                            array[1] = wikiPage;
7289    
7290                            array[2] = getByG_N_S_PrevAndNext(session, wikiPage, groupId,
7291                                            nodeId, status, orderByComparator, false);
7292    
7293                            return array;
7294                    }
7295                    catch (Exception e) {
7296                            throw processException(e);
7297                    }
7298                    finally {
7299                            closeSession(session);
7300                    }
7301            }
7302    
7303            protected WikiPage getByG_N_S_PrevAndNext(Session session,
7304                    WikiPage wikiPage, long groupId, long nodeId, int status,
7305                    OrderByComparator orderByComparator, boolean previous) {
7306                    StringBundler query = null;
7307    
7308                    if (orderByComparator != null) {
7309                            query = new StringBundler(6 +
7310                                            (orderByComparator.getOrderByFields().length * 6));
7311                    }
7312                    else {
7313                            query = new StringBundler(3);
7314                    }
7315    
7316                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7317    
7318                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
7319    
7320                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
7321    
7322                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
7323    
7324                    if (orderByComparator != null) {
7325                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7326    
7327                            if (orderByConditionFields.length > 0) {
7328                                    query.append(WHERE_AND);
7329                            }
7330    
7331                            for (int i = 0; i < orderByConditionFields.length; i++) {
7332                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7333                                    query.append(orderByConditionFields[i]);
7334    
7335                                    if ((i + 1) < orderByConditionFields.length) {
7336                                            if (orderByComparator.isAscending() ^ previous) {
7337                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7338                                            }
7339                                            else {
7340                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7341                                            }
7342                                    }
7343                                    else {
7344                                            if (orderByComparator.isAscending() ^ previous) {
7345                                                    query.append(WHERE_GREATER_THAN);
7346                                            }
7347                                            else {
7348                                                    query.append(WHERE_LESSER_THAN);
7349                                            }
7350                                    }
7351                            }
7352    
7353                            query.append(ORDER_BY_CLAUSE);
7354    
7355                            String[] orderByFields = orderByComparator.getOrderByFields();
7356    
7357                            for (int i = 0; i < orderByFields.length; i++) {
7358                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7359                                    query.append(orderByFields[i]);
7360    
7361                                    if ((i + 1) < orderByFields.length) {
7362                                            if (orderByComparator.isAscending() ^ previous) {
7363                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7364                                            }
7365                                            else {
7366                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7367                                            }
7368                                    }
7369                                    else {
7370                                            if (orderByComparator.isAscending() ^ previous) {
7371                                                    query.append(ORDER_BY_ASC);
7372                                            }
7373                                            else {
7374                                                    query.append(ORDER_BY_DESC);
7375                                            }
7376                                    }
7377                            }
7378                    }
7379    
7380                    else {
7381                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7382                    }
7383    
7384                    String sql = query.toString();
7385    
7386                    Query q = session.createQuery(sql);
7387    
7388                    q.setFirstResult(0);
7389                    q.setMaxResults(2);
7390    
7391                    QueryPos qPos = QueryPos.getInstance(q);
7392    
7393                    qPos.add(groupId);
7394    
7395                    qPos.add(nodeId);
7396    
7397                    qPos.add(status);
7398    
7399                    if (orderByComparator != null) {
7400                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
7401    
7402                            for (Object value : values) {
7403                                    qPos.add(value);
7404                            }
7405                    }
7406    
7407                    List<WikiPage> list = q.list();
7408    
7409                    if (list.size() == 2) {
7410                            return list.get(1);
7411                    }
7412                    else {
7413                            return null;
7414                    }
7415            }
7416    
7417            /**
7418             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
7419             *
7420             * @param groupId the group ID
7421             * @param nodeId the node ID
7422             * @param status the status
7423             * @return the matching wiki pages that the user has permission to view
7424             * @throws SystemException if a system exception occurred
7425             */
7426            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
7427                    int status) throws SystemException {
7428                    return filterFindByG_N_S(groupId, nodeId, status, QueryUtil.ALL_POS,
7429                            QueryUtil.ALL_POS, null);
7430            }
7431    
7432            /**
7433             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
7434             *
7435             * <p>
7436             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7437             * </p>
7438             *
7439             * @param groupId the group ID
7440             * @param nodeId the node ID
7441             * @param status the status
7442             * @param start the lower bound of the range of wiki pages
7443             * @param end the upper bound of the range of wiki pages (not inclusive)
7444             * @return the range of matching wiki pages that the user has permission to view
7445             * @throws SystemException if a system exception occurred
7446             */
7447            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
7448                    int status, int start, int end) throws SystemException {
7449                    return filterFindByG_N_S(groupId, nodeId, status, start, end, null);
7450            }
7451    
7452            /**
7453             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
7454             *
7455             * <p>
7456             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7457             * </p>
7458             *
7459             * @param groupId the group ID
7460             * @param nodeId the node ID
7461             * @param status the status
7462             * @param start the lower bound of the range of wiki pages
7463             * @param end the upper bound of the range of wiki pages (not inclusive)
7464             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7465             * @return the ordered range of matching wiki pages that the user has permission to view
7466             * @throws SystemException if a system exception occurred
7467             */
7468            public List<WikiPage> filterFindByG_N_S(long groupId, long nodeId,
7469                    int status, int start, int end, OrderByComparator orderByComparator)
7470                    throws SystemException {
7471                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7472                            return findByG_N_S(groupId, nodeId, status, start, end,
7473                                    orderByComparator);
7474                    }
7475    
7476                    StringBundler query = null;
7477    
7478                    if (orderByComparator != null) {
7479                            query = new StringBundler(5 +
7480                                            (orderByComparator.getOrderByFields().length * 3));
7481                    }
7482                    else {
7483                            query = new StringBundler(5);
7484                    }
7485    
7486                    if (getDB().isSupportsInlineDistinct()) {
7487                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
7488                    }
7489                    else {
7490                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
7491                    }
7492    
7493                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
7494    
7495                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
7496    
7497                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
7498    
7499                    if (!getDB().isSupportsInlineDistinct()) {
7500                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
7501                    }
7502    
7503                    if (orderByComparator != null) {
7504                            if (getDB().isSupportsInlineDistinct()) {
7505                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7506                                            orderByComparator);
7507                            }
7508                            else {
7509                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7510                                            orderByComparator);
7511                            }
7512                    }
7513    
7514                    else {
7515                            if (getDB().isSupportsInlineDistinct()) {
7516                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7517                            }
7518                            else {
7519                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
7520                            }
7521                    }
7522    
7523                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7524                                    WikiPage.class.getName(),
7525                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7526    
7527                    Session session = null;
7528    
7529                    try {
7530                            session = openSession();
7531    
7532                            SQLQuery q = session.createSQLQuery(sql);
7533    
7534                            if (getDB().isSupportsInlineDistinct()) {
7535                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
7536                            }
7537                            else {
7538                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
7539                            }
7540    
7541                            QueryPos qPos = QueryPos.getInstance(q);
7542    
7543                            qPos.add(groupId);
7544    
7545                            qPos.add(nodeId);
7546    
7547                            qPos.add(status);
7548    
7549                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
7550                    }
7551                    catch (Exception e) {
7552                            throw processException(e);
7553                    }
7554                    finally {
7555                            closeSession(session);
7556                    }
7557            }
7558    
7559            /**
7560             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
7561             *
7562             * @param pageId the primary key of the current wiki page
7563             * @param groupId the group ID
7564             * @param nodeId the node ID
7565             * @param status the status
7566             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7567             * @return the previous, current, and next wiki page
7568             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
7569             * @throws SystemException if a system exception occurred
7570             */
7571            public WikiPage[] filterFindByG_N_S_PrevAndNext(long pageId, long groupId,
7572                    long nodeId, int status, OrderByComparator orderByComparator)
7573                    throws NoSuchPageException, SystemException {
7574                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7575                            return findByG_N_S_PrevAndNext(pageId, groupId, nodeId, status,
7576                                    orderByComparator);
7577                    }
7578    
7579                    WikiPage wikiPage = findByPrimaryKey(pageId);
7580    
7581                    Session session = null;
7582    
7583                    try {
7584                            session = openSession();
7585    
7586                            WikiPage[] array = new WikiPageImpl[3];
7587    
7588                            array[0] = filterGetByG_N_S_PrevAndNext(session, wikiPage, groupId,
7589                                            nodeId, status, orderByComparator, true);
7590    
7591                            array[1] = wikiPage;
7592    
7593                            array[2] = filterGetByG_N_S_PrevAndNext(session, wikiPage, groupId,
7594                                            nodeId, status, orderByComparator, false);
7595    
7596                            return array;
7597                    }
7598                    catch (Exception e) {
7599                            throw processException(e);
7600                    }
7601                    finally {
7602                            closeSession(session);
7603                    }
7604            }
7605    
7606            protected WikiPage filterGetByG_N_S_PrevAndNext(Session session,
7607                    WikiPage wikiPage, long groupId, long nodeId, int status,
7608                    OrderByComparator orderByComparator, boolean previous) {
7609                    StringBundler query = null;
7610    
7611                    if (orderByComparator != null) {
7612                            query = new StringBundler(6 +
7613                                            (orderByComparator.getOrderByFields().length * 6));
7614                    }
7615                    else {
7616                            query = new StringBundler(3);
7617                    }
7618    
7619                    if (getDB().isSupportsInlineDistinct()) {
7620                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
7621                    }
7622                    else {
7623                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
7624                    }
7625    
7626                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
7627    
7628                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
7629    
7630                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
7631    
7632                    if (!getDB().isSupportsInlineDistinct()) {
7633                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
7634                    }
7635    
7636                    if (orderByComparator != null) {
7637                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7638    
7639                            if (orderByConditionFields.length > 0) {
7640                                    query.append(WHERE_AND);
7641                            }
7642    
7643                            for (int i = 0; i < orderByConditionFields.length; i++) {
7644                                    if (getDB().isSupportsInlineDistinct()) {
7645                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7646                                    }
7647                                    else {
7648                                            query.append(_ORDER_BY_ENTITY_TABLE);
7649                                    }
7650    
7651                                    query.append(orderByConditionFields[i]);
7652    
7653                                    if ((i + 1) < orderByConditionFields.length) {
7654                                            if (orderByComparator.isAscending() ^ previous) {
7655                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7656                                            }
7657                                            else {
7658                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7659                                            }
7660                                    }
7661                                    else {
7662                                            if (orderByComparator.isAscending() ^ previous) {
7663                                                    query.append(WHERE_GREATER_THAN);
7664                                            }
7665                                            else {
7666                                                    query.append(WHERE_LESSER_THAN);
7667                                            }
7668                                    }
7669                            }
7670    
7671                            query.append(ORDER_BY_CLAUSE);
7672    
7673                            String[] orderByFields = orderByComparator.getOrderByFields();
7674    
7675                            for (int i = 0; i < orderByFields.length; i++) {
7676                                    if (getDB().isSupportsInlineDistinct()) {
7677                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7678                                    }
7679                                    else {
7680                                            query.append(_ORDER_BY_ENTITY_TABLE);
7681                                    }
7682    
7683                                    query.append(orderByFields[i]);
7684    
7685                                    if ((i + 1) < orderByFields.length) {
7686                                            if (orderByComparator.isAscending() ^ previous) {
7687                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7688                                            }
7689                                            else {
7690                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7691                                            }
7692                                    }
7693                                    else {
7694                                            if (orderByComparator.isAscending() ^ previous) {
7695                                                    query.append(ORDER_BY_ASC);
7696                                            }
7697                                            else {
7698                                                    query.append(ORDER_BY_DESC);
7699                                            }
7700                                    }
7701                            }
7702                    }
7703    
7704                    else {
7705                            if (getDB().isSupportsInlineDistinct()) {
7706                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7707                            }
7708                            else {
7709                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
7710                            }
7711                    }
7712    
7713                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7714                                    WikiPage.class.getName(),
7715                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7716    
7717                    SQLQuery q = session.createSQLQuery(sql);
7718    
7719                    q.setFirstResult(0);
7720                    q.setMaxResults(2);
7721    
7722                    if (getDB().isSupportsInlineDistinct()) {
7723                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
7724                    }
7725                    else {
7726                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
7727                    }
7728    
7729                    QueryPos qPos = QueryPos.getInstance(q);
7730    
7731                    qPos.add(groupId);
7732    
7733                    qPos.add(nodeId);
7734    
7735                    qPos.add(status);
7736    
7737                    if (orderByComparator != null) {
7738                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
7739    
7740                            for (Object value : values) {
7741                                    qPos.add(value);
7742                            }
7743                    }
7744    
7745                    List<WikiPage> list = q.list();
7746    
7747                    if (list.size() == 2) {
7748                            return list.get(1);
7749                    }
7750                    else {
7751                            return null;
7752                    }
7753            }
7754    
7755            /**
7756             * Returns all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
7757             *
7758             * @param userId the user ID
7759             * @param nodeId the node ID
7760             * @param status the status
7761             * @return the matching wiki pages
7762             * @throws SystemException if a system exception occurred
7763             */
7764            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status)
7765                    throws SystemException {
7766                    return findByU_N_S(userId, nodeId, status, QueryUtil.ALL_POS,
7767                            QueryUtil.ALL_POS, null);
7768            }
7769    
7770            /**
7771             * Returns a range of all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
7772             *
7773             * <p>
7774             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7775             * </p>
7776             *
7777             * @param userId the user ID
7778             * @param nodeId the node ID
7779             * @param status the status
7780             * @param start the lower bound of the range of wiki pages
7781             * @param end the upper bound of the range of wiki pages (not inclusive)
7782             * @return the range of matching wiki pages
7783             * @throws SystemException if a system exception occurred
7784             */
7785            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status,
7786                    int start, int end) throws SystemException {
7787                    return findByU_N_S(userId, nodeId, status, start, end, null);
7788            }
7789    
7790            /**
7791             * Returns an ordered range of all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
7792             *
7793             * <p>
7794             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7795             * </p>
7796             *
7797             * @param userId the user ID
7798             * @param nodeId the node ID
7799             * @param status the status
7800             * @param start the lower bound of the range of wiki pages
7801             * @param end the upper bound of the range of wiki pages (not inclusive)
7802             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7803             * @return the ordered range of matching wiki pages
7804             * @throws SystemException if a system exception occurred
7805             */
7806            public List<WikiPage> findByU_N_S(long userId, long nodeId, int status,
7807                    int start, int end, OrderByComparator orderByComparator)
7808                    throws SystemException {
7809                    FinderPath finderPath = null;
7810                    Object[] finderArgs = null;
7811    
7812                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7813                                    (orderByComparator == null)) {
7814                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_N_S;
7815                            finderArgs = new Object[] { userId, nodeId, status };
7816                    }
7817                    else {
7818                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_N_S;
7819                            finderArgs = new Object[] {
7820                                            userId, nodeId, status,
7821                                            
7822                                            start, end, orderByComparator
7823                                    };
7824                    }
7825    
7826                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
7827                                    finderArgs, this);
7828    
7829                    if ((list != null) && !list.isEmpty()) {
7830                            for (WikiPage wikiPage : list) {
7831                                    if ((userId != wikiPage.getUserId()) ||
7832                                                    (nodeId != wikiPage.getNodeId()) ||
7833                                                    (status != wikiPage.getStatus())) {
7834                                            list = null;
7835    
7836                                            break;
7837                                    }
7838                            }
7839                    }
7840    
7841                    if (list == null) {
7842                            StringBundler query = null;
7843    
7844                            if (orderByComparator != null) {
7845                                    query = new StringBundler(5 +
7846                                                    (orderByComparator.getOrderByFields().length * 3));
7847                            }
7848                            else {
7849                                    query = new StringBundler(5);
7850                            }
7851    
7852                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
7853    
7854                            query.append(_FINDER_COLUMN_U_N_S_USERID_2);
7855    
7856                            query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
7857    
7858                            query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
7859    
7860                            if (orderByComparator != null) {
7861                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7862                                            orderByComparator);
7863                            }
7864    
7865                            else {
7866                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
7867                            }
7868    
7869                            String sql = query.toString();
7870    
7871                            Session session = null;
7872    
7873                            try {
7874                                    session = openSession();
7875    
7876                                    Query q = session.createQuery(sql);
7877    
7878                                    QueryPos qPos = QueryPos.getInstance(q);
7879    
7880                                    qPos.add(userId);
7881    
7882                                    qPos.add(nodeId);
7883    
7884                                    qPos.add(status);
7885    
7886                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
7887                                                    end);
7888                            }
7889                            catch (Exception e) {
7890                                    throw processException(e);
7891                            }
7892                            finally {
7893                                    if (list == null) {
7894                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7895                                    }
7896                                    else {
7897                                            cacheResult(list);
7898    
7899                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7900                                    }
7901    
7902                                    closeSession(session);
7903                            }
7904                    }
7905    
7906                    return list;
7907            }
7908    
7909            /**
7910             * Returns the first wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
7911             *
7912             * @param userId the user ID
7913             * @param nodeId the node ID
7914             * @param status the status
7915             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7916             * @return the first matching wiki page
7917             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7918             * @throws SystemException if a system exception occurred
7919             */
7920            public WikiPage findByU_N_S_First(long userId, long nodeId, int status,
7921                    OrderByComparator orderByComparator)
7922                    throws NoSuchPageException, SystemException {
7923                    WikiPage wikiPage = fetchByU_N_S_First(userId, nodeId, status,
7924                                    orderByComparator);
7925    
7926                    if (wikiPage != null) {
7927                            return wikiPage;
7928                    }
7929    
7930                    StringBundler msg = new StringBundler(8);
7931    
7932                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7933    
7934                    msg.append("userId=");
7935                    msg.append(userId);
7936    
7937                    msg.append(", nodeId=");
7938                    msg.append(nodeId);
7939    
7940                    msg.append(", status=");
7941                    msg.append(status);
7942    
7943                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7944    
7945                    throw new NoSuchPageException(msg.toString());
7946            }
7947    
7948            /**
7949             * Returns the first wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
7950             *
7951             * @param userId the user ID
7952             * @param nodeId the node ID
7953             * @param status the status
7954             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7955             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
7956             * @throws SystemException if a system exception occurred
7957             */
7958            public WikiPage fetchByU_N_S_First(long userId, long nodeId, int status,
7959                    OrderByComparator orderByComparator) throws SystemException {
7960                    List<WikiPage> list = findByU_N_S(userId, nodeId, status, 0, 1,
7961                                    orderByComparator);
7962    
7963                    if (!list.isEmpty()) {
7964                            return list.get(0);
7965                    }
7966    
7967                    return null;
7968            }
7969    
7970            /**
7971             * Returns the last wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
7972             *
7973             * @param userId the user ID
7974             * @param nodeId the node ID
7975             * @param status the status
7976             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7977             * @return the last matching wiki page
7978             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
7979             * @throws SystemException if a system exception occurred
7980             */
7981            public WikiPage findByU_N_S_Last(long userId, long nodeId, int status,
7982                    OrderByComparator orderByComparator)
7983                    throws NoSuchPageException, SystemException {
7984                    WikiPage wikiPage = fetchByU_N_S_Last(userId, nodeId, status,
7985                                    orderByComparator);
7986    
7987                    if (wikiPage != null) {
7988                            return wikiPage;
7989                    }
7990    
7991                    StringBundler msg = new StringBundler(8);
7992    
7993                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7994    
7995                    msg.append("userId=");
7996                    msg.append(userId);
7997    
7998                    msg.append(", nodeId=");
7999                    msg.append(nodeId);
8000    
8001                    msg.append(", status=");
8002                    msg.append(status);
8003    
8004                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8005    
8006                    throw new NoSuchPageException(msg.toString());
8007            }
8008    
8009            /**
8010             * Returns the last wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
8011             *
8012             * @param userId the user ID
8013             * @param nodeId the node ID
8014             * @param status the status
8015             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8016             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
8017             * @throws SystemException if a system exception occurred
8018             */
8019            public WikiPage fetchByU_N_S_Last(long userId, long nodeId, int status,
8020                    OrderByComparator orderByComparator) throws SystemException {
8021                    int count = countByU_N_S(userId, nodeId, status);
8022    
8023                    List<WikiPage> list = findByU_N_S(userId, nodeId, status, count - 1,
8024                                    count, orderByComparator);
8025    
8026                    if (!list.isEmpty()) {
8027                            return list.get(0);
8028                    }
8029    
8030                    return null;
8031            }
8032    
8033            /**
8034             * Returns the wiki pages before and after the current wiki page in the ordered set where userId = &#63; and nodeId = &#63; and status = &#63;.
8035             *
8036             * @param pageId the primary key of the current wiki page
8037             * @param userId the user ID
8038             * @param nodeId the node ID
8039             * @param status the status
8040             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8041             * @return the previous, current, and next wiki page
8042             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
8043             * @throws SystemException if a system exception occurred
8044             */
8045            public WikiPage[] findByU_N_S_PrevAndNext(long pageId, long userId,
8046                    long nodeId, int status, OrderByComparator orderByComparator)
8047                    throws NoSuchPageException, SystemException {
8048                    WikiPage wikiPage = findByPrimaryKey(pageId);
8049    
8050                    Session session = null;
8051    
8052                    try {
8053                            session = openSession();
8054    
8055                            WikiPage[] array = new WikiPageImpl[3];
8056    
8057                            array[0] = getByU_N_S_PrevAndNext(session, wikiPage, userId,
8058                                            nodeId, status, orderByComparator, true);
8059    
8060                            array[1] = wikiPage;
8061    
8062                            array[2] = getByU_N_S_PrevAndNext(session, wikiPage, userId,
8063                                            nodeId, status, orderByComparator, false);
8064    
8065                            return array;
8066                    }
8067                    catch (Exception e) {
8068                            throw processException(e);
8069                    }
8070                    finally {
8071                            closeSession(session);
8072                    }
8073            }
8074    
8075            protected WikiPage getByU_N_S_PrevAndNext(Session session,
8076                    WikiPage wikiPage, long userId, long nodeId, int status,
8077                    OrderByComparator orderByComparator, boolean previous) {
8078                    StringBundler query = null;
8079    
8080                    if (orderByComparator != null) {
8081                            query = new StringBundler(6 +
8082                                            (orderByComparator.getOrderByFields().length * 6));
8083                    }
8084                    else {
8085                            query = new StringBundler(3);
8086                    }
8087    
8088                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8089    
8090                    query.append(_FINDER_COLUMN_U_N_S_USERID_2);
8091    
8092                    query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
8093    
8094                    query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
8095    
8096                    if (orderByComparator != null) {
8097                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8098    
8099                            if (orderByConditionFields.length > 0) {
8100                                    query.append(WHERE_AND);
8101                            }
8102    
8103                            for (int i = 0; i < orderByConditionFields.length; i++) {
8104                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8105                                    query.append(orderByConditionFields[i]);
8106    
8107                                    if ((i + 1) < orderByConditionFields.length) {
8108                                            if (orderByComparator.isAscending() ^ previous) {
8109                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8110                                            }
8111                                            else {
8112                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8113                                            }
8114                                    }
8115                                    else {
8116                                            if (orderByComparator.isAscending() ^ previous) {
8117                                                    query.append(WHERE_GREATER_THAN);
8118                                            }
8119                                            else {
8120                                                    query.append(WHERE_LESSER_THAN);
8121                                            }
8122                                    }
8123                            }
8124    
8125                            query.append(ORDER_BY_CLAUSE);
8126    
8127                            String[] orderByFields = orderByComparator.getOrderByFields();
8128    
8129                            for (int i = 0; i < orderByFields.length; i++) {
8130                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8131                                    query.append(orderByFields[i]);
8132    
8133                                    if ((i + 1) < orderByFields.length) {
8134                                            if (orderByComparator.isAscending() ^ previous) {
8135                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8136                                            }
8137                                            else {
8138                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8139                                            }
8140                                    }
8141                                    else {
8142                                            if (orderByComparator.isAscending() ^ previous) {
8143                                                    query.append(ORDER_BY_ASC);
8144                                            }
8145                                            else {
8146                                                    query.append(ORDER_BY_DESC);
8147                                            }
8148                                    }
8149                            }
8150                    }
8151    
8152                    else {
8153                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8154                    }
8155    
8156                    String sql = query.toString();
8157    
8158                    Query q = session.createQuery(sql);
8159    
8160                    q.setFirstResult(0);
8161                    q.setMaxResults(2);
8162    
8163                    QueryPos qPos = QueryPos.getInstance(q);
8164    
8165                    qPos.add(userId);
8166    
8167                    qPos.add(nodeId);
8168    
8169                    qPos.add(status);
8170    
8171                    if (orderByComparator != null) {
8172                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
8173    
8174                            for (Object value : values) {
8175                                    qPos.add(value);
8176                            }
8177                    }
8178    
8179                    List<WikiPage> list = q.list();
8180    
8181                    if (list.size() == 2) {
8182                            return list.get(1);
8183                    }
8184                    else {
8185                            return null;
8186                    }
8187            }
8188    
8189            /**
8190             * 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.
8191             *
8192             * @param nodeId the node ID
8193             * @param title the title
8194             * @param version the version
8195             * @return the matching wiki page
8196             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
8197             * @throws SystemException if a system exception occurred
8198             */
8199            public WikiPage findByN_T_V(long nodeId, String title, double version)
8200                    throws NoSuchPageException, SystemException {
8201                    WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
8202    
8203                    if (wikiPage == null) {
8204                            StringBundler msg = new StringBundler(8);
8205    
8206                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8207    
8208                            msg.append("nodeId=");
8209                            msg.append(nodeId);
8210    
8211                            msg.append(", title=");
8212                            msg.append(title);
8213    
8214                            msg.append(", version=");
8215                            msg.append(version);
8216    
8217                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8218    
8219                            if (_log.isWarnEnabled()) {
8220                                    _log.warn(msg.toString());
8221                            }
8222    
8223                            throw new NoSuchPageException(msg.toString());
8224                    }
8225    
8226                    return wikiPage;
8227            }
8228    
8229            /**
8230             * 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.
8231             *
8232             * @param nodeId the node ID
8233             * @param title the title
8234             * @param version the version
8235             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
8236             * @throws SystemException if a system exception occurred
8237             */
8238            public WikiPage fetchByN_T_V(long nodeId, String title, double version)
8239                    throws SystemException {
8240                    return fetchByN_T_V(nodeId, title, version, true);
8241            }
8242    
8243            /**
8244             * 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.
8245             *
8246             * @param nodeId the node ID
8247             * @param title the title
8248             * @param version the version
8249             * @param retrieveFromCache whether to use the finder cache
8250             * @return the matching wiki page, or <code>null</code> if a matching wiki page could not be found
8251             * @throws SystemException if a system exception occurred
8252             */
8253            public WikiPage fetchByN_T_V(long nodeId, String title, double version,
8254                    boolean retrieveFromCache) throws SystemException {
8255                    Object[] finderArgs = new Object[] { nodeId, title, version };
8256    
8257                    Object result = null;
8258    
8259                    if (retrieveFromCache) {
8260                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T_V,
8261                                            finderArgs, this);
8262                    }
8263    
8264                    if (result instanceof WikiPage) {
8265                            WikiPage wikiPage = (WikiPage)result;
8266    
8267                            if ((nodeId != wikiPage.getNodeId()) ||
8268                                            !Validator.equals(title, wikiPage.getTitle()) ||
8269                                            (version != wikiPage.getVersion())) {
8270                                    result = null;
8271                            }
8272                    }
8273    
8274                    if (result == null) {
8275                            StringBundler query = new StringBundler(5);
8276    
8277                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8278    
8279                            query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
8280    
8281                            if (title == null) {
8282                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
8283                            }
8284                            else {
8285                                    if (title.equals(StringPool.BLANK)) {
8286                                            query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
8287                                    }
8288                                    else {
8289                                            query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
8290                                    }
8291                            }
8292    
8293                            query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
8294    
8295                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8296    
8297                            String sql = query.toString();
8298    
8299                            Session session = null;
8300    
8301                            try {
8302                                    session = openSession();
8303    
8304                                    Query q = session.createQuery(sql);
8305    
8306                                    QueryPos qPos = QueryPos.getInstance(q);
8307    
8308                                    qPos.add(nodeId);
8309    
8310                                    if (title != null) {
8311                                            qPos.add(title);
8312                                    }
8313    
8314                                    qPos.add(version);
8315    
8316                                    List<WikiPage> list = q.list();
8317    
8318                                    result = list;
8319    
8320                                    WikiPage wikiPage = null;
8321    
8322                                    if (list.isEmpty()) {
8323                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
8324                                                    finderArgs, list);
8325                                    }
8326                                    else {
8327                                            wikiPage = list.get(0);
8328    
8329                                            cacheResult(wikiPage);
8330    
8331                                            if ((wikiPage.getNodeId() != nodeId) ||
8332                                                            (wikiPage.getTitle() == null) ||
8333                                                            !wikiPage.getTitle().equals(title) ||
8334                                                            (wikiPage.getVersion() != version)) {
8335                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
8336                                                            finderArgs, wikiPage);
8337                                            }
8338                                    }
8339    
8340                                    return wikiPage;
8341                            }
8342                            catch (Exception e) {
8343                                    throw processException(e);
8344                            }
8345                            finally {
8346                                    if (result == null) {
8347                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
8348                                                    finderArgs);
8349                                    }
8350    
8351                                    closeSession(session);
8352                            }
8353                    }
8354                    else {
8355                            if (result instanceof List<?>) {
8356                                    return null;
8357                            }
8358                            else {
8359                                    return (WikiPage)result;
8360                            }
8361                    }
8362            }
8363    
8364            /**
8365             * Returns all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
8366             *
8367             * @param nodeId the node ID
8368             * @param title the title
8369             * @param head the head
8370             * @return the matching wiki pages
8371             * @throws SystemException if a system exception occurred
8372             */
8373            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head)
8374                    throws SystemException {
8375                    return findByN_T_H(nodeId, title, head, QueryUtil.ALL_POS,
8376                            QueryUtil.ALL_POS, null);
8377            }
8378    
8379            /**
8380             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
8381             *
8382             * <p>
8383             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8384             * </p>
8385             *
8386             * @param nodeId the node ID
8387             * @param title the title
8388             * @param head the head
8389             * @param start the lower bound of the range of wiki pages
8390             * @param end the upper bound of the range of wiki pages (not inclusive)
8391             * @return the range of matching wiki pages
8392             * @throws SystemException if a system exception occurred
8393             */
8394            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
8395                    int start, int end) throws SystemException {
8396                    return findByN_T_H(nodeId, title, head, start, end, null);
8397            }
8398    
8399            /**
8400             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
8401             *
8402             * <p>
8403             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8404             * </p>
8405             *
8406             * @param nodeId the node ID
8407             * @param title the title
8408             * @param head the head
8409             * @param start the lower bound of the range of wiki pages
8410             * @param end the upper bound of the range of wiki pages (not inclusive)
8411             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8412             * @return the ordered range of matching wiki pages
8413             * @throws SystemException if a system exception occurred
8414             */
8415            public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
8416                    int start, int end, OrderByComparator orderByComparator)
8417                    throws SystemException {
8418                    FinderPath finderPath = null;
8419                    Object[] finderArgs = null;
8420    
8421                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8422                                    (orderByComparator == null)) {
8423                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_H;
8424                            finderArgs = new Object[] { nodeId, title, head };
8425                    }
8426                    else {
8427                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_H;
8428                            finderArgs = new Object[] {
8429                                            nodeId, title, head,
8430                                            
8431                                            start, end, orderByComparator
8432                                    };
8433                    }
8434    
8435                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
8436                                    finderArgs, this);
8437    
8438                    if ((list != null) && !list.isEmpty()) {
8439                            for (WikiPage wikiPage : list) {
8440                                    if ((nodeId != wikiPage.getNodeId()) ||
8441                                                    !Validator.equals(title, wikiPage.getTitle()) ||
8442                                                    (head != wikiPage.getHead())) {
8443                                            list = null;
8444    
8445                                            break;
8446                                    }
8447                            }
8448                    }
8449    
8450                    if (list == null) {
8451                            StringBundler query = null;
8452    
8453                            if (orderByComparator != null) {
8454                                    query = new StringBundler(5 +
8455                                                    (orderByComparator.getOrderByFields().length * 3));
8456                            }
8457                            else {
8458                                    query = new StringBundler(5);
8459                            }
8460    
8461                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8462    
8463                            query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
8464    
8465                            if (title == null) {
8466                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
8467                            }
8468                            else {
8469                                    if (title.equals(StringPool.BLANK)) {
8470                                            query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
8471                                    }
8472                                    else {
8473                                            query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
8474                                    }
8475                            }
8476    
8477                            query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
8478    
8479                            if (orderByComparator != null) {
8480                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8481                                            orderByComparator);
8482                            }
8483    
8484                            else {
8485                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8486                            }
8487    
8488                            String sql = query.toString();
8489    
8490                            Session session = null;
8491    
8492                            try {
8493                                    session = openSession();
8494    
8495                                    Query q = session.createQuery(sql);
8496    
8497                                    QueryPos qPos = QueryPos.getInstance(q);
8498    
8499                                    qPos.add(nodeId);
8500    
8501                                    if (title != null) {
8502                                            qPos.add(title);
8503                                    }
8504    
8505                                    qPos.add(head);
8506    
8507                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
8508                                                    end);
8509                            }
8510                            catch (Exception e) {
8511                                    throw processException(e);
8512                            }
8513                            finally {
8514                                    if (list == null) {
8515                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8516                                    }
8517                                    else {
8518                                            cacheResult(list);
8519    
8520                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8521                                    }
8522    
8523                                    closeSession(session);
8524                            }
8525                    }
8526    
8527                    return list;
8528            }
8529    
8530            /**
8531             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
8532             *
8533             * @param nodeId the node ID
8534             * @param title the title
8535             * @param head the head
8536             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8537             * @return the first matching wiki page
8538             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
8539             * @throws SystemException if a system exception occurred
8540             */
8541            public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
8542                    OrderByComparator orderByComparator)
8543                    throws NoSuchPageException, SystemException {
8544                    WikiPage wikiPage = fetchByN_T_H_First(nodeId, title, head,
8545                                    orderByComparator);
8546    
8547                    if (wikiPage != null) {
8548                            return wikiPage;
8549                    }
8550    
8551                    StringBundler msg = new StringBundler(8);
8552    
8553                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8554    
8555                    msg.append("nodeId=");
8556                    msg.append(nodeId);
8557    
8558                    msg.append(", title=");
8559                    msg.append(title);
8560    
8561                    msg.append(", head=");
8562                    msg.append(head);
8563    
8564                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8565    
8566                    throw new NoSuchPageException(msg.toString());
8567            }
8568    
8569            /**
8570             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
8571             *
8572             * @param nodeId the node ID
8573             * @param title the title
8574             * @param head the head
8575             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8576             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
8577             * @throws SystemException if a system exception occurred
8578             */
8579            public WikiPage fetchByN_T_H_First(long nodeId, String title, boolean head,
8580                    OrderByComparator orderByComparator) throws SystemException {
8581                    List<WikiPage> list = findByN_T_H(nodeId, title, head, 0, 1,
8582                                    orderByComparator);
8583    
8584                    if (!list.isEmpty()) {
8585                            return list.get(0);
8586                    }
8587    
8588                    return null;
8589            }
8590    
8591            /**
8592             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
8593             *
8594             * @param nodeId the node ID
8595             * @param title the title
8596             * @param head the head
8597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8598             * @return the last matching wiki page
8599             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
8600             * @throws SystemException if a system exception occurred
8601             */
8602            public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
8603                    OrderByComparator orderByComparator)
8604                    throws NoSuchPageException, SystemException {
8605                    WikiPage wikiPage = fetchByN_T_H_Last(nodeId, title, head,
8606                                    orderByComparator);
8607    
8608                    if (wikiPage != null) {
8609                            return wikiPage;
8610                    }
8611    
8612                    StringBundler msg = new StringBundler(8);
8613    
8614                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8615    
8616                    msg.append("nodeId=");
8617                    msg.append(nodeId);
8618    
8619                    msg.append(", title=");
8620                    msg.append(title);
8621    
8622                    msg.append(", head=");
8623                    msg.append(head);
8624    
8625                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8626    
8627                    throw new NoSuchPageException(msg.toString());
8628            }
8629    
8630            /**
8631             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
8632             *
8633             * @param nodeId the node ID
8634             * @param title the title
8635             * @param head the head
8636             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8637             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
8638             * @throws SystemException if a system exception occurred
8639             */
8640            public WikiPage fetchByN_T_H_Last(long nodeId, String title, boolean head,
8641                    OrderByComparator orderByComparator) throws SystemException {
8642                    int count = countByN_T_H(nodeId, title, head);
8643    
8644                    List<WikiPage> list = findByN_T_H(nodeId, title, head, count - 1,
8645                                    count, orderByComparator);
8646    
8647                    if (!list.isEmpty()) {
8648                            return list.get(0);
8649                    }
8650    
8651                    return null;
8652            }
8653    
8654            /**
8655             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63; and head = &#63;.
8656             *
8657             * @param pageId the primary key of the current wiki page
8658             * @param nodeId the node ID
8659             * @param title the title
8660             * @param head the head
8661             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8662             * @return the previous, current, and next wiki page
8663             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
8664             * @throws SystemException if a system exception occurred
8665             */
8666            public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
8667                    String title, boolean head, OrderByComparator orderByComparator)
8668                    throws NoSuchPageException, SystemException {
8669                    WikiPage wikiPage = findByPrimaryKey(pageId);
8670    
8671                    Session session = null;
8672    
8673                    try {
8674                            session = openSession();
8675    
8676                            WikiPage[] array = new WikiPageImpl[3];
8677    
8678                            array[0] = getByN_T_H_PrevAndNext(session, wikiPage, nodeId, title,
8679                                            head, orderByComparator, true);
8680    
8681                            array[1] = wikiPage;
8682    
8683                            array[2] = getByN_T_H_PrevAndNext(session, wikiPage, nodeId, title,
8684                                            head, orderByComparator, false);
8685    
8686                            return array;
8687                    }
8688                    catch (Exception e) {
8689                            throw processException(e);
8690                    }
8691                    finally {
8692                            closeSession(session);
8693                    }
8694            }
8695    
8696            protected WikiPage getByN_T_H_PrevAndNext(Session session,
8697                    WikiPage wikiPage, long nodeId, String title, boolean head,
8698                    OrderByComparator orderByComparator, boolean previous) {
8699                    StringBundler query = null;
8700    
8701                    if (orderByComparator != null) {
8702                            query = new StringBundler(6 +
8703                                            (orderByComparator.getOrderByFields().length * 6));
8704                    }
8705                    else {
8706                            query = new StringBundler(3);
8707                    }
8708    
8709                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8710    
8711                    query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
8712    
8713                    if (title == null) {
8714                            query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
8715                    }
8716                    else {
8717                            if (title.equals(StringPool.BLANK)) {
8718                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
8719                            }
8720                            else {
8721                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
8722                            }
8723                    }
8724    
8725                    query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
8726    
8727                    if (orderByComparator != null) {
8728                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8729    
8730                            if (orderByConditionFields.length > 0) {
8731                                    query.append(WHERE_AND);
8732                            }
8733    
8734                            for (int i = 0; i < orderByConditionFields.length; i++) {
8735                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8736                                    query.append(orderByConditionFields[i]);
8737    
8738                                    if ((i + 1) < orderByConditionFields.length) {
8739                                            if (orderByComparator.isAscending() ^ previous) {
8740                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8741                                            }
8742                                            else {
8743                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8744                                            }
8745                                    }
8746                                    else {
8747                                            if (orderByComparator.isAscending() ^ previous) {
8748                                                    query.append(WHERE_GREATER_THAN);
8749                                            }
8750                                            else {
8751                                                    query.append(WHERE_LESSER_THAN);
8752                                            }
8753                                    }
8754                            }
8755    
8756                            query.append(ORDER_BY_CLAUSE);
8757    
8758                            String[] orderByFields = orderByComparator.getOrderByFields();
8759    
8760                            for (int i = 0; i < orderByFields.length; i++) {
8761                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8762                                    query.append(orderByFields[i]);
8763    
8764                                    if ((i + 1) < orderByFields.length) {
8765                                            if (orderByComparator.isAscending() ^ previous) {
8766                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8767                                            }
8768                                            else {
8769                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8770                                            }
8771                                    }
8772                                    else {
8773                                            if (orderByComparator.isAscending() ^ previous) {
8774                                                    query.append(ORDER_BY_ASC);
8775                                            }
8776                                            else {
8777                                                    query.append(ORDER_BY_DESC);
8778                                            }
8779                                    }
8780                            }
8781                    }
8782    
8783                    else {
8784                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8785                    }
8786    
8787                    String sql = query.toString();
8788    
8789                    Query q = session.createQuery(sql);
8790    
8791                    q.setFirstResult(0);
8792                    q.setMaxResults(2);
8793    
8794                    QueryPos qPos = QueryPos.getInstance(q);
8795    
8796                    qPos.add(nodeId);
8797    
8798                    if (title != null) {
8799                            qPos.add(title);
8800                    }
8801    
8802                    qPos.add(head);
8803    
8804                    if (orderByComparator != null) {
8805                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
8806    
8807                            for (Object value : values) {
8808                                    qPos.add(value);
8809                            }
8810                    }
8811    
8812                    List<WikiPage> list = q.list();
8813    
8814                    if (list.size() == 2) {
8815                            return list.get(1);
8816                    }
8817                    else {
8818                            return null;
8819                    }
8820            }
8821    
8822            /**
8823             * Returns all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
8824             *
8825             * @param nodeId the node ID
8826             * @param title the title
8827             * @param status the status
8828             * @return the matching wiki pages
8829             * @throws SystemException if a system exception occurred
8830             */
8831            public List<WikiPage> findByN_T_S(long nodeId, String title, int status)
8832                    throws SystemException {
8833                    return findByN_T_S(nodeId, title, status, QueryUtil.ALL_POS,
8834                            QueryUtil.ALL_POS, null);
8835            }
8836    
8837            /**
8838             * Returns a range of all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
8839             *
8840             * <p>
8841             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8842             * </p>
8843             *
8844             * @param nodeId the node ID
8845             * @param title the title
8846             * @param status the status
8847             * @param start the lower bound of the range of wiki pages
8848             * @param end the upper bound of the range of wiki pages (not inclusive)
8849             * @return the range of matching wiki pages
8850             * @throws SystemException if a system exception occurred
8851             */
8852            public List<WikiPage> findByN_T_S(long nodeId, String title, int status,
8853                    int start, int end) throws SystemException {
8854                    return findByN_T_S(nodeId, title, status, start, end, null);
8855            }
8856    
8857            /**
8858             * Returns an ordered range of all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
8859             *
8860             * <p>
8861             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8862             * </p>
8863             *
8864             * @param nodeId the node ID
8865             * @param title the title
8866             * @param status the status
8867             * @param start the lower bound of the range of wiki pages
8868             * @param end the upper bound of the range of wiki pages (not inclusive)
8869             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8870             * @return the ordered range of matching wiki pages
8871             * @throws SystemException if a system exception occurred
8872             */
8873            public List<WikiPage> findByN_T_S(long nodeId, String title, int status,
8874                    int start, int end, OrderByComparator orderByComparator)
8875                    throws SystemException {
8876                    FinderPath finderPath = null;
8877                    Object[] finderArgs = null;
8878    
8879                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8880                                    (orderByComparator == null)) {
8881                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_T_S;
8882                            finderArgs = new Object[] { nodeId, title, status };
8883                    }
8884                    else {
8885                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_T_S;
8886                            finderArgs = new Object[] {
8887                                            nodeId, title, status,
8888                                            
8889                                            start, end, orderByComparator
8890                                    };
8891                    }
8892    
8893                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
8894                                    finderArgs, this);
8895    
8896                    if ((list != null) && !list.isEmpty()) {
8897                            for (WikiPage wikiPage : list) {
8898                                    if ((nodeId != wikiPage.getNodeId()) ||
8899                                                    !Validator.equals(title, wikiPage.getTitle()) ||
8900                                                    (status != wikiPage.getStatus())) {
8901                                            list = null;
8902    
8903                                            break;
8904                                    }
8905                            }
8906                    }
8907    
8908                    if (list == null) {
8909                            StringBundler query = null;
8910    
8911                            if (orderByComparator != null) {
8912                                    query = new StringBundler(5 +
8913                                                    (orderByComparator.getOrderByFields().length * 3));
8914                            }
8915                            else {
8916                                    query = new StringBundler(5);
8917                            }
8918    
8919                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
8920    
8921                            query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
8922    
8923                            if (title == null) {
8924                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
8925                            }
8926                            else {
8927                                    if (title.equals(StringPool.BLANK)) {
8928                                            query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
8929                                    }
8930                                    else {
8931                                            query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
8932                                    }
8933                            }
8934    
8935                            query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
8936    
8937                            if (orderByComparator != null) {
8938                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8939                                            orderByComparator);
8940                            }
8941    
8942                            else {
8943                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
8944                            }
8945    
8946                            String sql = query.toString();
8947    
8948                            Session session = null;
8949    
8950                            try {
8951                                    session = openSession();
8952    
8953                                    Query q = session.createQuery(sql);
8954    
8955                                    QueryPos qPos = QueryPos.getInstance(q);
8956    
8957                                    qPos.add(nodeId);
8958    
8959                                    if (title != null) {
8960                                            qPos.add(title);
8961                                    }
8962    
8963                                    qPos.add(status);
8964    
8965                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
8966                                                    end);
8967                            }
8968                            catch (Exception e) {
8969                                    throw processException(e);
8970                            }
8971                            finally {
8972                                    if (list == null) {
8973                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8974                                    }
8975                                    else {
8976                                            cacheResult(list);
8977    
8978                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8979                                    }
8980    
8981                                    closeSession(session);
8982                            }
8983                    }
8984    
8985                    return list;
8986            }
8987    
8988            /**
8989             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
8990             *
8991             * @param nodeId the node ID
8992             * @param title the title
8993             * @param status the status
8994             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8995             * @return the first matching wiki page
8996             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
8997             * @throws SystemException if a system exception occurred
8998             */
8999            public WikiPage findByN_T_S_First(long nodeId, String title, int status,
9000                    OrderByComparator orderByComparator)
9001                    throws NoSuchPageException, SystemException {
9002                    WikiPage wikiPage = fetchByN_T_S_First(nodeId, title, status,
9003                                    orderByComparator);
9004    
9005                    if (wikiPage != null) {
9006                            return wikiPage;
9007                    }
9008    
9009                    StringBundler msg = new StringBundler(8);
9010    
9011                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9012    
9013                    msg.append("nodeId=");
9014                    msg.append(nodeId);
9015    
9016                    msg.append(", title=");
9017                    msg.append(title);
9018    
9019                    msg.append(", status=");
9020                    msg.append(status);
9021    
9022                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9023    
9024                    throw new NoSuchPageException(msg.toString());
9025            }
9026    
9027            /**
9028             * Returns the first wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
9029             *
9030             * @param nodeId the node ID
9031             * @param title the title
9032             * @param status the status
9033             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9034             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
9035             * @throws SystemException if a system exception occurred
9036             */
9037            public WikiPage fetchByN_T_S_First(long nodeId, String title, int status,
9038                    OrderByComparator orderByComparator) throws SystemException {
9039                    List<WikiPage> list = findByN_T_S(nodeId, title, status, 0, 1,
9040                                    orderByComparator);
9041    
9042                    if (!list.isEmpty()) {
9043                            return list.get(0);
9044                    }
9045    
9046                    return null;
9047            }
9048    
9049            /**
9050             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
9051             *
9052             * @param nodeId the node ID
9053             * @param title the title
9054             * @param status the status
9055             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9056             * @return the last matching wiki page
9057             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9058             * @throws SystemException if a system exception occurred
9059             */
9060            public WikiPage findByN_T_S_Last(long nodeId, String title, int status,
9061                    OrderByComparator orderByComparator)
9062                    throws NoSuchPageException, SystemException {
9063                    WikiPage wikiPage = fetchByN_T_S_Last(nodeId, title, status,
9064                                    orderByComparator);
9065    
9066                    if (wikiPage != null) {
9067                            return wikiPage;
9068                    }
9069    
9070                    StringBundler msg = new StringBundler(8);
9071    
9072                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9073    
9074                    msg.append("nodeId=");
9075                    msg.append(nodeId);
9076    
9077                    msg.append(", title=");
9078                    msg.append(title);
9079    
9080                    msg.append(", status=");
9081                    msg.append(status);
9082    
9083                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9084    
9085                    throw new NoSuchPageException(msg.toString());
9086            }
9087    
9088            /**
9089             * Returns the last wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
9090             *
9091             * @param nodeId the node ID
9092             * @param title the title
9093             * @param status the status
9094             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9095             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
9096             * @throws SystemException if a system exception occurred
9097             */
9098            public WikiPage fetchByN_T_S_Last(long nodeId, String title, int status,
9099                    OrderByComparator orderByComparator) throws SystemException {
9100                    int count = countByN_T_S(nodeId, title, status);
9101    
9102                    List<WikiPage> list = findByN_T_S(nodeId, title, status, count - 1,
9103                                    count, orderByComparator);
9104    
9105                    if (!list.isEmpty()) {
9106                            return list.get(0);
9107                    }
9108    
9109                    return null;
9110            }
9111    
9112            /**
9113             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and title = &#63; and status = &#63;.
9114             *
9115             * @param pageId the primary key of the current wiki page
9116             * @param nodeId the node ID
9117             * @param title the title
9118             * @param status the status
9119             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9120             * @return the previous, current, and next wiki page
9121             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
9122             * @throws SystemException if a system exception occurred
9123             */
9124            public WikiPage[] findByN_T_S_PrevAndNext(long pageId, long nodeId,
9125                    String title, int status, OrderByComparator orderByComparator)
9126                    throws NoSuchPageException, SystemException {
9127                    WikiPage wikiPage = findByPrimaryKey(pageId);
9128    
9129                    Session session = null;
9130    
9131                    try {
9132                            session = openSession();
9133    
9134                            WikiPage[] array = new WikiPageImpl[3];
9135    
9136                            array[0] = getByN_T_S_PrevAndNext(session, wikiPage, nodeId, title,
9137                                            status, orderByComparator, true);
9138    
9139                            array[1] = wikiPage;
9140    
9141                            array[2] = getByN_T_S_PrevAndNext(session, wikiPage, nodeId, title,
9142                                            status, orderByComparator, false);
9143    
9144                            return array;
9145                    }
9146                    catch (Exception e) {
9147                            throw processException(e);
9148                    }
9149                    finally {
9150                            closeSession(session);
9151                    }
9152            }
9153    
9154            protected WikiPage getByN_T_S_PrevAndNext(Session session,
9155                    WikiPage wikiPage, long nodeId, String title, int status,
9156                    OrderByComparator orderByComparator, boolean previous) {
9157                    StringBundler query = null;
9158    
9159                    if (orderByComparator != null) {
9160                            query = new StringBundler(6 +
9161                                            (orderByComparator.getOrderByFields().length * 6));
9162                    }
9163                    else {
9164                            query = new StringBundler(3);
9165                    }
9166    
9167                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9168    
9169                    query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
9170    
9171                    if (title == null) {
9172                            query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
9173                    }
9174                    else {
9175                            if (title.equals(StringPool.BLANK)) {
9176                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
9177                            }
9178                            else {
9179                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
9180                            }
9181                    }
9182    
9183                    query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
9184    
9185                    if (orderByComparator != null) {
9186                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9187    
9188                            if (orderByConditionFields.length > 0) {
9189                                    query.append(WHERE_AND);
9190                            }
9191    
9192                            for (int i = 0; i < orderByConditionFields.length; i++) {
9193                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9194                                    query.append(orderByConditionFields[i]);
9195    
9196                                    if ((i + 1) < orderByConditionFields.length) {
9197                                            if (orderByComparator.isAscending() ^ previous) {
9198                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9199                                            }
9200                                            else {
9201                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9202                                            }
9203                                    }
9204                                    else {
9205                                            if (orderByComparator.isAscending() ^ previous) {
9206                                                    query.append(WHERE_GREATER_THAN);
9207                                            }
9208                                            else {
9209                                                    query.append(WHERE_LESSER_THAN);
9210                                            }
9211                                    }
9212                            }
9213    
9214                            query.append(ORDER_BY_CLAUSE);
9215    
9216                            String[] orderByFields = orderByComparator.getOrderByFields();
9217    
9218                            for (int i = 0; i < orderByFields.length; i++) {
9219                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9220                                    query.append(orderByFields[i]);
9221    
9222                                    if ((i + 1) < orderByFields.length) {
9223                                            if (orderByComparator.isAscending() ^ previous) {
9224                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9225                                            }
9226                                            else {
9227                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9228                                            }
9229                                    }
9230                                    else {
9231                                            if (orderByComparator.isAscending() ^ previous) {
9232                                                    query.append(ORDER_BY_ASC);
9233                                            }
9234                                            else {
9235                                                    query.append(ORDER_BY_DESC);
9236                                            }
9237                                    }
9238                            }
9239                    }
9240    
9241                    else {
9242                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9243                    }
9244    
9245                    String sql = query.toString();
9246    
9247                    Query q = session.createQuery(sql);
9248    
9249                    q.setFirstResult(0);
9250                    q.setMaxResults(2);
9251    
9252                    QueryPos qPos = QueryPos.getInstance(q);
9253    
9254                    qPos.add(nodeId);
9255    
9256                    if (title != null) {
9257                            qPos.add(title);
9258                    }
9259    
9260                    qPos.add(status);
9261    
9262                    if (orderByComparator != null) {
9263                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
9264    
9265                            for (Object value : values) {
9266                                    qPos.add(value);
9267                            }
9268                    }
9269    
9270                    List<WikiPage> list = q.list();
9271    
9272                    if (list.size() == 2) {
9273                            return list.get(1);
9274                    }
9275                    else {
9276                            return null;
9277                    }
9278            }
9279    
9280            /**
9281             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
9282             *
9283             * @param nodeId the node ID
9284             * @param head the head
9285             * @param parentTitle the parent title
9286             * @return the matching wiki pages
9287             * @throws SystemException if a system exception occurred
9288             */
9289            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
9290                    String parentTitle) throws SystemException {
9291                    return findByN_H_P(nodeId, head, parentTitle, QueryUtil.ALL_POS,
9292                            QueryUtil.ALL_POS, null);
9293            }
9294    
9295            /**
9296             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
9297             *
9298             * <p>
9299             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9300             * </p>
9301             *
9302             * @param nodeId the node ID
9303             * @param head the head
9304             * @param parentTitle the parent title
9305             * @param start the lower bound of the range of wiki pages
9306             * @param end the upper bound of the range of wiki pages (not inclusive)
9307             * @return the range of matching wiki pages
9308             * @throws SystemException if a system exception occurred
9309             */
9310            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
9311                    String parentTitle, int start, int end) throws SystemException {
9312                    return findByN_H_P(nodeId, head, parentTitle, start, end, null);
9313            }
9314    
9315            /**
9316             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
9317             *
9318             * <p>
9319             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9320             * </p>
9321             *
9322             * @param nodeId the node ID
9323             * @param head the head
9324             * @param parentTitle the parent title
9325             * @param start the lower bound of the range of wiki pages
9326             * @param end the upper bound of the range of wiki pages (not inclusive)
9327             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9328             * @return the ordered range of matching wiki pages
9329             * @throws SystemException if a system exception occurred
9330             */
9331            public List<WikiPage> findByN_H_P(long nodeId, boolean head,
9332                    String parentTitle, int start, int end,
9333                    OrderByComparator orderByComparator) throws SystemException {
9334                    FinderPath finderPath = null;
9335                    Object[] finderArgs = null;
9336    
9337                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9338                                    (orderByComparator == null)) {
9339                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P;
9340                            finderArgs = new Object[] { nodeId, head, parentTitle };
9341                    }
9342                    else {
9343                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P;
9344                            finderArgs = new Object[] {
9345                                            nodeId, head, parentTitle,
9346                                            
9347                                            start, end, orderByComparator
9348                                    };
9349                    }
9350    
9351                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
9352                                    finderArgs, this);
9353    
9354                    if ((list != null) && !list.isEmpty()) {
9355                            for (WikiPage wikiPage : list) {
9356                                    if ((nodeId != wikiPage.getNodeId()) ||
9357                                                    (head != wikiPage.getHead()) ||
9358                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle())) {
9359                                            list = null;
9360    
9361                                            break;
9362                                    }
9363                            }
9364                    }
9365    
9366                    if (list == null) {
9367                            StringBundler query = null;
9368    
9369                            if (orderByComparator != null) {
9370                                    query = new StringBundler(5 +
9371                                                    (orderByComparator.getOrderByFields().length * 3));
9372                            }
9373                            else {
9374                                    query = new StringBundler(5);
9375                            }
9376    
9377                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9378    
9379                            query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
9380    
9381                            query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
9382    
9383                            if (parentTitle == null) {
9384                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
9385                            }
9386                            else {
9387                                    if (parentTitle.equals(StringPool.BLANK)) {
9388                                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
9389                                    }
9390                                    else {
9391                                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
9392                                    }
9393                            }
9394    
9395                            if (orderByComparator != null) {
9396                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9397                                            orderByComparator);
9398                            }
9399    
9400                            else {
9401                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9402                            }
9403    
9404                            String sql = query.toString();
9405    
9406                            Session session = null;
9407    
9408                            try {
9409                                    session = openSession();
9410    
9411                                    Query q = session.createQuery(sql);
9412    
9413                                    QueryPos qPos = QueryPos.getInstance(q);
9414    
9415                                    qPos.add(nodeId);
9416    
9417                                    qPos.add(head);
9418    
9419                                    if (parentTitle != null) {
9420                                            qPos.add(parentTitle);
9421                                    }
9422    
9423                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
9424                                                    end);
9425                            }
9426                            catch (Exception e) {
9427                                    throw processException(e);
9428                            }
9429                            finally {
9430                                    if (list == null) {
9431                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9432                                    }
9433                                    else {
9434                                            cacheResult(list);
9435    
9436                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9437                                    }
9438    
9439                                    closeSession(session);
9440                            }
9441                    }
9442    
9443                    return list;
9444            }
9445    
9446            /**
9447             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
9448             *
9449             * @param nodeId the node ID
9450             * @param head the head
9451             * @param parentTitle the parent title
9452             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9453             * @return the first matching wiki page
9454             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9455             * @throws SystemException if a system exception occurred
9456             */
9457            public WikiPage findByN_H_P_First(long nodeId, boolean head,
9458                    String parentTitle, OrderByComparator orderByComparator)
9459                    throws NoSuchPageException, SystemException {
9460                    WikiPage wikiPage = fetchByN_H_P_First(nodeId, head, parentTitle,
9461                                    orderByComparator);
9462    
9463                    if (wikiPage != null) {
9464                            return wikiPage;
9465                    }
9466    
9467                    StringBundler msg = new StringBundler(8);
9468    
9469                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9470    
9471                    msg.append("nodeId=");
9472                    msg.append(nodeId);
9473    
9474                    msg.append(", head=");
9475                    msg.append(head);
9476    
9477                    msg.append(", parentTitle=");
9478                    msg.append(parentTitle);
9479    
9480                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9481    
9482                    throw new NoSuchPageException(msg.toString());
9483            }
9484    
9485            /**
9486             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
9487             *
9488             * @param nodeId the node ID
9489             * @param head the head
9490             * @param parentTitle the parent title
9491             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9492             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
9493             * @throws SystemException if a system exception occurred
9494             */
9495            public WikiPage fetchByN_H_P_First(long nodeId, boolean head,
9496                    String parentTitle, OrderByComparator orderByComparator)
9497                    throws SystemException {
9498                    List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, 0, 1,
9499                                    orderByComparator);
9500    
9501                    if (!list.isEmpty()) {
9502                            return list.get(0);
9503                    }
9504    
9505                    return null;
9506            }
9507    
9508            /**
9509             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
9510             *
9511             * @param nodeId the node ID
9512             * @param head the head
9513             * @param parentTitle the parent title
9514             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9515             * @return the last matching wiki page
9516             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9517             * @throws SystemException if a system exception occurred
9518             */
9519            public WikiPage findByN_H_P_Last(long nodeId, boolean head,
9520                    String parentTitle, OrderByComparator orderByComparator)
9521                    throws NoSuchPageException, SystemException {
9522                    WikiPage wikiPage = fetchByN_H_P_Last(nodeId, head, parentTitle,
9523                                    orderByComparator);
9524    
9525                    if (wikiPage != null) {
9526                            return wikiPage;
9527                    }
9528    
9529                    StringBundler msg = new StringBundler(8);
9530    
9531                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9532    
9533                    msg.append("nodeId=");
9534                    msg.append(nodeId);
9535    
9536                    msg.append(", head=");
9537                    msg.append(head);
9538    
9539                    msg.append(", parentTitle=");
9540                    msg.append(parentTitle);
9541    
9542                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9543    
9544                    throw new NoSuchPageException(msg.toString());
9545            }
9546    
9547            /**
9548             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
9549             *
9550             * @param nodeId the node ID
9551             * @param head the head
9552             * @param parentTitle the parent title
9553             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9554             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
9555             * @throws SystemException if a system exception occurred
9556             */
9557            public WikiPage fetchByN_H_P_Last(long nodeId, boolean head,
9558                    String parentTitle, OrderByComparator orderByComparator)
9559                    throws SystemException {
9560                    int count = countByN_H_P(nodeId, head, parentTitle);
9561    
9562                    List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, count - 1,
9563                                    count, orderByComparator);
9564    
9565                    if (!list.isEmpty()) {
9566                            return list.get(0);
9567                    }
9568    
9569                    return null;
9570            }
9571    
9572            /**
9573             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
9574             *
9575             * @param pageId the primary key of the current wiki page
9576             * @param nodeId the node ID
9577             * @param head the head
9578             * @param parentTitle the parent title
9579             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9580             * @return the previous, current, and next wiki page
9581             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
9582             * @throws SystemException if a system exception occurred
9583             */
9584            public WikiPage[] findByN_H_P_PrevAndNext(long pageId, long nodeId,
9585                    boolean head, String parentTitle, OrderByComparator orderByComparator)
9586                    throws NoSuchPageException, SystemException {
9587                    WikiPage wikiPage = findByPrimaryKey(pageId);
9588    
9589                    Session session = null;
9590    
9591                    try {
9592                            session = openSession();
9593    
9594                            WikiPage[] array = new WikiPageImpl[3];
9595    
9596                            array[0] = getByN_H_P_PrevAndNext(session, wikiPage, nodeId, head,
9597                                            parentTitle, orderByComparator, true);
9598    
9599                            array[1] = wikiPage;
9600    
9601                            array[2] = getByN_H_P_PrevAndNext(session, wikiPage, nodeId, head,
9602                                            parentTitle, orderByComparator, false);
9603    
9604                            return array;
9605                    }
9606                    catch (Exception e) {
9607                            throw processException(e);
9608                    }
9609                    finally {
9610                            closeSession(session);
9611                    }
9612            }
9613    
9614            protected WikiPage getByN_H_P_PrevAndNext(Session session,
9615                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
9616                    OrderByComparator orderByComparator, boolean previous) {
9617                    StringBundler query = null;
9618    
9619                    if (orderByComparator != null) {
9620                            query = new StringBundler(6 +
9621                                            (orderByComparator.getOrderByFields().length * 6));
9622                    }
9623                    else {
9624                            query = new StringBundler(3);
9625                    }
9626    
9627                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9628    
9629                    query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
9630    
9631                    query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
9632    
9633                    if (parentTitle == null) {
9634                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
9635                    }
9636                    else {
9637                            if (parentTitle.equals(StringPool.BLANK)) {
9638                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
9639                            }
9640                            else {
9641                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
9642                            }
9643                    }
9644    
9645                    if (orderByComparator != null) {
9646                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9647    
9648                            if (orderByConditionFields.length > 0) {
9649                                    query.append(WHERE_AND);
9650                            }
9651    
9652                            for (int i = 0; i < orderByConditionFields.length; i++) {
9653                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9654                                    query.append(orderByConditionFields[i]);
9655    
9656                                    if ((i + 1) < orderByConditionFields.length) {
9657                                            if (orderByComparator.isAscending() ^ previous) {
9658                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9659                                            }
9660                                            else {
9661                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9662                                            }
9663                                    }
9664                                    else {
9665                                            if (orderByComparator.isAscending() ^ previous) {
9666                                                    query.append(WHERE_GREATER_THAN);
9667                                            }
9668                                            else {
9669                                                    query.append(WHERE_LESSER_THAN);
9670                                            }
9671                                    }
9672                            }
9673    
9674                            query.append(ORDER_BY_CLAUSE);
9675    
9676                            String[] orderByFields = orderByComparator.getOrderByFields();
9677    
9678                            for (int i = 0; i < orderByFields.length; i++) {
9679                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9680                                    query.append(orderByFields[i]);
9681    
9682                                    if ((i + 1) < orderByFields.length) {
9683                                            if (orderByComparator.isAscending() ^ previous) {
9684                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9685                                            }
9686                                            else {
9687                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9688                                            }
9689                                    }
9690                                    else {
9691                                            if (orderByComparator.isAscending() ^ previous) {
9692                                                    query.append(ORDER_BY_ASC);
9693                                            }
9694                                            else {
9695                                                    query.append(ORDER_BY_DESC);
9696                                            }
9697                                    }
9698                            }
9699                    }
9700    
9701                    else {
9702                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9703                    }
9704    
9705                    String sql = query.toString();
9706    
9707                    Query q = session.createQuery(sql);
9708    
9709                    q.setFirstResult(0);
9710                    q.setMaxResults(2);
9711    
9712                    QueryPos qPos = QueryPos.getInstance(q);
9713    
9714                    qPos.add(nodeId);
9715    
9716                    qPos.add(head);
9717    
9718                    if (parentTitle != null) {
9719                            qPos.add(parentTitle);
9720                    }
9721    
9722                    if (orderByComparator != null) {
9723                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
9724    
9725                            for (Object value : values) {
9726                                    qPos.add(value);
9727                            }
9728                    }
9729    
9730                    List<WikiPage> list = q.list();
9731    
9732                    if (list.size() == 2) {
9733                            return list.get(1);
9734                    }
9735                    else {
9736                            return null;
9737                    }
9738            }
9739    
9740            /**
9741             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
9742             *
9743             * @param nodeId the node ID
9744             * @param head the head
9745             * @param status the status
9746             * @return the matching wiki pages
9747             * @throws SystemException if a system exception occurred
9748             */
9749            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status)
9750                    throws SystemException {
9751                    return findByN_H_S(nodeId, head, status, QueryUtil.ALL_POS,
9752                            QueryUtil.ALL_POS, null);
9753            }
9754    
9755            /**
9756             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
9757             *
9758             * <p>
9759             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9760             * </p>
9761             *
9762             * @param nodeId the node ID
9763             * @param head the head
9764             * @param status the status
9765             * @param start the lower bound of the range of wiki pages
9766             * @param end the upper bound of the range of wiki pages (not inclusive)
9767             * @return the range of matching wiki pages
9768             * @throws SystemException if a system exception occurred
9769             */
9770            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status,
9771                    int start, int end) throws SystemException {
9772                    return findByN_H_S(nodeId, head, status, start, end, null);
9773            }
9774    
9775            /**
9776             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
9777             *
9778             * <p>
9779             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9780             * </p>
9781             *
9782             * @param nodeId the node ID
9783             * @param head the head
9784             * @param status the status
9785             * @param start the lower bound of the range of wiki pages
9786             * @param end the upper bound of the range of wiki pages (not inclusive)
9787             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9788             * @return the ordered range of matching wiki pages
9789             * @throws SystemException if a system exception occurred
9790             */
9791            public List<WikiPage> findByN_H_S(long nodeId, boolean head, int status,
9792                    int start, int end, OrderByComparator orderByComparator)
9793                    throws SystemException {
9794                    FinderPath finderPath = null;
9795                    Object[] finderArgs = null;
9796    
9797                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9798                                    (orderByComparator == null)) {
9799                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_S;
9800                            finderArgs = new Object[] { nodeId, head, status };
9801                    }
9802                    else {
9803                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_S;
9804                            finderArgs = new Object[] {
9805                                            nodeId, head, status,
9806                                            
9807                                            start, end, orderByComparator
9808                                    };
9809                    }
9810    
9811                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
9812                                    finderArgs, this);
9813    
9814                    if ((list != null) && !list.isEmpty()) {
9815                            for (WikiPage wikiPage : list) {
9816                                    if ((nodeId != wikiPage.getNodeId()) ||
9817                                                    (head != wikiPage.getHead()) ||
9818                                                    (status != wikiPage.getStatus())) {
9819                                            list = null;
9820    
9821                                            break;
9822                                    }
9823                            }
9824                    }
9825    
9826                    if (list == null) {
9827                            StringBundler query = null;
9828    
9829                            if (orderByComparator != null) {
9830                                    query = new StringBundler(5 +
9831                                                    (orderByComparator.getOrderByFields().length * 3));
9832                            }
9833                            else {
9834                                    query = new StringBundler(5);
9835                            }
9836    
9837                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
9838    
9839                            query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
9840    
9841                            query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
9842    
9843                            query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
9844    
9845                            if (orderByComparator != null) {
9846                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9847                                            orderByComparator);
9848                            }
9849    
9850                            else {
9851                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
9852                            }
9853    
9854                            String sql = query.toString();
9855    
9856                            Session session = null;
9857    
9858                            try {
9859                                    session = openSession();
9860    
9861                                    Query q = session.createQuery(sql);
9862    
9863                                    QueryPos qPos = QueryPos.getInstance(q);
9864    
9865                                    qPos.add(nodeId);
9866    
9867                                    qPos.add(head);
9868    
9869                                    qPos.add(status);
9870    
9871                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
9872                                                    end);
9873                            }
9874                            catch (Exception e) {
9875                                    throw processException(e);
9876                            }
9877                            finally {
9878                                    if (list == null) {
9879                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9880                                    }
9881                                    else {
9882                                            cacheResult(list);
9883    
9884                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9885                                    }
9886    
9887                                    closeSession(session);
9888                            }
9889                    }
9890    
9891                    return list;
9892            }
9893    
9894            /**
9895             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
9896             *
9897             * @param nodeId the node ID
9898             * @param head the head
9899             * @param status the status
9900             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9901             * @return the first matching wiki page
9902             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9903             * @throws SystemException if a system exception occurred
9904             */
9905            public WikiPage findByN_H_S_First(long nodeId, boolean head, int status,
9906                    OrderByComparator orderByComparator)
9907                    throws NoSuchPageException, SystemException {
9908                    WikiPage wikiPage = fetchByN_H_S_First(nodeId, head, status,
9909                                    orderByComparator);
9910    
9911                    if (wikiPage != null) {
9912                            return wikiPage;
9913                    }
9914    
9915                    StringBundler msg = new StringBundler(8);
9916    
9917                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9918    
9919                    msg.append("nodeId=");
9920                    msg.append(nodeId);
9921    
9922                    msg.append(", head=");
9923                    msg.append(head);
9924    
9925                    msg.append(", status=");
9926                    msg.append(status);
9927    
9928                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9929    
9930                    throw new NoSuchPageException(msg.toString());
9931            }
9932    
9933            /**
9934             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
9935             *
9936             * @param nodeId the node ID
9937             * @param head the head
9938             * @param status the status
9939             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9940             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
9941             * @throws SystemException if a system exception occurred
9942             */
9943            public WikiPage fetchByN_H_S_First(long nodeId, boolean head, int status,
9944                    OrderByComparator orderByComparator) throws SystemException {
9945                    List<WikiPage> list = findByN_H_S(nodeId, head, status, 0, 1,
9946                                    orderByComparator);
9947    
9948                    if (!list.isEmpty()) {
9949                            return list.get(0);
9950                    }
9951    
9952                    return null;
9953            }
9954    
9955            /**
9956             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
9957             *
9958             * @param nodeId the node ID
9959             * @param head the head
9960             * @param status the status
9961             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9962             * @return the last matching wiki page
9963             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
9964             * @throws SystemException if a system exception occurred
9965             */
9966            public WikiPage findByN_H_S_Last(long nodeId, boolean head, int status,
9967                    OrderByComparator orderByComparator)
9968                    throws NoSuchPageException, SystemException {
9969                    WikiPage wikiPage = fetchByN_H_S_Last(nodeId, head, status,
9970                                    orderByComparator);
9971    
9972                    if (wikiPage != null) {
9973                            return wikiPage;
9974                    }
9975    
9976                    StringBundler msg = new StringBundler(8);
9977    
9978                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9979    
9980                    msg.append("nodeId=");
9981                    msg.append(nodeId);
9982    
9983                    msg.append(", head=");
9984                    msg.append(head);
9985    
9986                    msg.append(", status=");
9987                    msg.append(status);
9988    
9989                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9990    
9991                    throw new NoSuchPageException(msg.toString());
9992            }
9993    
9994            /**
9995             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
9996             *
9997             * @param nodeId the node ID
9998             * @param head the head
9999             * @param status the status
10000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10001             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
10002             * @throws SystemException if a system exception occurred
10003             */
10004            public WikiPage fetchByN_H_S_Last(long nodeId, boolean head, int status,
10005                    OrderByComparator orderByComparator) throws SystemException {
10006                    int count = countByN_H_S(nodeId, head, status);
10007    
10008                    List<WikiPage> list = findByN_H_S(nodeId, head, status, count - 1,
10009                                    count, orderByComparator);
10010    
10011                    if (!list.isEmpty()) {
10012                            return list.get(0);
10013                    }
10014    
10015                    return null;
10016            }
10017    
10018            /**
10019             * Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = &#63; and head = &#63; and status = &#63;.
10020             *
10021             * @param pageId the primary key of the current wiki page
10022             * @param nodeId the node ID
10023             * @param head the head
10024             * @param status the status
10025             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10026             * @return the previous, current, and next wiki page
10027             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
10028             * @throws SystemException if a system exception occurred
10029             */
10030            public WikiPage[] findByN_H_S_PrevAndNext(long pageId, long nodeId,
10031                    boolean head, int status, OrderByComparator orderByComparator)
10032                    throws NoSuchPageException, SystemException {
10033                    WikiPage wikiPage = findByPrimaryKey(pageId);
10034    
10035                    Session session = null;
10036    
10037                    try {
10038                            session = openSession();
10039    
10040                            WikiPage[] array = new WikiPageImpl[3];
10041    
10042                            array[0] = getByN_H_S_PrevAndNext(session, wikiPage, nodeId, head,
10043                                            status, orderByComparator, true);
10044    
10045                            array[1] = wikiPage;
10046    
10047                            array[2] = getByN_H_S_PrevAndNext(session, wikiPage, nodeId, head,
10048                                            status, orderByComparator, false);
10049    
10050                            return array;
10051                    }
10052                    catch (Exception e) {
10053                            throw processException(e);
10054                    }
10055                    finally {
10056                            closeSession(session);
10057                    }
10058            }
10059    
10060            protected WikiPage getByN_H_S_PrevAndNext(Session session,
10061                    WikiPage wikiPage, long nodeId, boolean head, int status,
10062                    OrderByComparator orderByComparator, boolean previous) {
10063                    StringBundler query = null;
10064    
10065                    if (orderByComparator != null) {
10066                            query = new StringBundler(6 +
10067                                            (orderByComparator.getOrderByFields().length * 6));
10068                    }
10069                    else {
10070                            query = new StringBundler(3);
10071                    }
10072    
10073                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10074    
10075                    query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
10076    
10077                    query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
10078    
10079                    query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
10080    
10081                    if (orderByComparator != null) {
10082                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10083    
10084                            if (orderByConditionFields.length > 0) {
10085                                    query.append(WHERE_AND);
10086                            }
10087    
10088                            for (int i = 0; i < orderByConditionFields.length; i++) {
10089                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10090                                    query.append(orderByConditionFields[i]);
10091    
10092                                    if ((i + 1) < orderByConditionFields.length) {
10093                                            if (orderByComparator.isAscending() ^ previous) {
10094                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10095                                            }
10096                                            else {
10097                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10098                                            }
10099                                    }
10100                                    else {
10101                                            if (orderByComparator.isAscending() ^ previous) {
10102                                                    query.append(WHERE_GREATER_THAN);
10103                                            }
10104                                            else {
10105                                                    query.append(WHERE_LESSER_THAN);
10106                                            }
10107                                    }
10108                            }
10109    
10110                            query.append(ORDER_BY_CLAUSE);
10111    
10112                            String[] orderByFields = orderByComparator.getOrderByFields();
10113    
10114                            for (int i = 0; i < orderByFields.length; i++) {
10115                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10116                                    query.append(orderByFields[i]);
10117    
10118                                    if ((i + 1) < orderByFields.length) {
10119                                            if (orderByComparator.isAscending() ^ previous) {
10120                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10121                                            }
10122                                            else {
10123                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10124                                            }
10125                                    }
10126                                    else {
10127                                            if (orderByComparator.isAscending() ^ previous) {
10128                                                    query.append(ORDER_BY_ASC);
10129                                            }
10130                                            else {
10131                                                    query.append(ORDER_BY_DESC);
10132                                            }
10133                                    }
10134                            }
10135                    }
10136    
10137                    else {
10138                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10139                    }
10140    
10141                    String sql = query.toString();
10142    
10143                    Query q = session.createQuery(sql);
10144    
10145                    q.setFirstResult(0);
10146                    q.setMaxResults(2);
10147    
10148                    QueryPos qPos = QueryPos.getInstance(q);
10149    
10150                    qPos.add(nodeId);
10151    
10152                    qPos.add(head);
10153    
10154                    qPos.add(status);
10155    
10156                    if (orderByComparator != null) {
10157                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
10158    
10159                            for (Object value : values) {
10160                                    qPos.add(value);
10161                            }
10162                    }
10163    
10164                    List<WikiPage> list = q.list();
10165    
10166                    if (list.size() == 2) {
10167                            return list.get(1);
10168                    }
10169                    else {
10170                            return null;
10171                    }
10172            }
10173    
10174            /**
10175             * Returns all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10176             *
10177             * @param groupId the group ID
10178             * @param userId the user ID
10179             * @param nodeId the node ID
10180             * @param status the status
10181             * @return the matching wiki pages
10182             * @throws SystemException if a system exception occurred
10183             */
10184            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
10185                    int status) throws SystemException {
10186                    return findByG_U_N_S(groupId, userId, nodeId, status,
10187                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10188            }
10189    
10190            /**
10191             * Returns a range of all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10192             *
10193             * <p>
10194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10195             * </p>
10196             *
10197             * @param groupId the group ID
10198             * @param userId the user ID
10199             * @param nodeId the node ID
10200             * @param status the status
10201             * @param start the lower bound of the range of wiki pages
10202             * @param end the upper bound of the range of wiki pages (not inclusive)
10203             * @return the range of matching wiki pages
10204             * @throws SystemException if a system exception occurred
10205             */
10206            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
10207                    int status, int start, int end) throws SystemException {
10208                    return findByG_U_N_S(groupId, userId, nodeId, status, start, end, null);
10209            }
10210    
10211            /**
10212             * Returns an ordered range of all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10213             *
10214             * <p>
10215             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10216             * </p>
10217             *
10218             * @param groupId the group ID
10219             * @param userId the user ID
10220             * @param nodeId the node ID
10221             * @param status the status
10222             * @param start the lower bound of the range of wiki pages
10223             * @param end the upper bound of the range of wiki pages (not inclusive)
10224             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10225             * @return the ordered range of matching wiki pages
10226             * @throws SystemException if a system exception occurred
10227             */
10228            public List<WikiPage> findByG_U_N_S(long groupId, long userId, long nodeId,
10229                    int status, int start, int end, OrderByComparator orderByComparator)
10230                    throws SystemException {
10231                    FinderPath finderPath = null;
10232                    Object[] finderArgs = null;
10233    
10234                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10235                                    (orderByComparator == null)) {
10236                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_N_S;
10237                            finderArgs = new Object[] { groupId, userId, nodeId, status };
10238                    }
10239                    else {
10240                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_N_S;
10241                            finderArgs = new Object[] {
10242                                            groupId, userId, nodeId, status,
10243                                            
10244                                            start, end, orderByComparator
10245                                    };
10246                    }
10247    
10248                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
10249                                    finderArgs, this);
10250    
10251                    if ((list != null) && !list.isEmpty()) {
10252                            for (WikiPage wikiPage : list) {
10253                                    if ((groupId != wikiPage.getGroupId()) ||
10254                                                    (userId != wikiPage.getUserId()) ||
10255                                                    (nodeId != wikiPage.getNodeId()) ||
10256                                                    (status != wikiPage.getStatus())) {
10257                                            list = null;
10258    
10259                                            break;
10260                                    }
10261                            }
10262                    }
10263    
10264                    if (list == null) {
10265                            StringBundler query = null;
10266    
10267                            if (orderByComparator != null) {
10268                                    query = new StringBundler(6 +
10269                                                    (orderByComparator.getOrderByFields().length * 3));
10270                            }
10271                            else {
10272                                    query = new StringBundler(6);
10273                            }
10274    
10275                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10276    
10277                            query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
10278    
10279                            query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
10280    
10281                            query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
10282    
10283                            query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
10284    
10285                            if (orderByComparator != null) {
10286                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10287                                            orderByComparator);
10288                            }
10289    
10290                            else {
10291                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10292                            }
10293    
10294                            String sql = query.toString();
10295    
10296                            Session session = null;
10297    
10298                            try {
10299                                    session = openSession();
10300    
10301                                    Query q = session.createQuery(sql);
10302    
10303                                    QueryPos qPos = QueryPos.getInstance(q);
10304    
10305                                    qPos.add(groupId);
10306    
10307                                    qPos.add(userId);
10308    
10309                                    qPos.add(nodeId);
10310    
10311                                    qPos.add(status);
10312    
10313                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
10314                                                    end);
10315                            }
10316                            catch (Exception e) {
10317                                    throw processException(e);
10318                            }
10319                            finally {
10320                                    if (list == null) {
10321                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10322                                    }
10323                                    else {
10324                                            cacheResult(list);
10325    
10326                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10327                                    }
10328    
10329                                    closeSession(session);
10330                            }
10331                    }
10332    
10333                    return list;
10334            }
10335    
10336            /**
10337             * Returns the first wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10338             *
10339             * @param groupId the group ID
10340             * @param userId the user ID
10341             * @param nodeId the node ID
10342             * @param status the status
10343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10344             * @return the first matching wiki page
10345             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10346             * @throws SystemException if a system exception occurred
10347             */
10348            public WikiPage findByG_U_N_S_First(long groupId, long userId, long nodeId,
10349                    int status, OrderByComparator orderByComparator)
10350                    throws NoSuchPageException, SystemException {
10351                    WikiPage wikiPage = fetchByG_U_N_S_First(groupId, userId, nodeId,
10352                                    status, orderByComparator);
10353    
10354                    if (wikiPage != null) {
10355                            return wikiPage;
10356                    }
10357    
10358                    StringBundler msg = new StringBundler(10);
10359    
10360                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10361    
10362                    msg.append("groupId=");
10363                    msg.append(groupId);
10364    
10365                    msg.append(", userId=");
10366                    msg.append(userId);
10367    
10368                    msg.append(", nodeId=");
10369                    msg.append(nodeId);
10370    
10371                    msg.append(", status=");
10372                    msg.append(status);
10373    
10374                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10375    
10376                    throw new NoSuchPageException(msg.toString());
10377            }
10378    
10379            /**
10380             * Returns the first wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10381             *
10382             * @param groupId the group ID
10383             * @param userId the user ID
10384             * @param nodeId the node ID
10385             * @param status the status
10386             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10387             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
10388             * @throws SystemException if a system exception occurred
10389             */
10390            public WikiPage fetchByG_U_N_S_First(long groupId, long userId,
10391                    long nodeId, int status, OrderByComparator orderByComparator)
10392                    throws SystemException {
10393                    List<WikiPage> list = findByG_U_N_S(groupId, userId, nodeId, status, 0,
10394                                    1, orderByComparator);
10395    
10396                    if (!list.isEmpty()) {
10397                            return list.get(0);
10398                    }
10399    
10400                    return null;
10401            }
10402    
10403            /**
10404             * Returns the last wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10405             *
10406             * @param groupId the group ID
10407             * @param userId the user ID
10408             * @param nodeId the node ID
10409             * @param status the status
10410             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10411             * @return the last matching wiki page
10412             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
10413             * @throws SystemException if a system exception occurred
10414             */
10415            public WikiPage findByG_U_N_S_Last(long groupId, long userId, long nodeId,
10416                    int status, OrderByComparator orderByComparator)
10417                    throws NoSuchPageException, SystemException {
10418                    WikiPage wikiPage = fetchByG_U_N_S_Last(groupId, userId, nodeId,
10419                                    status, orderByComparator);
10420    
10421                    if (wikiPage != null) {
10422                            return wikiPage;
10423                    }
10424    
10425                    StringBundler msg = new StringBundler(10);
10426    
10427                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10428    
10429                    msg.append("groupId=");
10430                    msg.append(groupId);
10431    
10432                    msg.append(", userId=");
10433                    msg.append(userId);
10434    
10435                    msg.append(", nodeId=");
10436                    msg.append(nodeId);
10437    
10438                    msg.append(", status=");
10439                    msg.append(status);
10440    
10441                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10442    
10443                    throw new NoSuchPageException(msg.toString());
10444            }
10445    
10446            /**
10447             * Returns the last wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10448             *
10449             * @param groupId the group ID
10450             * @param userId the user ID
10451             * @param nodeId the node ID
10452             * @param status the status
10453             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10454             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
10455             * @throws SystemException if a system exception occurred
10456             */
10457            public WikiPage fetchByG_U_N_S_Last(long groupId, long userId, long nodeId,
10458                    int status, OrderByComparator orderByComparator)
10459                    throws SystemException {
10460                    int count = countByG_U_N_S(groupId, userId, nodeId, status);
10461    
10462                    List<WikiPage> list = findByG_U_N_S(groupId, userId, nodeId, status,
10463                                    count - 1, count, orderByComparator);
10464    
10465                    if (!list.isEmpty()) {
10466                            return list.get(0);
10467                    }
10468    
10469                    return null;
10470            }
10471    
10472            /**
10473             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10474             *
10475             * @param pageId the primary key of the current wiki page
10476             * @param groupId the group ID
10477             * @param userId the user ID
10478             * @param nodeId the node ID
10479             * @param status the status
10480             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10481             * @return the previous, current, and next wiki page
10482             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
10483             * @throws SystemException if a system exception occurred
10484             */
10485            public WikiPage[] findByG_U_N_S_PrevAndNext(long pageId, long groupId,
10486                    long userId, long nodeId, int status,
10487                    OrderByComparator orderByComparator)
10488                    throws NoSuchPageException, SystemException {
10489                    WikiPage wikiPage = findByPrimaryKey(pageId);
10490    
10491                    Session session = null;
10492    
10493                    try {
10494                            session = openSession();
10495    
10496                            WikiPage[] array = new WikiPageImpl[3];
10497    
10498                            array[0] = getByG_U_N_S_PrevAndNext(session, wikiPage, groupId,
10499                                            userId, nodeId, status, orderByComparator, true);
10500    
10501                            array[1] = wikiPage;
10502    
10503                            array[2] = getByG_U_N_S_PrevAndNext(session, wikiPage, groupId,
10504                                            userId, nodeId, status, orderByComparator, false);
10505    
10506                            return array;
10507                    }
10508                    catch (Exception e) {
10509                            throw processException(e);
10510                    }
10511                    finally {
10512                            closeSession(session);
10513                    }
10514            }
10515    
10516            protected WikiPage getByG_U_N_S_PrevAndNext(Session session,
10517                    WikiPage wikiPage, long groupId, long userId, long nodeId, int status,
10518                    OrderByComparator orderByComparator, boolean previous) {
10519                    StringBundler query = null;
10520    
10521                    if (orderByComparator != null) {
10522                            query = new StringBundler(6 +
10523                                            (orderByComparator.getOrderByFields().length * 6));
10524                    }
10525                    else {
10526                            query = new StringBundler(3);
10527                    }
10528    
10529                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
10530    
10531                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
10532    
10533                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
10534    
10535                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
10536    
10537                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
10538    
10539                    if (orderByComparator != null) {
10540                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10541    
10542                            if (orderByConditionFields.length > 0) {
10543                                    query.append(WHERE_AND);
10544                            }
10545    
10546                            for (int i = 0; i < orderByConditionFields.length; i++) {
10547                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10548                                    query.append(orderByConditionFields[i]);
10549    
10550                                    if ((i + 1) < orderByConditionFields.length) {
10551                                            if (orderByComparator.isAscending() ^ previous) {
10552                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10553                                            }
10554                                            else {
10555                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10556                                            }
10557                                    }
10558                                    else {
10559                                            if (orderByComparator.isAscending() ^ previous) {
10560                                                    query.append(WHERE_GREATER_THAN);
10561                                            }
10562                                            else {
10563                                                    query.append(WHERE_LESSER_THAN);
10564                                            }
10565                                    }
10566                            }
10567    
10568                            query.append(ORDER_BY_CLAUSE);
10569    
10570                            String[] orderByFields = orderByComparator.getOrderByFields();
10571    
10572                            for (int i = 0; i < orderByFields.length; i++) {
10573                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10574                                    query.append(orderByFields[i]);
10575    
10576                                    if ((i + 1) < orderByFields.length) {
10577                                            if (orderByComparator.isAscending() ^ previous) {
10578                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10579                                            }
10580                                            else {
10581                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10582                                            }
10583                                    }
10584                                    else {
10585                                            if (orderByComparator.isAscending() ^ previous) {
10586                                                    query.append(ORDER_BY_ASC);
10587                                            }
10588                                            else {
10589                                                    query.append(ORDER_BY_DESC);
10590                                            }
10591                                    }
10592                            }
10593                    }
10594    
10595                    else {
10596                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10597                    }
10598    
10599                    String sql = query.toString();
10600    
10601                    Query q = session.createQuery(sql);
10602    
10603                    q.setFirstResult(0);
10604                    q.setMaxResults(2);
10605    
10606                    QueryPos qPos = QueryPos.getInstance(q);
10607    
10608                    qPos.add(groupId);
10609    
10610                    qPos.add(userId);
10611    
10612                    qPos.add(nodeId);
10613    
10614                    qPos.add(status);
10615    
10616                    if (orderByComparator != null) {
10617                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
10618    
10619                            for (Object value : values) {
10620                                    qPos.add(value);
10621                            }
10622                    }
10623    
10624                    List<WikiPage> list = q.list();
10625    
10626                    if (list.size() == 2) {
10627                            return list.get(1);
10628                    }
10629                    else {
10630                            return null;
10631                    }
10632            }
10633    
10634            /**
10635             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10636             *
10637             * @param groupId the group ID
10638             * @param userId the user ID
10639             * @param nodeId the node ID
10640             * @param status the status
10641             * @return the matching wiki pages that the user has permission to view
10642             * @throws SystemException if a system exception occurred
10643             */
10644            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
10645                    long nodeId, int status) throws SystemException {
10646                    return filterFindByG_U_N_S(groupId, userId, nodeId, status,
10647                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10648            }
10649    
10650            /**
10651             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10652             *
10653             * <p>
10654             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10655             * </p>
10656             *
10657             * @param groupId the group ID
10658             * @param userId the user ID
10659             * @param nodeId the node ID
10660             * @param status the status
10661             * @param start the lower bound of the range of wiki pages
10662             * @param end the upper bound of the range of wiki pages (not inclusive)
10663             * @return the range of matching wiki pages that the user has permission to view
10664             * @throws SystemException if a system exception occurred
10665             */
10666            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
10667                    long nodeId, int status, int start, int end) throws SystemException {
10668                    return filterFindByG_U_N_S(groupId, userId, nodeId, status, start, end,
10669                            null);
10670            }
10671    
10672            /**
10673             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10674             *
10675             * <p>
10676             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10677             * </p>
10678             *
10679             * @param groupId the group ID
10680             * @param userId the user ID
10681             * @param nodeId the node ID
10682             * @param status the status
10683             * @param start the lower bound of the range of wiki pages
10684             * @param end the upper bound of the range of wiki pages (not inclusive)
10685             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10686             * @return the ordered range of matching wiki pages that the user has permission to view
10687             * @throws SystemException if a system exception occurred
10688             */
10689            public List<WikiPage> filterFindByG_U_N_S(long groupId, long userId,
10690                    long nodeId, int status, int start, int end,
10691                    OrderByComparator orderByComparator) throws SystemException {
10692                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10693                            return findByG_U_N_S(groupId, userId, nodeId, status, start, end,
10694                                    orderByComparator);
10695                    }
10696    
10697                    StringBundler query = null;
10698    
10699                    if (orderByComparator != null) {
10700                            query = new StringBundler(6 +
10701                                            (orderByComparator.getOrderByFields().length * 3));
10702                    }
10703                    else {
10704                            query = new StringBundler(6);
10705                    }
10706    
10707                    if (getDB().isSupportsInlineDistinct()) {
10708                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
10709                    }
10710                    else {
10711                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
10712                    }
10713    
10714                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
10715    
10716                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
10717    
10718                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
10719    
10720                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
10721    
10722                    if (!getDB().isSupportsInlineDistinct()) {
10723                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
10724                    }
10725    
10726                    if (orderByComparator != null) {
10727                            if (getDB().isSupportsInlineDistinct()) {
10728                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10729                                            orderByComparator);
10730                            }
10731                            else {
10732                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10733                                            orderByComparator);
10734                            }
10735                    }
10736    
10737                    else {
10738                            if (getDB().isSupportsInlineDistinct()) {
10739                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10740                            }
10741                            else {
10742                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
10743                            }
10744                    }
10745    
10746                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10747                                    WikiPage.class.getName(),
10748                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10749    
10750                    Session session = null;
10751    
10752                    try {
10753                            session = openSession();
10754    
10755                            SQLQuery q = session.createSQLQuery(sql);
10756    
10757                            if (getDB().isSupportsInlineDistinct()) {
10758                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
10759                            }
10760                            else {
10761                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
10762                            }
10763    
10764                            QueryPos qPos = QueryPos.getInstance(q);
10765    
10766                            qPos.add(groupId);
10767    
10768                            qPos.add(userId);
10769    
10770                            qPos.add(nodeId);
10771    
10772                            qPos.add(status);
10773    
10774                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
10775                    }
10776                    catch (Exception e) {
10777                            throw processException(e);
10778                    }
10779                    finally {
10780                            closeSession(session);
10781                    }
10782            }
10783    
10784            /**
10785             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
10786             *
10787             * @param pageId the primary key of the current wiki page
10788             * @param groupId the group ID
10789             * @param userId the user ID
10790             * @param nodeId the node ID
10791             * @param status the status
10792             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10793             * @return the previous, current, and next wiki page
10794             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
10795             * @throws SystemException if a system exception occurred
10796             */
10797            public WikiPage[] filterFindByG_U_N_S_PrevAndNext(long pageId,
10798                    long groupId, long userId, long nodeId, int status,
10799                    OrderByComparator orderByComparator)
10800                    throws NoSuchPageException, SystemException {
10801                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10802                            return findByG_U_N_S_PrevAndNext(pageId, groupId, userId, nodeId,
10803                                    status, orderByComparator);
10804                    }
10805    
10806                    WikiPage wikiPage = findByPrimaryKey(pageId);
10807    
10808                    Session session = null;
10809    
10810                    try {
10811                            session = openSession();
10812    
10813                            WikiPage[] array = new WikiPageImpl[3];
10814    
10815                            array[0] = filterGetByG_U_N_S_PrevAndNext(session, wikiPage,
10816                                            groupId, userId, nodeId, status, orderByComparator, true);
10817    
10818                            array[1] = wikiPage;
10819    
10820                            array[2] = filterGetByG_U_N_S_PrevAndNext(session, wikiPage,
10821                                            groupId, userId, nodeId, status, orderByComparator, false);
10822    
10823                            return array;
10824                    }
10825                    catch (Exception e) {
10826                            throw processException(e);
10827                    }
10828                    finally {
10829                            closeSession(session);
10830                    }
10831            }
10832    
10833            protected WikiPage filterGetByG_U_N_S_PrevAndNext(Session session,
10834                    WikiPage wikiPage, long groupId, long userId, long nodeId, int status,
10835                    OrderByComparator orderByComparator, boolean previous) {
10836                    StringBundler query = null;
10837    
10838                    if (orderByComparator != null) {
10839                            query = new StringBundler(6 +
10840                                            (orderByComparator.getOrderByFields().length * 6));
10841                    }
10842                    else {
10843                            query = new StringBundler(3);
10844                    }
10845    
10846                    if (getDB().isSupportsInlineDistinct()) {
10847                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
10848                    }
10849                    else {
10850                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
10851                    }
10852    
10853                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
10854    
10855                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
10856    
10857                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
10858    
10859                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
10860    
10861                    if (!getDB().isSupportsInlineDistinct()) {
10862                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
10863                    }
10864    
10865                    if (orderByComparator != null) {
10866                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10867    
10868                            if (orderByConditionFields.length > 0) {
10869                                    query.append(WHERE_AND);
10870                            }
10871    
10872                            for (int i = 0; i < orderByConditionFields.length; i++) {
10873                                    if (getDB().isSupportsInlineDistinct()) {
10874                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10875                                    }
10876                                    else {
10877                                            query.append(_ORDER_BY_ENTITY_TABLE);
10878                                    }
10879    
10880                                    query.append(orderByConditionFields[i]);
10881    
10882                                    if ((i + 1) < orderByConditionFields.length) {
10883                                            if (orderByComparator.isAscending() ^ previous) {
10884                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10885                                            }
10886                                            else {
10887                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10888                                            }
10889                                    }
10890                                    else {
10891                                            if (orderByComparator.isAscending() ^ previous) {
10892                                                    query.append(WHERE_GREATER_THAN);
10893                                            }
10894                                            else {
10895                                                    query.append(WHERE_LESSER_THAN);
10896                                            }
10897                                    }
10898                            }
10899    
10900                            query.append(ORDER_BY_CLAUSE);
10901    
10902                            String[] orderByFields = orderByComparator.getOrderByFields();
10903    
10904                            for (int i = 0; i < orderByFields.length; i++) {
10905                                    if (getDB().isSupportsInlineDistinct()) {
10906                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10907                                    }
10908                                    else {
10909                                            query.append(_ORDER_BY_ENTITY_TABLE);
10910                                    }
10911    
10912                                    query.append(orderByFields[i]);
10913    
10914                                    if ((i + 1) < orderByFields.length) {
10915                                            if (orderByComparator.isAscending() ^ previous) {
10916                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10917                                            }
10918                                            else {
10919                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10920                                            }
10921                                    }
10922                                    else {
10923                                            if (orderByComparator.isAscending() ^ previous) {
10924                                                    query.append(ORDER_BY_ASC);
10925                                            }
10926                                            else {
10927                                                    query.append(ORDER_BY_DESC);
10928                                            }
10929                                    }
10930                            }
10931                    }
10932    
10933                    else {
10934                            if (getDB().isSupportsInlineDistinct()) {
10935                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
10936                            }
10937                            else {
10938                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
10939                            }
10940                    }
10941    
10942                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10943                                    WikiPage.class.getName(),
10944                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10945    
10946                    SQLQuery q = session.createSQLQuery(sql);
10947    
10948                    q.setFirstResult(0);
10949                    q.setMaxResults(2);
10950    
10951                    if (getDB().isSupportsInlineDistinct()) {
10952                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
10953                    }
10954                    else {
10955                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
10956                    }
10957    
10958                    QueryPos qPos = QueryPos.getInstance(q);
10959    
10960                    qPos.add(groupId);
10961    
10962                    qPos.add(userId);
10963    
10964                    qPos.add(nodeId);
10965    
10966                    qPos.add(status);
10967    
10968                    if (orderByComparator != null) {
10969                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
10970    
10971                            for (Object value : values) {
10972                                    qPos.add(value);
10973                            }
10974                    }
10975    
10976                    List<WikiPage> list = q.list();
10977    
10978                    if (list.size() == 2) {
10979                            return list.get(1);
10980                    }
10981                    else {
10982                            return null;
10983                    }
10984            }
10985    
10986            /**
10987             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
10988             *
10989             * @param groupId the group ID
10990             * @param nodeId the node ID
10991             * @param title the title
10992             * @param head the head
10993             * @return the matching wiki pages
10994             * @throws SystemException if a system exception occurred
10995             */
10996            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
10997                    String title, boolean head) throws SystemException {
10998                    return findByG_N_T_H(groupId, nodeId, title, head, QueryUtil.ALL_POS,
10999                            QueryUtil.ALL_POS, null);
11000            }
11001    
11002            /**
11003             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11004             *
11005             * <p>
11006             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11007             * </p>
11008             *
11009             * @param groupId the group ID
11010             * @param nodeId the node ID
11011             * @param title the title
11012             * @param head the head
11013             * @param start the lower bound of the range of wiki pages
11014             * @param end the upper bound of the range of wiki pages (not inclusive)
11015             * @return the range of matching wiki pages
11016             * @throws SystemException if a system exception occurred
11017             */
11018            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
11019                    String title, boolean head, int start, int end)
11020                    throws SystemException {
11021                    return findByG_N_T_H(groupId, nodeId, title, head, start, end, null);
11022            }
11023    
11024            /**
11025             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11026             *
11027             * <p>
11028             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11029             * </p>
11030             *
11031             * @param groupId the group ID
11032             * @param nodeId the node ID
11033             * @param title the title
11034             * @param head the head
11035             * @param start the lower bound of the range of wiki pages
11036             * @param end the upper bound of the range of wiki pages (not inclusive)
11037             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11038             * @return the ordered range of matching wiki pages
11039             * @throws SystemException if a system exception occurred
11040             */
11041            public List<WikiPage> findByG_N_T_H(long groupId, long nodeId,
11042                    String title, boolean head, int start, int end,
11043                    OrderByComparator orderByComparator) throws SystemException {
11044                    FinderPath finderPath = null;
11045                    Object[] finderArgs = null;
11046    
11047                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11048                                    (orderByComparator == null)) {
11049                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_T_H;
11050                            finderArgs = new Object[] { groupId, nodeId, title, head };
11051                    }
11052                    else {
11053                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_T_H;
11054                            finderArgs = new Object[] {
11055                                            groupId, nodeId, title, head,
11056                                            
11057                                            start, end, orderByComparator
11058                                    };
11059                    }
11060    
11061                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
11062                                    finderArgs, this);
11063    
11064                    if ((list != null) && !list.isEmpty()) {
11065                            for (WikiPage wikiPage : list) {
11066                                    if ((groupId != wikiPage.getGroupId()) ||
11067                                                    (nodeId != wikiPage.getNodeId()) ||
11068                                                    !Validator.equals(title, wikiPage.getTitle()) ||
11069                                                    (head != wikiPage.getHead())) {
11070                                            list = null;
11071    
11072                                            break;
11073                                    }
11074                            }
11075                    }
11076    
11077                    if (list == null) {
11078                            StringBundler query = null;
11079    
11080                            if (orderByComparator != null) {
11081                                    query = new StringBundler(6 +
11082                                                    (orderByComparator.getOrderByFields().length * 3));
11083                            }
11084                            else {
11085                                    query = new StringBundler(6);
11086                            }
11087    
11088                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11089    
11090                            query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
11091    
11092                            query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
11093    
11094                            if (title == null) {
11095                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
11096                            }
11097                            else {
11098                                    if (title.equals(StringPool.BLANK)) {
11099                                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
11100                                    }
11101                                    else {
11102                                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
11103                                    }
11104                            }
11105    
11106                            query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
11107    
11108                            if (orderByComparator != null) {
11109                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11110                                            orderByComparator);
11111                            }
11112    
11113                            else {
11114                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11115                            }
11116    
11117                            String sql = query.toString();
11118    
11119                            Session session = null;
11120    
11121                            try {
11122                                    session = openSession();
11123    
11124                                    Query q = session.createQuery(sql);
11125    
11126                                    QueryPos qPos = QueryPos.getInstance(q);
11127    
11128                                    qPos.add(groupId);
11129    
11130                                    qPos.add(nodeId);
11131    
11132                                    if (title != null) {
11133                                            qPos.add(title);
11134                                    }
11135    
11136                                    qPos.add(head);
11137    
11138                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
11139                                                    end);
11140                            }
11141                            catch (Exception e) {
11142                                    throw processException(e);
11143                            }
11144                            finally {
11145                                    if (list == null) {
11146                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11147                                    }
11148                                    else {
11149                                            cacheResult(list);
11150    
11151                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
11152                                    }
11153    
11154                                    closeSession(session);
11155                            }
11156                    }
11157    
11158                    return list;
11159            }
11160    
11161            /**
11162             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11163             *
11164             * @param groupId the group ID
11165             * @param nodeId the node ID
11166             * @param title the title
11167             * @param head the head
11168             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11169             * @return the first matching wiki page
11170             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11171             * @throws SystemException if a system exception occurred
11172             */
11173            public WikiPage findByG_N_T_H_First(long groupId, long nodeId,
11174                    String title, boolean head, OrderByComparator orderByComparator)
11175                    throws NoSuchPageException, SystemException {
11176                    WikiPage wikiPage = fetchByG_N_T_H_First(groupId, nodeId, title, head,
11177                                    orderByComparator);
11178    
11179                    if (wikiPage != null) {
11180                            return wikiPage;
11181                    }
11182    
11183                    StringBundler msg = new StringBundler(10);
11184    
11185                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11186    
11187                    msg.append("groupId=");
11188                    msg.append(groupId);
11189    
11190                    msg.append(", nodeId=");
11191                    msg.append(nodeId);
11192    
11193                    msg.append(", title=");
11194                    msg.append(title);
11195    
11196                    msg.append(", head=");
11197                    msg.append(head);
11198    
11199                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11200    
11201                    throw new NoSuchPageException(msg.toString());
11202            }
11203    
11204            /**
11205             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11206             *
11207             * @param groupId the group ID
11208             * @param nodeId the node ID
11209             * @param title the title
11210             * @param head the head
11211             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11212             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
11213             * @throws SystemException if a system exception occurred
11214             */
11215            public WikiPage fetchByG_N_T_H_First(long groupId, long nodeId,
11216                    String title, boolean head, OrderByComparator orderByComparator)
11217                    throws SystemException {
11218                    List<WikiPage> list = findByG_N_T_H(groupId, nodeId, title, head, 0, 1,
11219                                    orderByComparator);
11220    
11221                    if (!list.isEmpty()) {
11222                            return list.get(0);
11223                    }
11224    
11225                    return null;
11226            }
11227    
11228            /**
11229             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11230             *
11231             * @param groupId the group ID
11232             * @param nodeId the node ID
11233             * @param title the title
11234             * @param head the head
11235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11236             * @return the last matching wiki page
11237             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
11238             * @throws SystemException if a system exception occurred
11239             */
11240            public WikiPage findByG_N_T_H_Last(long groupId, long nodeId, String title,
11241                    boolean head, OrderByComparator orderByComparator)
11242                    throws NoSuchPageException, SystemException {
11243                    WikiPage wikiPage = fetchByG_N_T_H_Last(groupId, nodeId, title, head,
11244                                    orderByComparator);
11245    
11246                    if (wikiPage != null) {
11247                            return wikiPage;
11248                    }
11249    
11250                    StringBundler msg = new StringBundler(10);
11251    
11252                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11253    
11254                    msg.append("groupId=");
11255                    msg.append(groupId);
11256    
11257                    msg.append(", nodeId=");
11258                    msg.append(nodeId);
11259    
11260                    msg.append(", title=");
11261                    msg.append(title);
11262    
11263                    msg.append(", head=");
11264                    msg.append(head);
11265    
11266                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11267    
11268                    throw new NoSuchPageException(msg.toString());
11269            }
11270    
11271            /**
11272             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11273             *
11274             * @param groupId the group ID
11275             * @param nodeId the node ID
11276             * @param title the title
11277             * @param head the head
11278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11279             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
11280             * @throws SystemException if a system exception occurred
11281             */
11282            public WikiPage fetchByG_N_T_H_Last(long groupId, long nodeId,
11283                    String title, boolean head, OrderByComparator orderByComparator)
11284                    throws SystemException {
11285                    int count = countByG_N_T_H(groupId, nodeId, title, head);
11286    
11287                    List<WikiPage> list = findByG_N_T_H(groupId, nodeId, title, head,
11288                                    count - 1, count, orderByComparator);
11289    
11290                    if (!list.isEmpty()) {
11291                            return list.get(0);
11292                    }
11293    
11294                    return null;
11295            }
11296    
11297            /**
11298             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11299             *
11300             * @param pageId the primary key of the current wiki page
11301             * @param groupId the group ID
11302             * @param nodeId the node ID
11303             * @param title the title
11304             * @param head the head
11305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11306             * @return the previous, current, and next wiki page
11307             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
11308             * @throws SystemException if a system exception occurred
11309             */
11310            public WikiPage[] findByG_N_T_H_PrevAndNext(long pageId, long groupId,
11311                    long nodeId, String title, boolean head,
11312                    OrderByComparator orderByComparator)
11313                    throws NoSuchPageException, SystemException {
11314                    WikiPage wikiPage = findByPrimaryKey(pageId);
11315    
11316                    Session session = null;
11317    
11318                    try {
11319                            session = openSession();
11320    
11321                            WikiPage[] array = new WikiPageImpl[3];
11322    
11323                            array[0] = getByG_N_T_H_PrevAndNext(session, wikiPage, groupId,
11324                                            nodeId, title, head, orderByComparator, true);
11325    
11326                            array[1] = wikiPage;
11327    
11328                            array[2] = getByG_N_T_H_PrevAndNext(session, wikiPage, groupId,
11329                                            nodeId, title, head, orderByComparator, false);
11330    
11331                            return array;
11332                    }
11333                    catch (Exception e) {
11334                            throw processException(e);
11335                    }
11336                    finally {
11337                            closeSession(session);
11338                    }
11339            }
11340    
11341            protected WikiPage getByG_N_T_H_PrevAndNext(Session session,
11342                    WikiPage wikiPage, long groupId, long nodeId, String title,
11343                    boolean head, OrderByComparator orderByComparator, boolean previous) {
11344                    StringBundler query = null;
11345    
11346                    if (orderByComparator != null) {
11347                            query = new StringBundler(6 +
11348                                            (orderByComparator.getOrderByFields().length * 6));
11349                    }
11350                    else {
11351                            query = new StringBundler(3);
11352                    }
11353    
11354                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11355    
11356                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
11357    
11358                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
11359    
11360                    if (title == null) {
11361                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
11362                    }
11363                    else {
11364                            if (title.equals(StringPool.BLANK)) {
11365                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
11366                            }
11367                            else {
11368                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
11369                            }
11370                    }
11371    
11372                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
11373    
11374                    if (orderByComparator != null) {
11375                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11376    
11377                            if (orderByConditionFields.length > 0) {
11378                                    query.append(WHERE_AND);
11379                            }
11380    
11381                            for (int i = 0; i < orderByConditionFields.length; i++) {
11382                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11383                                    query.append(orderByConditionFields[i]);
11384    
11385                                    if ((i + 1) < orderByConditionFields.length) {
11386                                            if (orderByComparator.isAscending() ^ previous) {
11387                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11388                                            }
11389                                            else {
11390                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11391                                            }
11392                                    }
11393                                    else {
11394                                            if (orderByComparator.isAscending() ^ previous) {
11395                                                    query.append(WHERE_GREATER_THAN);
11396                                            }
11397                                            else {
11398                                                    query.append(WHERE_LESSER_THAN);
11399                                            }
11400                                    }
11401                            }
11402    
11403                            query.append(ORDER_BY_CLAUSE);
11404    
11405                            String[] orderByFields = orderByComparator.getOrderByFields();
11406    
11407                            for (int i = 0; i < orderByFields.length; i++) {
11408                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11409                                    query.append(orderByFields[i]);
11410    
11411                                    if ((i + 1) < orderByFields.length) {
11412                                            if (orderByComparator.isAscending() ^ previous) {
11413                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11414                                            }
11415                                            else {
11416                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11417                                            }
11418                                    }
11419                                    else {
11420                                            if (orderByComparator.isAscending() ^ previous) {
11421                                                    query.append(ORDER_BY_ASC);
11422                                            }
11423                                            else {
11424                                                    query.append(ORDER_BY_DESC);
11425                                            }
11426                                    }
11427                            }
11428                    }
11429    
11430                    else {
11431                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11432                    }
11433    
11434                    String sql = query.toString();
11435    
11436                    Query q = session.createQuery(sql);
11437    
11438                    q.setFirstResult(0);
11439                    q.setMaxResults(2);
11440    
11441                    QueryPos qPos = QueryPos.getInstance(q);
11442    
11443                    qPos.add(groupId);
11444    
11445                    qPos.add(nodeId);
11446    
11447                    if (title != null) {
11448                            qPos.add(title);
11449                    }
11450    
11451                    qPos.add(head);
11452    
11453                    if (orderByComparator != null) {
11454                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
11455    
11456                            for (Object value : values) {
11457                                    qPos.add(value);
11458                            }
11459                    }
11460    
11461                    List<WikiPage> list = q.list();
11462    
11463                    if (list.size() == 2) {
11464                            return list.get(1);
11465                    }
11466                    else {
11467                            return null;
11468                    }
11469            }
11470    
11471            /**
11472             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11473             *
11474             * @param groupId the group ID
11475             * @param nodeId the node ID
11476             * @param title the title
11477             * @param head the head
11478             * @return the matching wiki pages that the user has permission to view
11479             * @throws SystemException if a system exception occurred
11480             */
11481            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
11482                    String title, boolean head) throws SystemException {
11483                    return filterFindByG_N_T_H(groupId, nodeId, title, head,
11484                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11485            }
11486    
11487            /**
11488             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11489             *
11490             * <p>
11491             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11492             * </p>
11493             *
11494             * @param groupId the group ID
11495             * @param nodeId the node ID
11496             * @param title the title
11497             * @param head the head
11498             * @param start the lower bound of the range of wiki pages
11499             * @param end the upper bound of the range of wiki pages (not inclusive)
11500             * @return the range of matching wiki pages that the user has permission to view
11501             * @throws SystemException if a system exception occurred
11502             */
11503            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
11504                    String title, boolean head, int start, int end)
11505                    throws SystemException {
11506                    return filterFindByG_N_T_H(groupId, nodeId, title, head, start, end,
11507                            null);
11508            }
11509    
11510            /**
11511             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11512             *
11513             * <p>
11514             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11515             * </p>
11516             *
11517             * @param groupId the group ID
11518             * @param nodeId the node ID
11519             * @param title the title
11520             * @param head the head
11521             * @param start the lower bound of the range of wiki pages
11522             * @param end the upper bound of the range of wiki pages (not inclusive)
11523             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11524             * @return the ordered range of matching wiki pages that the user has permission to view
11525             * @throws SystemException if a system exception occurred
11526             */
11527            public List<WikiPage> filterFindByG_N_T_H(long groupId, long nodeId,
11528                    String title, boolean head, int start, int end,
11529                    OrderByComparator orderByComparator) throws SystemException {
11530                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11531                            return findByG_N_T_H(groupId, nodeId, title, head, start, end,
11532                                    orderByComparator);
11533                    }
11534    
11535                    StringBundler query = null;
11536    
11537                    if (orderByComparator != null) {
11538                            query = new StringBundler(6 +
11539                                            (orderByComparator.getOrderByFields().length * 3));
11540                    }
11541                    else {
11542                            query = new StringBundler(6);
11543                    }
11544    
11545                    if (getDB().isSupportsInlineDistinct()) {
11546                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
11547                    }
11548                    else {
11549                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
11550                    }
11551    
11552                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
11553    
11554                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
11555    
11556                    if (title == null) {
11557                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
11558                    }
11559                    else {
11560                            if (title.equals(StringPool.BLANK)) {
11561                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
11562                            }
11563                            else {
11564                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
11565                            }
11566                    }
11567    
11568                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
11569    
11570                    if (!getDB().isSupportsInlineDistinct()) {
11571                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
11572                    }
11573    
11574                    if (orderByComparator != null) {
11575                            if (getDB().isSupportsInlineDistinct()) {
11576                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11577                                            orderByComparator);
11578                            }
11579                            else {
11580                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11581                                            orderByComparator);
11582                            }
11583                    }
11584    
11585                    else {
11586                            if (getDB().isSupportsInlineDistinct()) {
11587                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11588                            }
11589                            else {
11590                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
11591                            }
11592                    }
11593    
11594                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11595                                    WikiPage.class.getName(),
11596                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11597    
11598                    Session session = null;
11599    
11600                    try {
11601                            session = openSession();
11602    
11603                            SQLQuery q = session.createSQLQuery(sql);
11604    
11605                            if (getDB().isSupportsInlineDistinct()) {
11606                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
11607                            }
11608                            else {
11609                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
11610                            }
11611    
11612                            QueryPos qPos = QueryPos.getInstance(q);
11613    
11614                            qPos.add(groupId);
11615    
11616                            qPos.add(nodeId);
11617    
11618                            if (title != null) {
11619                                    qPos.add(title);
11620                            }
11621    
11622                            qPos.add(head);
11623    
11624                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
11625                    }
11626                    catch (Exception e) {
11627                            throw processException(e);
11628                    }
11629                    finally {
11630                            closeSession(session);
11631                    }
11632            }
11633    
11634            /**
11635             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
11636             *
11637             * @param pageId the primary key of the current wiki page
11638             * @param groupId the group ID
11639             * @param nodeId the node ID
11640             * @param title the title
11641             * @param head the head
11642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11643             * @return the previous, current, and next wiki page
11644             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
11645             * @throws SystemException if a system exception occurred
11646             */
11647            public WikiPage[] filterFindByG_N_T_H_PrevAndNext(long pageId,
11648                    long groupId, long nodeId, String title, boolean head,
11649                    OrderByComparator orderByComparator)
11650                    throws NoSuchPageException, SystemException {
11651                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11652                            return findByG_N_T_H_PrevAndNext(pageId, groupId, nodeId, title,
11653                                    head, orderByComparator);
11654                    }
11655    
11656                    WikiPage wikiPage = findByPrimaryKey(pageId);
11657    
11658                    Session session = null;
11659    
11660                    try {
11661                            session = openSession();
11662    
11663                            WikiPage[] array = new WikiPageImpl[3];
11664    
11665                            array[0] = filterGetByG_N_T_H_PrevAndNext(session, wikiPage,
11666                                            groupId, nodeId, title, head, orderByComparator, true);
11667    
11668                            array[1] = wikiPage;
11669    
11670                            array[2] = filterGetByG_N_T_H_PrevAndNext(session, wikiPage,
11671                                            groupId, nodeId, title, head, orderByComparator, false);
11672    
11673                            return array;
11674                    }
11675                    catch (Exception e) {
11676                            throw processException(e);
11677                    }
11678                    finally {
11679                            closeSession(session);
11680                    }
11681            }
11682    
11683            protected WikiPage filterGetByG_N_T_H_PrevAndNext(Session session,
11684                    WikiPage wikiPage, long groupId, long nodeId, String title,
11685                    boolean head, OrderByComparator orderByComparator, boolean previous) {
11686                    StringBundler query = null;
11687    
11688                    if (orderByComparator != null) {
11689                            query = new StringBundler(6 +
11690                                            (orderByComparator.getOrderByFields().length * 6));
11691                    }
11692                    else {
11693                            query = new StringBundler(3);
11694                    }
11695    
11696                    if (getDB().isSupportsInlineDistinct()) {
11697                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
11698                    }
11699                    else {
11700                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
11701                    }
11702    
11703                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
11704    
11705                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
11706    
11707                    if (title == null) {
11708                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
11709                    }
11710                    else {
11711                            if (title.equals(StringPool.BLANK)) {
11712                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
11713                            }
11714                            else {
11715                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
11716                            }
11717                    }
11718    
11719                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
11720    
11721                    if (!getDB().isSupportsInlineDistinct()) {
11722                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
11723                    }
11724    
11725                    if (orderByComparator != null) {
11726                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11727    
11728                            if (orderByConditionFields.length > 0) {
11729                                    query.append(WHERE_AND);
11730                            }
11731    
11732                            for (int i = 0; i < orderByConditionFields.length; i++) {
11733                                    if (getDB().isSupportsInlineDistinct()) {
11734                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11735                                    }
11736                                    else {
11737                                            query.append(_ORDER_BY_ENTITY_TABLE);
11738                                    }
11739    
11740                                    query.append(orderByConditionFields[i]);
11741    
11742                                    if ((i + 1) < orderByConditionFields.length) {
11743                                            if (orderByComparator.isAscending() ^ previous) {
11744                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11745                                            }
11746                                            else {
11747                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11748                                            }
11749                                    }
11750                                    else {
11751                                            if (orderByComparator.isAscending() ^ previous) {
11752                                                    query.append(WHERE_GREATER_THAN);
11753                                            }
11754                                            else {
11755                                                    query.append(WHERE_LESSER_THAN);
11756                                            }
11757                                    }
11758                            }
11759    
11760                            query.append(ORDER_BY_CLAUSE);
11761    
11762                            String[] orderByFields = orderByComparator.getOrderByFields();
11763    
11764                            for (int i = 0; i < orderByFields.length; i++) {
11765                                    if (getDB().isSupportsInlineDistinct()) {
11766                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11767                                    }
11768                                    else {
11769                                            query.append(_ORDER_BY_ENTITY_TABLE);
11770                                    }
11771    
11772                                    query.append(orderByFields[i]);
11773    
11774                                    if ((i + 1) < orderByFields.length) {
11775                                            if (orderByComparator.isAscending() ^ previous) {
11776                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11777                                            }
11778                                            else {
11779                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11780                                            }
11781                                    }
11782                                    else {
11783                                            if (orderByComparator.isAscending() ^ previous) {
11784                                                    query.append(ORDER_BY_ASC);
11785                                            }
11786                                            else {
11787                                                    query.append(ORDER_BY_DESC);
11788                                            }
11789                                    }
11790                            }
11791                    }
11792    
11793                    else {
11794                            if (getDB().isSupportsInlineDistinct()) {
11795                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11796                            }
11797                            else {
11798                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
11799                            }
11800                    }
11801    
11802                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11803                                    WikiPage.class.getName(),
11804                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11805    
11806                    SQLQuery q = session.createSQLQuery(sql);
11807    
11808                    q.setFirstResult(0);
11809                    q.setMaxResults(2);
11810    
11811                    if (getDB().isSupportsInlineDistinct()) {
11812                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
11813                    }
11814                    else {
11815                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
11816                    }
11817    
11818                    QueryPos qPos = QueryPos.getInstance(q);
11819    
11820                    qPos.add(groupId);
11821    
11822                    qPos.add(nodeId);
11823    
11824                    if (title != null) {
11825                            qPos.add(title);
11826                    }
11827    
11828                    qPos.add(head);
11829    
11830                    if (orderByComparator != null) {
11831                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
11832    
11833                            for (Object value : values) {
11834                                    qPos.add(value);
11835                            }
11836                    }
11837    
11838                    List<WikiPage> list = q.list();
11839    
11840                    if (list.size() == 2) {
11841                            return list.get(1);
11842                    }
11843                    else {
11844                            return null;
11845                    }
11846            }
11847    
11848            /**
11849             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
11850             *
11851             * @param groupId the group ID
11852             * @param nodeId the node ID
11853             * @param head the head
11854             * @param status the status
11855             * @return the matching wiki pages
11856             * @throws SystemException if a system exception occurred
11857             */
11858            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
11859                    boolean head, int status) throws SystemException {
11860                    return findByG_N_H_S(groupId, nodeId, head, status, QueryUtil.ALL_POS,
11861                            QueryUtil.ALL_POS, null);
11862            }
11863    
11864            /**
11865             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
11866             *
11867             * <p>
11868             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11869             * </p>
11870             *
11871             * @param groupId the group ID
11872             * @param nodeId the node ID
11873             * @param head the head
11874             * @param status the status
11875             * @param start the lower bound of the range of wiki pages
11876             * @param end the upper bound of the range of wiki pages (not inclusive)
11877             * @return the range of matching wiki pages
11878             * @throws SystemException if a system exception occurred
11879             */
11880            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
11881                    boolean head, int status, int start, int end) throws SystemException {
11882                    return findByG_N_H_S(groupId, nodeId, head, status, start, end, null);
11883            }
11884    
11885            /**
11886             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
11887             *
11888             * <p>
11889             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11890             * </p>
11891             *
11892             * @param groupId the group ID
11893             * @param nodeId the node ID
11894             * @param head the head
11895             * @param status the status
11896             * @param start the lower bound of the range of wiki pages
11897             * @param end the upper bound of the range of wiki pages (not inclusive)
11898             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11899             * @return the ordered range of matching wiki pages
11900             * @throws SystemException if a system exception occurred
11901             */
11902            public List<WikiPage> findByG_N_H_S(long groupId, long nodeId,
11903                    boolean head, int status, int start, int end,
11904                    OrderByComparator orderByComparator) throws SystemException {
11905                    FinderPath finderPath = null;
11906                    Object[] finderArgs = null;
11907    
11908                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11909                                    (orderByComparator == null)) {
11910                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_S;
11911                            finderArgs = new Object[] { groupId, nodeId, head, status };
11912                    }
11913                    else {
11914                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_S;
11915                            finderArgs = new Object[] {
11916                                            groupId, nodeId, head, status,
11917                                            
11918                                            start, end, orderByComparator
11919                                    };
11920                    }
11921    
11922                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
11923                                    finderArgs, this);
11924    
11925                    if ((list != null) && !list.isEmpty()) {
11926                            for (WikiPage wikiPage : list) {
11927                                    if ((groupId != wikiPage.getGroupId()) ||
11928                                                    (nodeId != wikiPage.getNodeId()) ||
11929                                                    (head != wikiPage.getHead()) ||
11930                                                    (status != wikiPage.getStatus())) {
11931                                            list = null;
11932    
11933                                            break;
11934                                    }
11935                            }
11936                    }
11937    
11938                    if (list == null) {
11939                            StringBundler query = null;
11940    
11941                            if (orderByComparator != null) {
11942                                    query = new StringBundler(6 +
11943                                                    (orderByComparator.getOrderByFields().length * 3));
11944                            }
11945                            else {
11946                                    query = new StringBundler(6);
11947                            }
11948    
11949                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
11950    
11951                            query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
11952    
11953                            query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
11954    
11955                            query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
11956    
11957                            query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
11958    
11959                            if (orderByComparator != null) {
11960                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11961                                            orderByComparator);
11962                            }
11963    
11964                            else {
11965                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
11966                            }
11967    
11968                            String sql = query.toString();
11969    
11970                            Session session = null;
11971    
11972                            try {
11973                                    session = openSession();
11974    
11975                                    Query q = session.createQuery(sql);
11976    
11977                                    QueryPos qPos = QueryPos.getInstance(q);
11978    
11979                                    qPos.add(groupId);
11980    
11981                                    qPos.add(nodeId);
11982    
11983                                    qPos.add(head);
11984    
11985                                    qPos.add(status);
11986    
11987                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
11988                                                    end);
11989                            }
11990                            catch (Exception e) {
11991                                    throw processException(e);
11992                            }
11993                            finally {
11994                                    if (list == null) {
11995                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11996                                    }
11997                                    else {
11998                                            cacheResult(list);
11999    
12000                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12001                                    }
12002    
12003                                    closeSession(session);
12004                            }
12005                    }
12006    
12007                    return list;
12008            }
12009    
12010            /**
12011             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12012             *
12013             * @param groupId the group ID
12014             * @param nodeId the node ID
12015             * @param head the head
12016             * @param status the status
12017             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12018             * @return the first matching wiki page
12019             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12020             * @throws SystemException if a system exception occurred
12021             */
12022            public WikiPage findByG_N_H_S_First(long groupId, long nodeId,
12023                    boolean head, int status, OrderByComparator orderByComparator)
12024                    throws NoSuchPageException, SystemException {
12025                    WikiPage wikiPage = fetchByG_N_H_S_First(groupId, nodeId, head, status,
12026                                    orderByComparator);
12027    
12028                    if (wikiPage != null) {
12029                            return wikiPage;
12030                    }
12031    
12032                    StringBundler msg = new StringBundler(10);
12033    
12034                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12035    
12036                    msg.append("groupId=");
12037                    msg.append(groupId);
12038    
12039                    msg.append(", nodeId=");
12040                    msg.append(nodeId);
12041    
12042                    msg.append(", head=");
12043                    msg.append(head);
12044    
12045                    msg.append(", status=");
12046                    msg.append(status);
12047    
12048                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12049    
12050                    throw new NoSuchPageException(msg.toString());
12051            }
12052    
12053            /**
12054             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12055             *
12056             * @param groupId the group ID
12057             * @param nodeId the node ID
12058             * @param head the head
12059             * @param status the status
12060             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12061             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
12062             * @throws SystemException if a system exception occurred
12063             */
12064            public WikiPage fetchByG_N_H_S_First(long groupId, long nodeId,
12065                    boolean head, int status, OrderByComparator orderByComparator)
12066                    throws SystemException {
12067                    List<WikiPage> list = findByG_N_H_S(groupId, nodeId, head, status, 0,
12068                                    1, orderByComparator);
12069    
12070                    if (!list.isEmpty()) {
12071                            return list.get(0);
12072                    }
12073    
12074                    return null;
12075            }
12076    
12077            /**
12078             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12079             *
12080             * @param groupId the group ID
12081             * @param nodeId the node ID
12082             * @param head the head
12083             * @param status the status
12084             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12085             * @return the last matching wiki page
12086             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12087             * @throws SystemException if a system exception occurred
12088             */
12089            public WikiPage findByG_N_H_S_Last(long groupId, long nodeId, boolean head,
12090                    int status, OrderByComparator orderByComparator)
12091                    throws NoSuchPageException, SystemException {
12092                    WikiPage wikiPage = fetchByG_N_H_S_Last(groupId, nodeId, head, status,
12093                                    orderByComparator);
12094    
12095                    if (wikiPage != null) {
12096                            return wikiPage;
12097                    }
12098    
12099                    StringBundler msg = new StringBundler(10);
12100    
12101                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12102    
12103                    msg.append("groupId=");
12104                    msg.append(groupId);
12105    
12106                    msg.append(", nodeId=");
12107                    msg.append(nodeId);
12108    
12109                    msg.append(", head=");
12110                    msg.append(head);
12111    
12112                    msg.append(", status=");
12113                    msg.append(status);
12114    
12115                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12116    
12117                    throw new NoSuchPageException(msg.toString());
12118            }
12119    
12120            /**
12121             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12122             *
12123             * @param groupId the group ID
12124             * @param nodeId the node ID
12125             * @param head the head
12126             * @param status the status
12127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12128             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
12129             * @throws SystemException if a system exception occurred
12130             */
12131            public WikiPage fetchByG_N_H_S_Last(long groupId, long nodeId,
12132                    boolean head, int status, OrderByComparator orderByComparator)
12133                    throws SystemException {
12134                    int count = countByG_N_H_S(groupId, nodeId, head, status);
12135    
12136                    List<WikiPage> list = findByG_N_H_S(groupId, nodeId, head, status,
12137                                    count - 1, count, orderByComparator);
12138    
12139                    if (!list.isEmpty()) {
12140                            return list.get(0);
12141                    }
12142    
12143                    return null;
12144            }
12145    
12146            /**
12147             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12148             *
12149             * @param pageId the primary key of the current wiki page
12150             * @param groupId the group ID
12151             * @param nodeId the node ID
12152             * @param head the head
12153             * @param status the status
12154             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12155             * @return the previous, current, and next wiki page
12156             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
12157             * @throws SystemException if a system exception occurred
12158             */
12159            public WikiPage[] findByG_N_H_S_PrevAndNext(long pageId, long groupId,
12160                    long nodeId, boolean head, int status,
12161                    OrderByComparator orderByComparator)
12162                    throws NoSuchPageException, SystemException {
12163                    WikiPage wikiPage = findByPrimaryKey(pageId);
12164    
12165                    Session session = null;
12166    
12167                    try {
12168                            session = openSession();
12169    
12170                            WikiPage[] array = new WikiPageImpl[3];
12171    
12172                            array[0] = getByG_N_H_S_PrevAndNext(session, wikiPage, groupId,
12173                                            nodeId, head, status, orderByComparator, true);
12174    
12175                            array[1] = wikiPage;
12176    
12177                            array[2] = getByG_N_H_S_PrevAndNext(session, wikiPage, groupId,
12178                                            nodeId, head, status, orderByComparator, false);
12179    
12180                            return array;
12181                    }
12182                    catch (Exception e) {
12183                            throw processException(e);
12184                    }
12185                    finally {
12186                            closeSession(session);
12187                    }
12188            }
12189    
12190            protected WikiPage getByG_N_H_S_PrevAndNext(Session session,
12191                    WikiPage wikiPage, long groupId, long nodeId, boolean head, int status,
12192                    OrderByComparator orderByComparator, boolean previous) {
12193                    StringBundler query = null;
12194    
12195                    if (orderByComparator != null) {
12196                            query = new StringBundler(6 +
12197                                            (orderByComparator.getOrderByFields().length * 6));
12198                    }
12199                    else {
12200                            query = new StringBundler(3);
12201                    }
12202    
12203                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
12204    
12205                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
12206    
12207                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
12208    
12209                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
12210    
12211                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
12212    
12213                    if (orderByComparator != null) {
12214                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12215    
12216                            if (orderByConditionFields.length > 0) {
12217                                    query.append(WHERE_AND);
12218                            }
12219    
12220                            for (int i = 0; i < orderByConditionFields.length; i++) {
12221                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12222                                    query.append(orderByConditionFields[i]);
12223    
12224                                    if ((i + 1) < orderByConditionFields.length) {
12225                                            if (orderByComparator.isAscending() ^ previous) {
12226                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12227                                            }
12228                                            else {
12229                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12230                                            }
12231                                    }
12232                                    else {
12233                                            if (orderByComparator.isAscending() ^ previous) {
12234                                                    query.append(WHERE_GREATER_THAN);
12235                                            }
12236                                            else {
12237                                                    query.append(WHERE_LESSER_THAN);
12238                                            }
12239                                    }
12240                            }
12241    
12242                            query.append(ORDER_BY_CLAUSE);
12243    
12244                            String[] orderByFields = orderByComparator.getOrderByFields();
12245    
12246                            for (int i = 0; i < orderByFields.length; i++) {
12247                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12248                                    query.append(orderByFields[i]);
12249    
12250                                    if ((i + 1) < orderByFields.length) {
12251                                            if (orderByComparator.isAscending() ^ previous) {
12252                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12253                                            }
12254                                            else {
12255                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12256                                            }
12257                                    }
12258                                    else {
12259                                            if (orderByComparator.isAscending() ^ previous) {
12260                                                    query.append(ORDER_BY_ASC);
12261                                            }
12262                                            else {
12263                                                    query.append(ORDER_BY_DESC);
12264                                            }
12265                                    }
12266                            }
12267                    }
12268    
12269                    else {
12270                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12271                    }
12272    
12273                    String sql = query.toString();
12274    
12275                    Query q = session.createQuery(sql);
12276    
12277                    q.setFirstResult(0);
12278                    q.setMaxResults(2);
12279    
12280                    QueryPos qPos = QueryPos.getInstance(q);
12281    
12282                    qPos.add(groupId);
12283    
12284                    qPos.add(nodeId);
12285    
12286                    qPos.add(head);
12287    
12288                    qPos.add(status);
12289    
12290                    if (orderByComparator != null) {
12291                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
12292    
12293                            for (Object value : values) {
12294                                    qPos.add(value);
12295                            }
12296                    }
12297    
12298                    List<WikiPage> list = q.list();
12299    
12300                    if (list.size() == 2) {
12301                            return list.get(1);
12302                    }
12303                    else {
12304                            return null;
12305                    }
12306            }
12307    
12308            /**
12309             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12310             *
12311             * @param groupId the group ID
12312             * @param nodeId the node ID
12313             * @param head the head
12314             * @param status the status
12315             * @return the matching wiki pages that the user has permission to view
12316             * @throws SystemException if a system exception occurred
12317             */
12318            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
12319                    boolean head, int status) throws SystemException {
12320                    return filterFindByG_N_H_S(groupId, nodeId, head, status,
12321                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12322            }
12323    
12324            /**
12325             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12326             *
12327             * <p>
12328             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12329             * </p>
12330             *
12331             * @param groupId the group ID
12332             * @param nodeId the node ID
12333             * @param head the head
12334             * @param status the status
12335             * @param start the lower bound of the range of wiki pages
12336             * @param end the upper bound of the range of wiki pages (not inclusive)
12337             * @return the range of matching wiki pages that the user has permission to view
12338             * @throws SystemException if a system exception occurred
12339             */
12340            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
12341                    boolean head, int status, int start, int end) throws SystemException {
12342                    return filterFindByG_N_H_S(groupId, nodeId, head, status, start, end,
12343                            null);
12344            }
12345    
12346            /**
12347             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12348             *
12349             * <p>
12350             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12351             * </p>
12352             *
12353             * @param groupId the group ID
12354             * @param nodeId the node ID
12355             * @param head the head
12356             * @param status the status
12357             * @param start the lower bound of the range of wiki pages
12358             * @param end the upper bound of the range of wiki pages (not inclusive)
12359             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12360             * @return the ordered range of matching wiki pages that the user has permission to view
12361             * @throws SystemException if a system exception occurred
12362             */
12363            public List<WikiPage> filterFindByG_N_H_S(long groupId, long nodeId,
12364                    boolean head, int status, int start, int end,
12365                    OrderByComparator orderByComparator) throws SystemException {
12366                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12367                            return findByG_N_H_S(groupId, nodeId, head, status, start, end,
12368                                    orderByComparator);
12369                    }
12370    
12371                    StringBundler query = null;
12372    
12373                    if (orderByComparator != null) {
12374                            query = new StringBundler(6 +
12375                                            (orderByComparator.getOrderByFields().length * 3));
12376                    }
12377                    else {
12378                            query = new StringBundler(6);
12379                    }
12380    
12381                    if (getDB().isSupportsInlineDistinct()) {
12382                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
12383                    }
12384                    else {
12385                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
12386                    }
12387    
12388                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
12389    
12390                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
12391    
12392                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
12393    
12394                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
12395    
12396                    if (!getDB().isSupportsInlineDistinct()) {
12397                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
12398                    }
12399    
12400                    if (orderByComparator != null) {
12401                            if (getDB().isSupportsInlineDistinct()) {
12402                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12403                                            orderByComparator);
12404                            }
12405                            else {
12406                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12407                                            orderByComparator);
12408                            }
12409                    }
12410    
12411                    else {
12412                            if (getDB().isSupportsInlineDistinct()) {
12413                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12414                            }
12415                            else {
12416                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
12417                            }
12418                    }
12419    
12420                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12421                                    WikiPage.class.getName(),
12422                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12423    
12424                    Session session = null;
12425    
12426                    try {
12427                            session = openSession();
12428    
12429                            SQLQuery q = session.createSQLQuery(sql);
12430    
12431                            if (getDB().isSupportsInlineDistinct()) {
12432                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
12433                            }
12434                            else {
12435                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
12436                            }
12437    
12438                            QueryPos qPos = QueryPos.getInstance(q);
12439    
12440                            qPos.add(groupId);
12441    
12442                            qPos.add(nodeId);
12443    
12444                            qPos.add(head);
12445    
12446                            qPos.add(status);
12447    
12448                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
12449                    }
12450                    catch (Exception e) {
12451                            throw processException(e);
12452                    }
12453                    finally {
12454                            closeSession(session);
12455                    }
12456            }
12457    
12458            /**
12459             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
12460             *
12461             * @param pageId the primary key of the current wiki page
12462             * @param groupId the group ID
12463             * @param nodeId the node ID
12464             * @param head the head
12465             * @param status the status
12466             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12467             * @return the previous, current, and next wiki page
12468             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
12469             * @throws SystemException if a system exception occurred
12470             */
12471            public WikiPage[] filterFindByG_N_H_S_PrevAndNext(long pageId,
12472                    long groupId, long nodeId, boolean head, int status,
12473                    OrderByComparator orderByComparator)
12474                    throws NoSuchPageException, SystemException {
12475                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12476                            return findByG_N_H_S_PrevAndNext(pageId, groupId, nodeId, head,
12477                                    status, orderByComparator);
12478                    }
12479    
12480                    WikiPage wikiPage = findByPrimaryKey(pageId);
12481    
12482                    Session session = null;
12483    
12484                    try {
12485                            session = openSession();
12486    
12487                            WikiPage[] array = new WikiPageImpl[3];
12488    
12489                            array[0] = filterGetByG_N_H_S_PrevAndNext(session, wikiPage,
12490                                            groupId, nodeId, head, status, orderByComparator, true);
12491    
12492                            array[1] = wikiPage;
12493    
12494                            array[2] = filterGetByG_N_H_S_PrevAndNext(session, wikiPage,
12495                                            groupId, nodeId, head, status, orderByComparator, false);
12496    
12497                            return array;
12498                    }
12499                    catch (Exception e) {
12500                            throw processException(e);
12501                    }
12502                    finally {
12503                            closeSession(session);
12504                    }
12505            }
12506    
12507            protected WikiPage filterGetByG_N_H_S_PrevAndNext(Session session,
12508                    WikiPage wikiPage, long groupId, long nodeId, boolean head, int status,
12509                    OrderByComparator orderByComparator, boolean previous) {
12510                    StringBundler query = null;
12511    
12512                    if (orderByComparator != null) {
12513                            query = new StringBundler(6 +
12514                                            (orderByComparator.getOrderByFields().length * 6));
12515                    }
12516                    else {
12517                            query = new StringBundler(3);
12518                    }
12519    
12520                    if (getDB().isSupportsInlineDistinct()) {
12521                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
12522                    }
12523                    else {
12524                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
12525                    }
12526    
12527                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
12528    
12529                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
12530    
12531                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
12532    
12533                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
12534    
12535                    if (!getDB().isSupportsInlineDistinct()) {
12536                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
12537                    }
12538    
12539                    if (orderByComparator != null) {
12540                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12541    
12542                            if (orderByConditionFields.length > 0) {
12543                                    query.append(WHERE_AND);
12544                            }
12545    
12546                            for (int i = 0; i < orderByConditionFields.length; i++) {
12547                                    if (getDB().isSupportsInlineDistinct()) {
12548                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12549                                    }
12550                                    else {
12551                                            query.append(_ORDER_BY_ENTITY_TABLE);
12552                                    }
12553    
12554                                    query.append(orderByConditionFields[i]);
12555    
12556                                    if ((i + 1) < orderByConditionFields.length) {
12557                                            if (orderByComparator.isAscending() ^ previous) {
12558                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12559                                            }
12560                                            else {
12561                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12562                                            }
12563                                    }
12564                                    else {
12565                                            if (orderByComparator.isAscending() ^ previous) {
12566                                                    query.append(WHERE_GREATER_THAN);
12567                                            }
12568                                            else {
12569                                                    query.append(WHERE_LESSER_THAN);
12570                                            }
12571                                    }
12572                            }
12573    
12574                            query.append(ORDER_BY_CLAUSE);
12575    
12576                            String[] orderByFields = orderByComparator.getOrderByFields();
12577    
12578                            for (int i = 0; i < orderByFields.length; i++) {
12579                                    if (getDB().isSupportsInlineDistinct()) {
12580                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12581                                    }
12582                                    else {
12583                                            query.append(_ORDER_BY_ENTITY_TABLE);
12584                                    }
12585    
12586                                    query.append(orderByFields[i]);
12587    
12588                                    if ((i + 1) < orderByFields.length) {
12589                                            if (orderByComparator.isAscending() ^ previous) {
12590                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12591                                            }
12592                                            else {
12593                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12594                                            }
12595                                    }
12596                                    else {
12597                                            if (orderByComparator.isAscending() ^ previous) {
12598                                                    query.append(ORDER_BY_ASC);
12599                                            }
12600                                            else {
12601                                                    query.append(ORDER_BY_DESC);
12602                                            }
12603                                    }
12604                            }
12605                    }
12606    
12607                    else {
12608                            if (getDB().isSupportsInlineDistinct()) {
12609                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12610                            }
12611                            else {
12612                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
12613                            }
12614                    }
12615    
12616                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12617                                    WikiPage.class.getName(),
12618                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12619    
12620                    SQLQuery q = session.createSQLQuery(sql);
12621    
12622                    q.setFirstResult(0);
12623                    q.setMaxResults(2);
12624    
12625                    if (getDB().isSupportsInlineDistinct()) {
12626                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
12627                    }
12628                    else {
12629                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
12630                    }
12631    
12632                    QueryPos qPos = QueryPos.getInstance(q);
12633    
12634                    qPos.add(groupId);
12635    
12636                    qPos.add(nodeId);
12637    
12638                    qPos.add(head);
12639    
12640                    qPos.add(status);
12641    
12642                    if (orderByComparator != null) {
12643                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
12644    
12645                            for (Object value : values) {
12646                                    qPos.add(value);
12647                            }
12648                    }
12649    
12650                    List<WikiPage> list = q.list();
12651    
12652                    if (list.size() == 2) {
12653                            return list.get(1);
12654                    }
12655                    else {
12656                            return null;
12657                    }
12658            }
12659    
12660            /**
12661             * Returns all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
12662             *
12663             * @param nodeId the node ID
12664             * @param head the head
12665             * @param parentTitle the parent title
12666             * @param status the status
12667             * @return the matching wiki pages
12668             * @throws SystemException if a system exception occurred
12669             */
12670            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
12671                    String parentTitle, int status) throws SystemException {
12672                    return findByN_H_P_S(nodeId, head, parentTitle, status,
12673                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12674            }
12675    
12676            /**
12677             * Returns a range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
12678             *
12679             * <p>
12680             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12681             * </p>
12682             *
12683             * @param nodeId the node ID
12684             * @param head the head
12685             * @param parentTitle the parent title
12686             * @param status the status
12687             * @param start the lower bound of the range of wiki pages
12688             * @param end the upper bound of the range of wiki pages (not inclusive)
12689             * @return the range of matching wiki pages
12690             * @throws SystemException if a system exception occurred
12691             */
12692            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
12693                    String parentTitle, int status, int start, int end)
12694                    throws SystemException {
12695                    return findByN_H_P_S(nodeId, head, parentTitle, status, start, end, null);
12696            }
12697    
12698            /**
12699             * Returns an ordered range of all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
12700             *
12701             * <p>
12702             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12703             * </p>
12704             *
12705             * @param nodeId the node ID
12706             * @param head the head
12707             * @param parentTitle the parent title
12708             * @param status the status
12709             * @param start the lower bound of the range of wiki pages
12710             * @param end the upper bound of the range of wiki pages (not inclusive)
12711             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12712             * @return the ordered range of matching wiki pages
12713             * @throws SystemException if a system exception occurred
12714             */
12715            public List<WikiPage> findByN_H_P_S(long nodeId, boolean head,
12716                    String parentTitle, int status, int start, int end,
12717                    OrderByComparator orderByComparator) throws SystemException {
12718                    FinderPath finderPath = null;
12719                    Object[] finderArgs = null;
12720    
12721                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12722                                    (orderByComparator == null)) {
12723                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_H_P_S;
12724                            finderArgs = new Object[] { nodeId, head, parentTitle, status };
12725                    }
12726                    else {
12727                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_H_P_S;
12728                            finderArgs = new Object[] {
12729                                            nodeId, head, parentTitle, status,
12730                                            
12731                                            start, end, orderByComparator
12732                                    };
12733                    }
12734    
12735                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
12736                                    finderArgs, this);
12737    
12738                    if ((list != null) && !list.isEmpty()) {
12739                            for (WikiPage wikiPage : list) {
12740                                    if ((nodeId != wikiPage.getNodeId()) ||
12741                                                    (head != wikiPage.getHead()) ||
12742                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle()) ||
12743                                                    (status != wikiPage.getStatus())) {
12744                                            list = null;
12745    
12746                                            break;
12747                                    }
12748                            }
12749                    }
12750    
12751                    if (list == null) {
12752                            StringBundler query = null;
12753    
12754                            if (orderByComparator != null) {
12755                                    query = new StringBundler(6 +
12756                                                    (orderByComparator.getOrderByFields().length * 3));
12757                            }
12758                            else {
12759                                    query = new StringBundler(6);
12760                            }
12761    
12762                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
12763    
12764                            query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
12765    
12766                            query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
12767    
12768                            if (parentTitle == null) {
12769                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
12770                            }
12771                            else {
12772                                    if (parentTitle.equals(StringPool.BLANK)) {
12773                                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
12774                                    }
12775                                    else {
12776                                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
12777                                    }
12778                            }
12779    
12780                            query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
12781    
12782                            if (orderByComparator != null) {
12783                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12784                                            orderByComparator);
12785                            }
12786    
12787                            else {
12788                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
12789                            }
12790    
12791                            String sql = query.toString();
12792    
12793                            Session session = null;
12794    
12795                            try {
12796                                    session = openSession();
12797    
12798                                    Query q = session.createQuery(sql);
12799    
12800                                    QueryPos qPos = QueryPos.getInstance(q);
12801    
12802                                    qPos.add(nodeId);
12803    
12804                                    qPos.add(head);
12805    
12806                                    if (parentTitle != null) {
12807                                            qPos.add(parentTitle);
12808                                    }
12809    
12810                                    qPos.add(status);
12811    
12812                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
12813                                                    end);
12814                            }
12815                            catch (Exception e) {
12816                                    throw processException(e);
12817                            }
12818                            finally {
12819                                    if (list == null) {
12820                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12821                                    }
12822                                    else {
12823                                            cacheResult(list);
12824    
12825                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12826                                    }
12827    
12828                                    closeSession(session);
12829                            }
12830                    }
12831    
12832                    return list;
12833            }
12834    
12835            /**
12836             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
12837             *
12838             * @param nodeId the node ID
12839             * @param head the head
12840             * @param parentTitle the parent title
12841             * @param status the status
12842             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12843             * @return the first matching wiki page
12844             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12845             * @throws SystemException if a system exception occurred
12846             */
12847            public WikiPage findByN_H_P_S_First(long nodeId, boolean head,
12848                    String parentTitle, int status, OrderByComparator orderByComparator)
12849                    throws NoSuchPageException, SystemException {
12850                    WikiPage wikiPage = fetchByN_H_P_S_First(nodeId, head, parentTitle,
12851                                    status, orderByComparator);
12852    
12853                    if (wikiPage != null) {
12854                            return wikiPage;
12855                    }
12856    
12857                    StringBundler msg = new StringBundler(10);
12858    
12859                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12860    
12861                    msg.append("nodeId=");
12862                    msg.append(nodeId);
12863    
12864                    msg.append(", head=");
12865                    msg.append(head);
12866    
12867                    msg.append(", parentTitle=");
12868                    msg.append(parentTitle);
12869    
12870                    msg.append(", status=");
12871                    msg.append(status);
12872    
12873                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12874    
12875                    throw new NoSuchPageException(msg.toString());
12876            }
12877    
12878            /**
12879             * Returns the first wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
12880             *
12881             * @param nodeId the node ID
12882             * @param head the head
12883             * @param parentTitle the parent title
12884             * @param status the status
12885             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12886             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
12887             * @throws SystemException if a system exception occurred
12888             */
12889            public WikiPage fetchByN_H_P_S_First(long nodeId, boolean head,
12890                    String parentTitle, int status, OrderByComparator orderByComparator)
12891                    throws SystemException {
12892                    List<WikiPage> list = findByN_H_P_S(nodeId, head, parentTitle, status,
12893                                    0, 1, orderByComparator);
12894    
12895                    if (!list.isEmpty()) {
12896                            return list.get(0);
12897                    }
12898    
12899                    return null;
12900            }
12901    
12902            /**
12903             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
12904             *
12905             * @param nodeId the node ID
12906             * @param head the head
12907             * @param parentTitle the parent title
12908             * @param status the status
12909             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12910             * @return the last matching wiki page
12911             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
12912             * @throws SystemException if a system exception occurred
12913             */
12914            public WikiPage findByN_H_P_S_Last(long nodeId, boolean head,
12915                    String parentTitle, int status, OrderByComparator orderByComparator)
12916                    throws NoSuchPageException, SystemException {
12917                    WikiPage wikiPage = fetchByN_H_P_S_Last(nodeId, head, parentTitle,
12918                                    status, orderByComparator);
12919    
12920                    if (wikiPage != null) {
12921                            return wikiPage;
12922                    }
12923    
12924                    StringBundler msg = new StringBundler(10);
12925    
12926                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12927    
12928                    msg.append("nodeId=");
12929                    msg.append(nodeId);
12930    
12931                    msg.append(", head=");
12932                    msg.append(head);
12933    
12934                    msg.append(", parentTitle=");
12935                    msg.append(parentTitle);
12936    
12937                    msg.append(", status=");
12938                    msg.append(status);
12939    
12940                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12941    
12942                    throw new NoSuchPageException(msg.toString());
12943            }
12944    
12945            /**
12946             * Returns the last wiki page in the ordered set where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
12947             *
12948             * @param nodeId the node ID
12949             * @param head the head
12950             * @param parentTitle the parent title
12951             * @param status the status
12952             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12953             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
12954             * @throws SystemException if a system exception occurred
12955             */
12956            public WikiPage fetchByN_H_P_S_Last(long nodeId, boolean head,
12957                    String parentTitle, int status, OrderByComparator orderByComparator)
12958                    throws SystemException {
12959                    int count = countByN_H_P_S(nodeId, head, parentTitle, status);
12960    
12961                    List<WikiPage> list = findByN_H_P_S(nodeId, head, parentTitle, status,
12962                                    count - 1, count, orderByComparator);
12963    
12964                    if (!list.isEmpty()) {
12965                            return list.get(0);
12966                    }
12967    
12968                    return null;
12969            }
12970    
12971            /**
12972             * 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;.
12973             *
12974             * @param pageId the primary key of the current wiki page
12975             * @param nodeId the node ID
12976             * @param head the head
12977             * @param parentTitle the parent title
12978             * @param status the status
12979             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12980             * @return the previous, current, and next wiki page
12981             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
12982             * @throws SystemException if a system exception occurred
12983             */
12984            public WikiPage[] findByN_H_P_S_PrevAndNext(long pageId, long nodeId,
12985                    boolean head, String parentTitle, int status,
12986                    OrderByComparator orderByComparator)
12987                    throws NoSuchPageException, SystemException {
12988                    WikiPage wikiPage = findByPrimaryKey(pageId);
12989    
12990                    Session session = null;
12991    
12992                    try {
12993                            session = openSession();
12994    
12995                            WikiPage[] array = new WikiPageImpl[3];
12996    
12997                            array[0] = getByN_H_P_S_PrevAndNext(session, wikiPage, nodeId,
12998                                            head, parentTitle, status, orderByComparator, true);
12999    
13000                            array[1] = wikiPage;
13001    
13002                            array[2] = getByN_H_P_S_PrevAndNext(session, wikiPage, nodeId,
13003                                            head, parentTitle, status, orderByComparator, false);
13004    
13005                            return array;
13006                    }
13007                    catch (Exception e) {
13008                            throw processException(e);
13009                    }
13010                    finally {
13011                            closeSession(session);
13012                    }
13013            }
13014    
13015            protected WikiPage getByN_H_P_S_PrevAndNext(Session session,
13016                    WikiPage wikiPage, long nodeId, boolean head, String parentTitle,
13017                    int status, OrderByComparator orderByComparator, boolean previous) {
13018                    StringBundler query = null;
13019    
13020                    if (orderByComparator != null) {
13021                            query = new StringBundler(6 +
13022                                            (orderByComparator.getOrderByFields().length * 6));
13023                    }
13024                    else {
13025                            query = new StringBundler(3);
13026                    }
13027    
13028                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
13029    
13030                    query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
13031    
13032                    query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
13033    
13034                    if (parentTitle == null) {
13035                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
13036                    }
13037                    else {
13038                            if (parentTitle.equals(StringPool.BLANK)) {
13039                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
13040                            }
13041                            else {
13042                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
13043                            }
13044                    }
13045    
13046                    query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
13047    
13048                    if (orderByComparator != null) {
13049                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13050    
13051                            if (orderByConditionFields.length > 0) {
13052                                    query.append(WHERE_AND);
13053                            }
13054    
13055                            for (int i = 0; i < orderByConditionFields.length; i++) {
13056                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13057                                    query.append(orderByConditionFields[i]);
13058    
13059                                    if ((i + 1) < orderByConditionFields.length) {
13060                                            if (orderByComparator.isAscending() ^ previous) {
13061                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13062                                            }
13063                                            else {
13064                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13065                                            }
13066                                    }
13067                                    else {
13068                                            if (orderByComparator.isAscending() ^ previous) {
13069                                                    query.append(WHERE_GREATER_THAN);
13070                                            }
13071                                            else {
13072                                                    query.append(WHERE_LESSER_THAN);
13073                                            }
13074                                    }
13075                            }
13076    
13077                            query.append(ORDER_BY_CLAUSE);
13078    
13079                            String[] orderByFields = orderByComparator.getOrderByFields();
13080    
13081                            for (int i = 0; i < orderByFields.length; i++) {
13082                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13083                                    query.append(orderByFields[i]);
13084    
13085                                    if ((i + 1) < orderByFields.length) {
13086                                            if (orderByComparator.isAscending() ^ previous) {
13087                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13088                                            }
13089                                            else {
13090                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13091                                            }
13092                                    }
13093                                    else {
13094                                            if (orderByComparator.isAscending() ^ previous) {
13095                                                    query.append(ORDER_BY_ASC);
13096                                            }
13097                                            else {
13098                                                    query.append(ORDER_BY_DESC);
13099                                            }
13100                                    }
13101                            }
13102                    }
13103    
13104                    else {
13105                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13106                    }
13107    
13108                    String sql = query.toString();
13109    
13110                    Query q = session.createQuery(sql);
13111    
13112                    q.setFirstResult(0);
13113                    q.setMaxResults(2);
13114    
13115                    QueryPos qPos = QueryPos.getInstance(q);
13116    
13117                    qPos.add(nodeId);
13118    
13119                    qPos.add(head);
13120    
13121                    if (parentTitle != null) {
13122                            qPos.add(parentTitle);
13123                    }
13124    
13125                    qPos.add(status);
13126    
13127                    if (orderByComparator != null) {
13128                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
13129    
13130                            for (Object value : values) {
13131                                    qPos.add(value);
13132                            }
13133                    }
13134    
13135                    List<WikiPage> list = q.list();
13136    
13137                    if (list.size() == 2) {
13138                            return list.get(1);
13139                    }
13140                    else {
13141                            return null;
13142                    }
13143            }
13144    
13145            /**
13146             * Returns all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13147             *
13148             * @param groupId the group ID
13149             * @param nodeId the node ID
13150             * @param head the head
13151             * @param parentTitle the parent title
13152             * @param status the status
13153             * @return the matching wiki pages
13154             * @throws SystemException if a system exception occurred
13155             */
13156            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
13157                    boolean head, String parentTitle, int status) throws SystemException {
13158                    return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
13159                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13160            }
13161    
13162            /**
13163             * Returns a range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13164             *
13165             * <p>
13166             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13167             * </p>
13168             *
13169             * @param groupId the group ID
13170             * @param nodeId the node ID
13171             * @param head the head
13172             * @param parentTitle the parent title
13173             * @param status the status
13174             * @param start the lower bound of the range of wiki pages
13175             * @param end the upper bound of the range of wiki pages (not inclusive)
13176             * @return the range of matching wiki pages
13177             * @throws SystemException if a system exception occurred
13178             */
13179            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
13180                    boolean head, String parentTitle, int status, int start, int end)
13181                    throws SystemException {
13182                    return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
13183                            start, end, null);
13184            }
13185    
13186            /**
13187             * Returns an ordered range of all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13188             *
13189             * <p>
13190             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13191             * </p>
13192             *
13193             * @param groupId the group ID
13194             * @param nodeId the node ID
13195             * @param head the head
13196             * @param parentTitle the parent title
13197             * @param status the status
13198             * @param start the lower bound of the range of wiki pages
13199             * @param end the upper bound of the range of wiki pages (not inclusive)
13200             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13201             * @return the ordered range of matching wiki pages
13202             * @throws SystemException if a system exception occurred
13203             */
13204            public List<WikiPage> findByG_N_H_P_S(long groupId, long nodeId,
13205                    boolean head, String parentTitle, int status, int start, int end,
13206                    OrderByComparator orderByComparator) throws SystemException {
13207                    FinderPath finderPath = null;
13208                    Object[] finderArgs = null;
13209    
13210                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13211                                    (orderByComparator == null)) {
13212                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_H_P_S;
13213                            finderArgs = new Object[] { groupId, nodeId, head, parentTitle, status };
13214                    }
13215                    else {
13216                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_H_P_S;
13217                            finderArgs = new Object[] {
13218                                            groupId, nodeId, head, parentTitle, status,
13219                                            
13220                                            start, end, orderByComparator
13221                                    };
13222                    }
13223    
13224                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
13225                                    finderArgs, this);
13226    
13227                    if ((list != null) && !list.isEmpty()) {
13228                            for (WikiPage wikiPage : list) {
13229                                    if ((groupId != wikiPage.getGroupId()) ||
13230                                                    (nodeId != wikiPage.getNodeId()) ||
13231                                                    (head != wikiPage.getHead()) ||
13232                                                    !Validator.equals(parentTitle, wikiPage.getParentTitle()) ||
13233                                                    (status != wikiPage.getStatus())) {
13234                                            list = null;
13235    
13236                                            break;
13237                                    }
13238                            }
13239                    }
13240    
13241                    if (list == null) {
13242                            StringBundler query = null;
13243    
13244                            if (orderByComparator != null) {
13245                                    query = new StringBundler(7 +
13246                                                    (orderByComparator.getOrderByFields().length * 3));
13247                            }
13248                            else {
13249                                    query = new StringBundler(7);
13250                            }
13251    
13252                            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
13253    
13254                            query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
13255    
13256                            query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
13257    
13258                            query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
13259    
13260                            if (parentTitle == null) {
13261                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
13262                            }
13263                            else {
13264                                    if (parentTitle.equals(StringPool.BLANK)) {
13265                                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
13266                                    }
13267                                    else {
13268                                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
13269                                    }
13270                            }
13271    
13272                            query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
13273    
13274                            if (orderByComparator != null) {
13275                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13276                                            orderByComparator);
13277                            }
13278    
13279                            else {
13280                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13281                            }
13282    
13283                            String sql = query.toString();
13284    
13285                            Session session = null;
13286    
13287                            try {
13288                                    session = openSession();
13289    
13290                                    Query q = session.createQuery(sql);
13291    
13292                                    QueryPos qPos = QueryPos.getInstance(q);
13293    
13294                                    qPos.add(groupId);
13295    
13296                                    qPos.add(nodeId);
13297    
13298                                    qPos.add(head);
13299    
13300                                    if (parentTitle != null) {
13301                                            qPos.add(parentTitle);
13302                                    }
13303    
13304                                    qPos.add(status);
13305    
13306                                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
13307                                                    end);
13308                            }
13309                            catch (Exception e) {
13310                                    throw processException(e);
13311                            }
13312                            finally {
13313                                    if (list == null) {
13314                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13315                                    }
13316                                    else {
13317                                            cacheResult(list);
13318    
13319                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13320                                    }
13321    
13322                                    closeSession(session);
13323                            }
13324                    }
13325    
13326                    return list;
13327            }
13328    
13329            /**
13330             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13331             *
13332             * @param groupId the group ID
13333             * @param nodeId the node ID
13334             * @param head the head
13335             * @param parentTitle the parent title
13336             * @param status the status
13337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13338             * @return the first matching wiki page
13339             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
13340             * @throws SystemException if a system exception occurred
13341             */
13342            public WikiPage findByG_N_H_P_S_First(long groupId, long nodeId,
13343                    boolean head, String parentTitle, int status,
13344                    OrderByComparator orderByComparator)
13345                    throws NoSuchPageException, SystemException {
13346                    WikiPage wikiPage = fetchByG_N_H_P_S_First(groupId, nodeId, head,
13347                                    parentTitle, status, orderByComparator);
13348    
13349                    if (wikiPage != null) {
13350                            return wikiPage;
13351                    }
13352    
13353                    StringBundler msg = new StringBundler(12);
13354    
13355                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13356    
13357                    msg.append("groupId=");
13358                    msg.append(groupId);
13359    
13360                    msg.append(", nodeId=");
13361                    msg.append(nodeId);
13362    
13363                    msg.append(", head=");
13364                    msg.append(head);
13365    
13366                    msg.append(", parentTitle=");
13367                    msg.append(parentTitle);
13368    
13369                    msg.append(", status=");
13370                    msg.append(status);
13371    
13372                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13373    
13374                    throw new NoSuchPageException(msg.toString());
13375            }
13376    
13377            /**
13378             * Returns the first wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13379             *
13380             * @param groupId the group ID
13381             * @param nodeId the node ID
13382             * @param head the head
13383             * @param parentTitle the parent title
13384             * @param status the status
13385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13386             * @return the first matching wiki page, or <code>null</code> if a matching wiki page could not be found
13387             * @throws SystemException if a system exception occurred
13388             */
13389            public WikiPage fetchByG_N_H_P_S_First(long groupId, long nodeId,
13390                    boolean head, String parentTitle, int status,
13391                    OrderByComparator orderByComparator) throws SystemException {
13392                    List<WikiPage> list = findByG_N_H_P_S(groupId, nodeId, head,
13393                                    parentTitle, status, 0, 1, orderByComparator);
13394    
13395                    if (!list.isEmpty()) {
13396                            return list.get(0);
13397                    }
13398    
13399                    return null;
13400            }
13401    
13402            /**
13403             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13404             *
13405             * @param groupId the group ID
13406             * @param nodeId the node ID
13407             * @param head the head
13408             * @param parentTitle the parent title
13409             * @param status the status
13410             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13411             * @return the last matching wiki page
13412             * @throws com.liferay.portlet.wiki.NoSuchPageException if a matching wiki page could not be found
13413             * @throws SystemException if a system exception occurred
13414             */
13415            public WikiPage findByG_N_H_P_S_Last(long groupId, long nodeId,
13416                    boolean head, String parentTitle, int status,
13417                    OrderByComparator orderByComparator)
13418                    throws NoSuchPageException, SystemException {
13419                    WikiPage wikiPage = fetchByG_N_H_P_S_Last(groupId, nodeId, head,
13420                                    parentTitle, status, orderByComparator);
13421    
13422                    if (wikiPage != null) {
13423                            return wikiPage;
13424                    }
13425    
13426                    StringBundler msg = new StringBundler(12);
13427    
13428                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13429    
13430                    msg.append("groupId=");
13431                    msg.append(groupId);
13432    
13433                    msg.append(", nodeId=");
13434                    msg.append(nodeId);
13435    
13436                    msg.append(", head=");
13437                    msg.append(head);
13438    
13439                    msg.append(", parentTitle=");
13440                    msg.append(parentTitle);
13441    
13442                    msg.append(", status=");
13443                    msg.append(status);
13444    
13445                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13446    
13447                    throw new NoSuchPageException(msg.toString());
13448            }
13449    
13450            /**
13451             * Returns the last wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13452             *
13453             * @param groupId the group ID
13454             * @param nodeId the node ID
13455             * @param head the head
13456             * @param parentTitle the parent title
13457             * @param status the status
13458             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13459             * @return the last matching wiki page, or <code>null</code> if a matching wiki page could not be found
13460             * @throws SystemException if a system exception occurred
13461             */
13462            public WikiPage fetchByG_N_H_P_S_Last(long groupId, long nodeId,
13463                    boolean head, String parentTitle, int status,
13464                    OrderByComparator orderByComparator) throws SystemException {
13465                    int count = countByG_N_H_P_S(groupId, nodeId, head, parentTitle, status);
13466    
13467                    List<WikiPage> list = findByG_N_H_P_S(groupId, nodeId, head,
13468                                    parentTitle, status, count - 1, count, orderByComparator);
13469    
13470                    if (!list.isEmpty()) {
13471                            return list.get(0);
13472                    }
13473    
13474                    return null;
13475            }
13476    
13477            /**
13478             * Returns the wiki pages before and after the current wiki page in the ordered set where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13479             *
13480             * @param pageId the primary key of the current wiki page
13481             * @param groupId the group ID
13482             * @param nodeId the node ID
13483             * @param head the head
13484             * @param parentTitle the parent title
13485             * @param status the status
13486             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13487             * @return the previous, current, and next wiki page
13488             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
13489             * @throws SystemException if a system exception occurred
13490             */
13491            public WikiPage[] findByG_N_H_P_S_PrevAndNext(long pageId, long groupId,
13492                    long nodeId, boolean head, String parentTitle, int status,
13493                    OrderByComparator orderByComparator)
13494                    throws NoSuchPageException, SystemException {
13495                    WikiPage wikiPage = findByPrimaryKey(pageId);
13496    
13497                    Session session = null;
13498    
13499                    try {
13500                            session = openSession();
13501    
13502                            WikiPage[] array = new WikiPageImpl[3];
13503    
13504                            array[0] = getByG_N_H_P_S_PrevAndNext(session, wikiPage, groupId,
13505                                            nodeId, head, parentTitle, status, orderByComparator, true);
13506    
13507                            array[1] = wikiPage;
13508    
13509                            array[2] = getByG_N_H_P_S_PrevAndNext(session, wikiPage, groupId,
13510                                            nodeId, head, parentTitle, status, orderByComparator, false);
13511    
13512                            return array;
13513                    }
13514                    catch (Exception e) {
13515                            throw processException(e);
13516                    }
13517                    finally {
13518                            closeSession(session);
13519                    }
13520            }
13521    
13522            protected WikiPage getByG_N_H_P_S_PrevAndNext(Session session,
13523                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
13524                    String parentTitle, int status, OrderByComparator orderByComparator,
13525                    boolean previous) {
13526                    StringBundler query = null;
13527    
13528                    if (orderByComparator != null) {
13529                            query = new StringBundler(6 +
13530                                            (orderByComparator.getOrderByFields().length * 6));
13531                    }
13532                    else {
13533                            query = new StringBundler(3);
13534                    }
13535    
13536                    query.append(_SQL_SELECT_WIKIPAGE_WHERE);
13537    
13538                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
13539    
13540                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
13541    
13542                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
13543    
13544                    if (parentTitle == null) {
13545                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
13546                    }
13547                    else {
13548                            if (parentTitle.equals(StringPool.BLANK)) {
13549                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
13550                            }
13551                            else {
13552                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
13553                            }
13554                    }
13555    
13556                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
13557    
13558                    if (orderByComparator != null) {
13559                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13560    
13561                            if (orderByConditionFields.length > 0) {
13562                                    query.append(WHERE_AND);
13563                            }
13564    
13565                            for (int i = 0; i < orderByConditionFields.length; i++) {
13566                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13567                                    query.append(orderByConditionFields[i]);
13568    
13569                                    if ((i + 1) < orderByConditionFields.length) {
13570                                            if (orderByComparator.isAscending() ^ previous) {
13571                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13572                                            }
13573                                            else {
13574                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13575                                            }
13576                                    }
13577                                    else {
13578                                            if (orderByComparator.isAscending() ^ previous) {
13579                                                    query.append(WHERE_GREATER_THAN);
13580                                            }
13581                                            else {
13582                                                    query.append(WHERE_LESSER_THAN);
13583                                            }
13584                                    }
13585                            }
13586    
13587                            query.append(ORDER_BY_CLAUSE);
13588    
13589                            String[] orderByFields = orderByComparator.getOrderByFields();
13590    
13591                            for (int i = 0; i < orderByFields.length; i++) {
13592                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13593                                    query.append(orderByFields[i]);
13594    
13595                                    if ((i + 1) < orderByFields.length) {
13596                                            if (orderByComparator.isAscending() ^ previous) {
13597                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13598                                            }
13599                                            else {
13600                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13601                                            }
13602                                    }
13603                                    else {
13604                                            if (orderByComparator.isAscending() ^ previous) {
13605                                                    query.append(ORDER_BY_ASC);
13606                                            }
13607                                            else {
13608                                                    query.append(ORDER_BY_DESC);
13609                                            }
13610                                    }
13611                            }
13612                    }
13613    
13614                    else {
13615                            query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13616                    }
13617    
13618                    String sql = query.toString();
13619    
13620                    Query q = session.createQuery(sql);
13621    
13622                    q.setFirstResult(0);
13623                    q.setMaxResults(2);
13624    
13625                    QueryPos qPos = QueryPos.getInstance(q);
13626    
13627                    qPos.add(groupId);
13628    
13629                    qPos.add(nodeId);
13630    
13631                    qPos.add(head);
13632    
13633                    if (parentTitle != null) {
13634                            qPos.add(parentTitle);
13635                    }
13636    
13637                    qPos.add(status);
13638    
13639                    if (orderByComparator != null) {
13640                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
13641    
13642                            for (Object value : values) {
13643                                    qPos.add(value);
13644                            }
13645                    }
13646    
13647                    List<WikiPage> list = q.list();
13648    
13649                    if (list.size() == 2) {
13650                            return list.get(1);
13651                    }
13652                    else {
13653                            return null;
13654                    }
13655            }
13656    
13657            /**
13658             * Returns all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13659             *
13660             * @param groupId the group ID
13661             * @param nodeId the node ID
13662             * @param head the head
13663             * @param parentTitle the parent title
13664             * @param status the status
13665             * @return the matching wiki pages that the user has permission to view
13666             * @throws SystemException if a system exception occurred
13667             */
13668            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
13669                    boolean head, String parentTitle, int status) throws SystemException {
13670                    return filterFindByG_N_H_P_S(groupId, nodeId, head, parentTitle,
13671                            status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13672            }
13673    
13674            /**
13675             * Returns a range of all the wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13676             *
13677             * <p>
13678             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13679             * </p>
13680             *
13681             * @param groupId the group ID
13682             * @param nodeId the node ID
13683             * @param head the head
13684             * @param parentTitle the parent title
13685             * @param status the status
13686             * @param start the lower bound of the range of wiki pages
13687             * @param end the upper bound of the range of wiki pages (not inclusive)
13688             * @return the range of matching wiki pages that the user has permission to view
13689             * @throws SystemException if a system exception occurred
13690             */
13691            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
13692                    boolean head, String parentTitle, int status, int start, int end)
13693                    throws SystemException {
13694                    return filterFindByG_N_H_P_S(groupId, nodeId, head, parentTitle,
13695                            status, start, end, null);
13696            }
13697    
13698            /**
13699             * Returns an ordered range of all the wiki pages that the user has permissions to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13700             *
13701             * <p>
13702             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13703             * </p>
13704             *
13705             * @param groupId the group ID
13706             * @param nodeId the node ID
13707             * @param head the head
13708             * @param parentTitle the parent title
13709             * @param status the status
13710             * @param start the lower bound of the range of wiki pages
13711             * @param end the upper bound of the range of wiki pages (not inclusive)
13712             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13713             * @return the ordered range of matching wiki pages that the user has permission to view
13714             * @throws SystemException if a system exception occurred
13715             */
13716            public List<WikiPage> filterFindByG_N_H_P_S(long groupId, long nodeId,
13717                    boolean head, String parentTitle, int status, int start, int end,
13718                    OrderByComparator orderByComparator) throws SystemException {
13719                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13720                            return findByG_N_H_P_S(groupId, nodeId, head, parentTitle, status,
13721                                    start, end, orderByComparator);
13722                    }
13723    
13724                    StringBundler query = null;
13725    
13726                    if (orderByComparator != null) {
13727                            query = new StringBundler(7 +
13728                                            (orderByComparator.getOrderByFields().length * 3));
13729                    }
13730                    else {
13731                            query = new StringBundler(7);
13732                    }
13733    
13734                    if (getDB().isSupportsInlineDistinct()) {
13735                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
13736                    }
13737                    else {
13738                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
13739                    }
13740    
13741                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
13742    
13743                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
13744    
13745                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
13746    
13747                    if (parentTitle == null) {
13748                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
13749                    }
13750                    else {
13751                            if (parentTitle.equals(StringPool.BLANK)) {
13752                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
13753                            }
13754                            else {
13755                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
13756                            }
13757                    }
13758    
13759                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
13760    
13761                    if (!getDB().isSupportsInlineDistinct()) {
13762                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
13763                    }
13764    
13765                    if (orderByComparator != null) {
13766                            if (getDB().isSupportsInlineDistinct()) {
13767                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13768                                            orderByComparator);
13769                            }
13770                            else {
13771                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13772                                            orderByComparator);
13773                            }
13774                    }
13775    
13776                    else {
13777                            if (getDB().isSupportsInlineDistinct()) {
13778                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13779                            }
13780                            else {
13781                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
13782                            }
13783                    }
13784    
13785                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13786                                    WikiPage.class.getName(),
13787                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13788    
13789                    Session session = null;
13790    
13791                    try {
13792                            session = openSession();
13793    
13794                            SQLQuery q = session.createSQLQuery(sql);
13795    
13796                            if (getDB().isSupportsInlineDistinct()) {
13797                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
13798                            }
13799                            else {
13800                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
13801                            }
13802    
13803                            QueryPos qPos = QueryPos.getInstance(q);
13804    
13805                            qPos.add(groupId);
13806    
13807                            qPos.add(nodeId);
13808    
13809                            qPos.add(head);
13810    
13811                            if (parentTitle != null) {
13812                                    qPos.add(parentTitle);
13813                            }
13814    
13815                            qPos.add(status);
13816    
13817                            return (List<WikiPage>)QueryUtil.list(q, getDialect(), start, end);
13818                    }
13819                    catch (Exception e) {
13820                            throw processException(e);
13821                    }
13822                    finally {
13823                            closeSession(session);
13824                    }
13825            }
13826    
13827            /**
13828             * Returns the wiki pages before and after the current wiki page in the ordered set of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
13829             *
13830             * @param pageId the primary key of the current wiki page
13831             * @param groupId the group ID
13832             * @param nodeId the node ID
13833             * @param head the head
13834             * @param parentTitle the parent title
13835             * @param status the status
13836             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13837             * @return the previous, current, and next wiki page
13838             * @throws com.liferay.portlet.wiki.NoSuchPageException if a wiki page with the primary key could not be found
13839             * @throws SystemException if a system exception occurred
13840             */
13841            public WikiPage[] filterFindByG_N_H_P_S_PrevAndNext(long pageId,
13842                    long groupId, long nodeId, boolean head, String parentTitle,
13843                    int status, OrderByComparator orderByComparator)
13844                    throws NoSuchPageException, SystemException {
13845                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13846                            return findByG_N_H_P_S_PrevAndNext(pageId, groupId, nodeId, head,
13847                                    parentTitle, status, orderByComparator);
13848                    }
13849    
13850                    WikiPage wikiPage = findByPrimaryKey(pageId);
13851    
13852                    Session session = null;
13853    
13854                    try {
13855                            session = openSession();
13856    
13857                            WikiPage[] array = new WikiPageImpl[3];
13858    
13859                            array[0] = filterGetByG_N_H_P_S_PrevAndNext(session, wikiPage,
13860                                            groupId, nodeId, head, parentTitle, status,
13861                                            orderByComparator, true);
13862    
13863                            array[1] = wikiPage;
13864    
13865                            array[2] = filterGetByG_N_H_P_S_PrevAndNext(session, wikiPage,
13866                                            groupId, nodeId, head, parentTitle, status,
13867                                            orderByComparator, false);
13868    
13869                            return array;
13870                    }
13871                    catch (Exception e) {
13872                            throw processException(e);
13873                    }
13874                    finally {
13875                            closeSession(session);
13876                    }
13877            }
13878    
13879            protected WikiPage filterGetByG_N_H_P_S_PrevAndNext(Session session,
13880                    WikiPage wikiPage, long groupId, long nodeId, boolean head,
13881                    String parentTitle, int status, OrderByComparator orderByComparator,
13882                    boolean previous) {
13883                    StringBundler query = null;
13884    
13885                    if (orderByComparator != null) {
13886                            query = new StringBundler(6 +
13887                                            (orderByComparator.getOrderByFields().length * 6));
13888                    }
13889                    else {
13890                            query = new StringBundler(3);
13891                    }
13892    
13893                    if (getDB().isSupportsInlineDistinct()) {
13894                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_WHERE);
13895                    }
13896                    else {
13897                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1);
13898                    }
13899    
13900                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
13901    
13902                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
13903    
13904                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
13905    
13906                    if (parentTitle == null) {
13907                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
13908                    }
13909                    else {
13910                            if (parentTitle.equals(StringPool.BLANK)) {
13911                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
13912                            }
13913                            else {
13914                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
13915                            }
13916                    }
13917    
13918                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
13919    
13920                    if (!getDB().isSupportsInlineDistinct()) {
13921                            query.append(_FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2);
13922                    }
13923    
13924                    if (orderByComparator != null) {
13925                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13926    
13927                            if (orderByConditionFields.length > 0) {
13928                                    query.append(WHERE_AND);
13929                            }
13930    
13931                            for (int i = 0; i < orderByConditionFields.length; i++) {
13932                                    if (getDB().isSupportsInlineDistinct()) {
13933                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13934                                    }
13935                                    else {
13936                                            query.append(_ORDER_BY_ENTITY_TABLE);
13937                                    }
13938    
13939                                    query.append(orderByConditionFields[i]);
13940    
13941                                    if ((i + 1) < orderByConditionFields.length) {
13942                                            if (orderByComparator.isAscending() ^ previous) {
13943                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13944                                            }
13945                                            else {
13946                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13947                                            }
13948                                    }
13949                                    else {
13950                                            if (orderByComparator.isAscending() ^ previous) {
13951                                                    query.append(WHERE_GREATER_THAN);
13952                                            }
13953                                            else {
13954                                                    query.append(WHERE_LESSER_THAN);
13955                                            }
13956                                    }
13957                            }
13958    
13959                            query.append(ORDER_BY_CLAUSE);
13960    
13961                            String[] orderByFields = orderByComparator.getOrderByFields();
13962    
13963                            for (int i = 0; i < orderByFields.length; i++) {
13964                                    if (getDB().isSupportsInlineDistinct()) {
13965                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13966                                    }
13967                                    else {
13968                                            query.append(_ORDER_BY_ENTITY_TABLE);
13969                                    }
13970    
13971                                    query.append(orderByFields[i]);
13972    
13973                                    if ((i + 1) < orderByFields.length) {
13974                                            if (orderByComparator.isAscending() ^ previous) {
13975                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13976                                            }
13977                                            else {
13978                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13979                                            }
13980                                    }
13981                                    else {
13982                                            if (orderByComparator.isAscending() ^ previous) {
13983                                                    query.append(ORDER_BY_ASC);
13984                                            }
13985                                            else {
13986                                                    query.append(ORDER_BY_DESC);
13987                                            }
13988                                    }
13989                            }
13990                    }
13991    
13992                    else {
13993                            if (getDB().isSupportsInlineDistinct()) {
13994                                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
13995                            }
13996                            else {
13997                                    query.append(WikiPageModelImpl.ORDER_BY_SQL);
13998                            }
13999                    }
14000    
14001                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14002                                    WikiPage.class.getName(),
14003                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14004    
14005                    SQLQuery q = session.createSQLQuery(sql);
14006    
14007                    q.setFirstResult(0);
14008                    q.setMaxResults(2);
14009    
14010                    if (getDB().isSupportsInlineDistinct()) {
14011                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiPageImpl.class);
14012                    }
14013                    else {
14014                            q.addEntity(_FILTER_ENTITY_TABLE, WikiPageImpl.class);
14015                    }
14016    
14017                    QueryPos qPos = QueryPos.getInstance(q);
14018    
14019                    qPos.add(groupId);
14020    
14021                    qPos.add(nodeId);
14022    
14023                    qPos.add(head);
14024    
14025                    if (parentTitle != null) {
14026                            qPos.add(parentTitle);
14027                    }
14028    
14029                    qPos.add(status);
14030    
14031                    if (orderByComparator != null) {
14032                            Object[] values = orderByComparator.getOrderByConditionValues(wikiPage);
14033    
14034                            for (Object value : values) {
14035                                    qPos.add(value);
14036                            }
14037                    }
14038    
14039                    List<WikiPage> list = q.list();
14040    
14041                    if (list.size() == 2) {
14042                            return list.get(1);
14043                    }
14044                    else {
14045                            return null;
14046                    }
14047            }
14048    
14049            /**
14050             * Returns all the wiki pages.
14051             *
14052             * @return the wiki pages
14053             * @throws SystemException if a system exception occurred
14054             */
14055            public List<WikiPage> findAll() throws SystemException {
14056                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14057            }
14058    
14059            /**
14060             * Returns a range of all the wiki pages.
14061             *
14062             * <p>
14063             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14064             * </p>
14065             *
14066             * @param start the lower bound of the range of wiki pages
14067             * @param end the upper bound of the range of wiki pages (not inclusive)
14068             * @return the range of wiki pages
14069             * @throws SystemException if a system exception occurred
14070             */
14071            public List<WikiPage> findAll(int start, int end) throws SystemException {
14072                    return findAll(start, end, null);
14073            }
14074    
14075            /**
14076             * Returns an ordered range of all the wiki pages.
14077             *
14078             * <p>
14079             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14080             * </p>
14081             *
14082             * @param start the lower bound of the range of wiki pages
14083             * @param end the upper bound of the range of wiki pages (not inclusive)
14084             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14085             * @return the ordered range of wiki pages
14086             * @throws SystemException if a system exception occurred
14087             */
14088            public List<WikiPage> findAll(int start, int end,
14089                    OrderByComparator orderByComparator) throws SystemException {
14090                    FinderPath finderPath = null;
14091                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
14092    
14093                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14094                                    (orderByComparator == null)) {
14095                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
14096                            finderArgs = FINDER_ARGS_EMPTY;
14097                    }
14098                    else {
14099                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
14100                            finderArgs = new Object[] { start, end, orderByComparator };
14101                    }
14102    
14103                    List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(finderPath,
14104                                    finderArgs, this);
14105    
14106                    if (list == null) {
14107                            StringBundler query = null;
14108                            String sql = null;
14109    
14110                            if (orderByComparator != null) {
14111                                    query = new StringBundler(2 +
14112                                                    (orderByComparator.getOrderByFields().length * 3));
14113    
14114                                    query.append(_SQL_SELECT_WIKIPAGE);
14115    
14116                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14117                                            orderByComparator);
14118    
14119                                    sql = query.toString();
14120                            }
14121                            else {
14122                                    sql = _SQL_SELECT_WIKIPAGE.concat(WikiPageModelImpl.ORDER_BY_JPQL);
14123                            }
14124    
14125                            Session session = null;
14126    
14127                            try {
14128                                    session = openSession();
14129    
14130                                    Query q = session.createQuery(sql);
14131    
14132                                    if (orderByComparator == null) {
14133                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
14134                                                            start, end, false);
14135    
14136                                            Collections.sort(list);
14137                                    }
14138                                    else {
14139                                            list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
14140                                                            start, end);
14141                                    }
14142                            }
14143                            catch (Exception e) {
14144                                    throw processException(e);
14145                            }
14146                            finally {
14147                                    if (list == null) {
14148                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14149                                    }
14150                                    else {
14151                                            cacheResult(list);
14152    
14153                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14154                                    }
14155    
14156                                    closeSession(session);
14157                            }
14158                    }
14159    
14160                    return list;
14161            }
14162    
14163            /**
14164             * Removes all the wiki pages where uuid = &#63; from the database.
14165             *
14166             * @param uuid the uuid
14167             * @throws SystemException if a system exception occurred
14168             */
14169            public void removeByUuid(String uuid) throws SystemException {
14170                    for (WikiPage wikiPage : findByUuid(uuid)) {
14171                            remove(wikiPage);
14172                    }
14173            }
14174    
14175            /**
14176             * Removes the wiki page where uuid = &#63; and groupId = &#63; from the database.
14177             *
14178             * @param uuid the uuid
14179             * @param groupId the group ID
14180             * @return the wiki page that was removed
14181             * @throws SystemException if a system exception occurred
14182             */
14183            public WikiPage removeByUUID_G(String uuid, long groupId)
14184                    throws NoSuchPageException, SystemException {
14185                    WikiPage wikiPage = findByUUID_G(uuid, groupId);
14186    
14187                    return remove(wikiPage);
14188            }
14189    
14190            /**
14191             * Removes all the wiki pages where nodeId = &#63; from the database.
14192             *
14193             * @param nodeId the node ID
14194             * @throws SystemException if a system exception occurred
14195             */
14196            public void removeByNodeId(long nodeId) throws SystemException {
14197                    for (WikiPage wikiPage : findByNodeId(nodeId)) {
14198                            remove(wikiPage);
14199                    }
14200            }
14201    
14202            /**
14203             * Removes all the wiki pages where format = &#63; from the database.
14204             *
14205             * @param format the format
14206             * @throws SystemException if a system exception occurred
14207             */
14208            public void removeByFormat(String format) throws SystemException {
14209                    for (WikiPage wikiPage : findByFormat(format)) {
14210                            remove(wikiPage);
14211                    }
14212            }
14213    
14214            /**
14215             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; from the database.
14216             *
14217             * @param resourcePrimKey the resource prim key
14218             * @param nodeId the node ID
14219             * @throws SystemException if a system exception occurred
14220             */
14221            public void removeByR_N(long resourcePrimKey, long nodeId)
14222                    throws SystemException {
14223                    for (WikiPage wikiPage : findByR_N(resourcePrimKey, nodeId)) {
14224                            remove(wikiPage);
14225                    }
14226            }
14227    
14228            /**
14229             * Removes all the wiki pages where nodeId = &#63; and title = &#63; from the database.
14230             *
14231             * @param nodeId the node ID
14232             * @param title the title
14233             * @throws SystemException if a system exception occurred
14234             */
14235            public void removeByN_T(long nodeId, String title)
14236                    throws SystemException {
14237                    for (WikiPage wikiPage : findByN_T(nodeId, title)) {
14238                            remove(wikiPage);
14239                    }
14240            }
14241    
14242            /**
14243             * Removes all the wiki pages where nodeId = &#63; and head = &#63; from the database.
14244             *
14245             * @param nodeId the node ID
14246             * @param head the head
14247             * @throws SystemException if a system exception occurred
14248             */
14249            public void removeByN_H(long nodeId, boolean head)
14250                    throws SystemException {
14251                    for (WikiPage wikiPage : findByN_H(nodeId, head)) {
14252                            remove(wikiPage);
14253                    }
14254            }
14255    
14256            /**
14257             * Removes all the wiki pages where nodeId = &#63; and parentTitle = &#63; from the database.
14258             *
14259             * @param nodeId the node ID
14260             * @param parentTitle the parent title
14261             * @throws SystemException if a system exception occurred
14262             */
14263            public void removeByN_P(long nodeId, String parentTitle)
14264                    throws SystemException {
14265                    for (WikiPage wikiPage : findByN_P(nodeId, parentTitle)) {
14266                            remove(wikiPage);
14267                    }
14268            }
14269    
14270            /**
14271             * Removes all the wiki pages where nodeId = &#63; and redirectTitle = &#63; from the database.
14272             *
14273             * @param nodeId the node ID
14274             * @param redirectTitle the redirect title
14275             * @throws SystemException if a system exception occurred
14276             */
14277            public void removeByN_R(long nodeId, String redirectTitle)
14278                    throws SystemException {
14279                    for (WikiPage wikiPage : findByN_R(nodeId, redirectTitle)) {
14280                            remove(wikiPage);
14281                    }
14282            }
14283    
14284            /**
14285             * Removes all the wiki pages where nodeId = &#63; and status = &#63; from the database.
14286             *
14287             * @param nodeId the node ID
14288             * @param status the status
14289             * @throws SystemException if a system exception occurred
14290             */
14291            public void removeByN_S(long nodeId, int status) throws SystemException {
14292                    for (WikiPage wikiPage : findByN_S(nodeId, status)) {
14293                            remove(wikiPage);
14294                    }
14295            }
14296    
14297            /**
14298             * Removes the wiki page where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63; from the database.
14299             *
14300             * @param resourcePrimKey the resource prim key
14301             * @param nodeId the node ID
14302             * @param version the version
14303             * @return the wiki page that was removed
14304             * @throws SystemException if a system exception occurred
14305             */
14306            public WikiPage removeByR_N_V(long resourcePrimKey, long nodeId,
14307                    double version) throws NoSuchPageException, SystemException {
14308                    WikiPage wikiPage = findByR_N_V(resourcePrimKey, nodeId, version);
14309    
14310                    return remove(wikiPage);
14311            }
14312    
14313            /**
14314             * Removes all the wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63; from the database.
14315             *
14316             * @param resourcePrimKey the resource prim key
14317             * @param nodeId the node ID
14318             * @param status the status
14319             * @throws SystemException if a system exception occurred
14320             */
14321            public void removeByR_N_S(long resourcePrimKey, long nodeId, int status)
14322                    throws SystemException {
14323                    for (WikiPage wikiPage : findByR_N_S(resourcePrimKey, nodeId, status)) {
14324                            remove(wikiPage);
14325                    }
14326            }
14327    
14328            /**
14329             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; from the database.
14330             *
14331             * @param groupId the group ID
14332             * @param nodeId the node ID
14333             * @param head the head
14334             * @throws SystemException if a system exception occurred
14335             */
14336            public void removeByG_N_H(long groupId, long nodeId, boolean head)
14337                    throws SystemException {
14338                    for (WikiPage wikiPage : findByG_N_H(groupId, nodeId, head)) {
14339                            remove(wikiPage);
14340                    }
14341            }
14342    
14343            /**
14344             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63; from the database.
14345             *
14346             * @param groupId the group ID
14347             * @param nodeId the node ID
14348             * @param status the status
14349             * @throws SystemException if a system exception occurred
14350             */
14351            public void removeByG_N_S(long groupId, long nodeId, int status)
14352                    throws SystemException {
14353                    for (WikiPage wikiPage : findByG_N_S(groupId, nodeId, status)) {
14354                            remove(wikiPage);
14355                    }
14356            }
14357    
14358            /**
14359             * Removes all the wiki pages where userId = &#63; and nodeId = &#63; and status = &#63; from the database.
14360             *
14361             * @param userId the user ID
14362             * @param nodeId the node ID
14363             * @param status the status
14364             * @throws SystemException if a system exception occurred
14365             */
14366            public void removeByU_N_S(long userId, long nodeId, int status)
14367                    throws SystemException {
14368                    for (WikiPage wikiPage : findByU_N_S(userId, nodeId, status)) {
14369                            remove(wikiPage);
14370                    }
14371            }
14372    
14373            /**
14374             * Removes the wiki page where nodeId = &#63; and title = &#63; and version = &#63; from the database.
14375             *
14376             * @param nodeId the node ID
14377             * @param title the title
14378             * @param version the version
14379             * @return the wiki page that was removed
14380             * @throws SystemException if a system exception occurred
14381             */
14382            public WikiPage removeByN_T_V(long nodeId, String title, double version)
14383                    throws NoSuchPageException, SystemException {
14384                    WikiPage wikiPage = findByN_T_V(nodeId, title, version);
14385    
14386                    return remove(wikiPage);
14387            }
14388    
14389            /**
14390             * Removes all the wiki pages where nodeId = &#63; and title = &#63; and head = &#63; from the database.
14391             *
14392             * @param nodeId the node ID
14393             * @param title the title
14394             * @param head the head
14395             * @throws SystemException if a system exception occurred
14396             */
14397            public void removeByN_T_H(long nodeId, String title, boolean head)
14398                    throws SystemException {
14399                    for (WikiPage wikiPage : findByN_T_H(nodeId, title, head)) {
14400                            remove(wikiPage);
14401                    }
14402            }
14403    
14404            /**
14405             * Removes all the wiki pages where nodeId = &#63; and title = &#63; and status = &#63; from the database.
14406             *
14407             * @param nodeId the node ID
14408             * @param title the title
14409             * @param status the status
14410             * @throws SystemException if a system exception occurred
14411             */
14412            public void removeByN_T_S(long nodeId, String title, int status)
14413                    throws SystemException {
14414                    for (WikiPage wikiPage : findByN_T_S(nodeId, title, status)) {
14415                            remove(wikiPage);
14416                    }
14417            }
14418    
14419            /**
14420             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; from the database.
14421             *
14422             * @param nodeId the node ID
14423             * @param head the head
14424             * @param parentTitle the parent title
14425             * @throws SystemException if a system exception occurred
14426             */
14427            public void removeByN_H_P(long nodeId, boolean head, String parentTitle)
14428                    throws SystemException {
14429                    for (WikiPage wikiPage : findByN_H_P(nodeId, head, parentTitle)) {
14430                            remove(wikiPage);
14431                    }
14432            }
14433    
14434            /**
14435             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and status = &#63; from the database.
14436             *
14437             * @param nodeId the node ID
14438             * @param head the head
14439             * @param status the status
14440             * @throws SystemException if a system exception occurred
14441             */
14442            public void removeByN_H_S(long nodeId, boolean head, int status)
14443                    throws SystemException {
14444                    for (WikiPage wikiPage : findByN_H_S(nodeId, head, status)) {
14445                            remove(wikiPage);
14446                    }
14447            }
14448    
14449            /**
14450             * Removes all the wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63; from the database.
14451             *
14452             * @param groupId the group ID
14453             * @param userId the user ID
14454             * @param nodeId the node ID
14455             * @param status the status
14456             * @throws SystemException if a system exception occurred
14457             */
14458            public void removeByG_U_N_S(long groupId, long userId, long nodeId,
14459                    int status) throws SystemException {
14460                    for (WikiPage wikiPage : findByG_U_N_S(groupId, userId, nodeId, status)) {
14461                            remove(wikiPage);
14462                    }
14463            }
14464    
14465            /**
14466             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63; from the database.
14467             *
14468             * @param groupId the group ID
14469             * @param nodeId the node ID
14470             * @param title the title
14471             * @param head the head
14472             * @throws SystemException if a system exception occurred
14473             */
14474            public void removeByG_N_T_H(long groupId, long nodeId, String title,
14475                    boolean head) throws SystemException {
14476                    for (WikiPage wikiPage : findByG_N_T_H(groupId, nodeId, title, head)) {
14477                            remove(wikiPage);
14478                    }
14479            }
14480    
14481            /**
14482             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63; from the database.
14483             *
14484             * @param groupId the group ID
14485             * @param nodeId the node ID
14486             * @param head the head
14487             * @param status the status
14488             * @throws SystemException if a system exception occurred
14489             */
14490            public void removeByG_N_H_S(long groupId, long nodeId, boolean head,
14491                    int status) throws SystemException {
14492                    for (WikiPage wikiPage : findByG_N_H_S(groupId, nodeId, head, status)) {
14493                            remove(wikiPage);
14494                    }
14495            }
14496    
14497            /**
14498             * Removes all the wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63; from the database.
14499             *
14500             * @param nodeId the node ID
14501             * @param head the head
14502             * @param parentTitle the parent title
14503             * @param status the status
14504             * @throws SystemException if a system exception occurred
14505             */
14506            public void removeByN_H_P_S(long nodeId, boolean head, String parentTitle,
14507                    int status) throws SystemException {
14508                    for (WikiPage wikiPage : findByN_H_P_S(nodeId, head, parentTitle, status)) {
14509                            remove(wikiPage);
14510                    }
14511            }
14512    
14513            /**
14514             * Removes all the wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63; from the database.
14515             *
14516             * @param groupId the group ID
14517             * @param nodeId the node ID
14518             * @param head the head
14519             * @param parentTitle the parent title
14520             * @param status the status
14521             * @throws SystemException if a system exception occurred
14522             */
14523            public void removeByG_N_H_P_S(long groupId, long nodeId, boolean head,
14524                    String parentTitle, int status) throws SystemException {
14525                    for (WikiPage wikiPage : findByG_N_H_P_S(groupId, nodeId, head,
14526                                    parentTitle, status)) {
14527                            remove(wikiPage);
14528                    }
14529            }
14530    
14531            /**
14532             * Removes all the wiki pages from the database.
14533             *
14534             * @throws SystemException if a system exception occurred
14535             */
14536            public void removeAll() throws SystemException {
14537                    for (WikiPage wikiPage : findAll()) {
14538                            remove(wikiPage);
14539                    }
14540            }
14541    
14542            /**
14543             * Returns the number of wiki pages where uuid = &#63;.
14544             *
14545             * @param uuid the uuid
14546             * @return the number of matching wiki pages
14547             * @throws SystemException if a system exception occurred
14548             */
14549            public int countByUuid(String uuid) throws SystemException {
14550                    Object[] finderArgs = new Object[] { uuid };
14551    
14552                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
14553                                    finderArgs, this);
14554    
14555                    if (count == null) {
14556                            StringBundler query = new StringBundler(2);
14557    
14558                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14559    
14560                            if (uuid == null) {
14561                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
14562                            }
14563                            else {
14564                                    if (uuid.equals(StringPool.BLANK)) {
14565                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
14566                                    }
14567                                    else {
14568                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
14569                                    }
14570                            }
14571    
14572                            String sql = query.toString();
14573    
14574                            Session session = null;
14575    
14576                            try {
14577                                    session = openSession();
14578    
14579                                    Query q = session.createQuery(sql);
14580    
14581                                    QueryPos qPos = QueryPos.getInstance(q);
14582    
14583                                    if (uuid != null) {
14584                                            qPos.add(uuid);
14585                                    }
14586    
14587                                    count = (Long)q.uniqueResult();
14588                            }
14589                            catch (Exception e) {
14590                                    throw processException(e);
14591                            }
14592                            finally {
14593                                    if (count == null) {
14594                                            count = Long.valueOf(0);
14595                                    }
14596    
14597                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
14598                                            finderArgs, count);
14599    
14600                                    closeSession(session);
14601                            }
14602                    }
14603    
14604                    return count.intValue();
14605            }
14606    
14607            /**
14608             * Returns the number of wiki pages where uuid = &#63; and groupId = &#63;.
14609             *
14610             * @param uuid the uuid
14611             * @param groupId the group ID
14612             * @return the number of matching wiki pages
14613             * @throws SystemException if a system exception occurred
14614             */
14615            public int countByUUID_G(String uuid, long groupId)
14616                    throws SystemException {
14617                    Object[] finderArgs = new Object[] { uuid, groupId };
14618    
14619                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
14620                                    finderArgs, this);
14621    
14622                    if (count == null) {
14623                            StringBundler query = new StringBundler(3);
14624    
14625                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14626    
14627                            if (uuid == null) {
14628                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
14629                            }
14630                            else {
14631                                    if (uuid.equals(StringPool.BLANK)) {
14632                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
14633                                    }
14634                                    else {
14635                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
14636                                    }
14637                            }
14638    
14639                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
14640    
14641                            String sql = query.toString();
14642    
14643                            Session session = null;
14644    
14645                            try {
14646                                    session = openSession();
14647    
14648                                    Query q = session.createQuery(sql);
14649    
14650                                    QueryPos qPos = QueryPos.getInstance(q);
14651    
14652                                    if (uuid != null) {
14653                                            qPos.add(uuid);
14654                                    }
14655    
14656                                    qPos.add(groupId);
14657    
14658                                    count = (Long)q.uniqueResult();
14659                            }
14660                            catch (Exception e) {
14661                                    throw processException(e);
14662                            }
14663                            finally {
14664                                    if (count == null) {
14665                                            count = Long.valueOf(0);
14666                                    }
14667    
14668                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
14669                                            finderArgs, count);
14670    
14671                                    closeSession(session);
14672                            }
14673                    }
14674    
14675                    return count.intValue();
14676            }
14677    
14678            /**
14679             * Returns the number of wiki pages where nodeId = &#63;.
14680             *
14681             * @param nodeId the node ID
14682             * @return the number of matching wiki pages
14683             * @throws SystemException if a system exception occurred
14684             */
14685            public int countByNodeId(long nodeId) throws SystemException {
14686                    Object[] finderArgs = new Object[] { nodeId };
14687    
14688                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NODEID,
14689                                    finderArgs, this);
14690    
14691                    if (count == null) {
14692                            StringBundler query = new StringBundler(2);
14693    
14694                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14695    
14696                            query.append(_FINDER_COLUMN_NODEID_NODEID_2);
14697    
14698                            String sql = query.toString();
14699    
14700                            Session session = null;
14701    
14702                            try {
14703                                    session = openSession();
14704    
14705                                    Query q = session.createQuery(sql);
14706    
14707                                    QueryPos qPos = QueryPos.getInstance(q);
14708    
14709                                    qPos.add(nodeId);
14710    
14711                                    count = (Long)q.uniqueResult();
14712                            }
14713                            catch (Exception e) {
14714                                    throw processException(e);
14715                            }
14716                            finally {
14717                                    if (count == null) {
14718                                            count = Long.valueOf(0);
14719                                    }
14720    
14721                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NODEID,
14722                                            finderArgs, count);
14723    
14724                                    closeSession(session);
14725                            }
14726                    }
14727    
14728                    return count.intValue();
14729            }
14730    
14731            /**
14732             * Returns the number of wiki pages where format = &#63;.
14733             *
14734             * @param format the format
14735             * @return the number of matching wiki pages
14736             * @throws SystemException if a system exception occurred
14737             */
14738            public int countByFormat(String format) throws SystemException {
14739                    Object[] finderArgs = new Object[] { format };
14740    
14741                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FORMAT,
14742                                    finderArgs, this);
14743    
14744                    if (count == null) {
14745                            StringBundler query = new StringBundler(2);
14746    
14747                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14748    
14749                            if (format == null) {
14750                                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
14751                            }
14752                            else {
14753                                    if (format.equals(StringPool.BLANK)) {
14754                                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
14755                                    }
14756                                    else {
14757                                            query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
14758                                    }
14759                            }
14760    
14761                            String sql = query.toString();
14762    
14763                            Session session = null;
14764    
14765                            try {
14766                                    session = openSession();
14767    
14768                                    Query q = session.createQuery(sql);
14769    
14770                                    QueryPos qPos = QueryPos.getInstance(q);
14771    
14772                                    if (format != null) {
14773                                            qPos.add(format);
14774                                    }
14775    
14776                                    count = (Long)q.uniqueResult();
14777                            }
14778                            catch (Exception e) {
14779                                    throw processException(e);
14780                            }
14781                            finally {
14782                                    if (count == null) {
14783                                            count = Long.valueOf(0);
14784                                    }
14785    
14786                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FORMAT,
14787                                            finderArgs, count);
14788    
14789                                    closeSession(session);
14790                            }
14791                    }
14792    
14793                    return count.intValue();
14794            }
14795    
14796            /**
14797             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63;.
14798             *
14799             * @param resourcePrimKey the resource prim key
14800             * @param nodeId the node ID
14801             * @return the number of matching wiki pages
14802             * @throws SystemException if a system exception occurred
14803             */
14804            public int countByR_N(long resourcePrimKey, long nodeId)
14805                    throws SystemException {
14806                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId };
14807    
14808                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_N,
14809                                    finderArgs, this);
14810    
14811                    if (count == null) {
14812                            StringBundler query = new StringBundler(3);
14813    
14814                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14815    
14816                            query.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
14817    
14818                            query.append(_FINDER_COLUMN_R_N_NODEID_2);
14819    
14820                            String sql = query.toString();
14821    
14822                            Session session = null;
14823    
14824                            try {
14825                                    session = openSession();
14826    
14827                                    Query q = session.createQuery(sql);
14828    
14829                                    QueryPos qPos = QueryPos.getInstance(q);
14830    
14831                                    qPos.add(resourcePrimKey);
14832    
14833                                    qPos.add(nodeId);
14834    
14835                                    count = (Long)q.uniqueResult();
14836                            }
14837                            catch (Exception e) {
14838                                    throw processException(e);
14839                            }
14840                            finally {
14841                                    if (count == null) {
14842                                            count = Long.valueOf(0);
14843                                    }
14844    
14845                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N, finderArgs,
14846                                            count);
14847    
14848                                    closeSession(session);
14849                            }
14850                    }
14851    
14852                    return count.intValue();
14853            }
14854    
14855            /**
14856             * Returns the number of wiki pages where nodeId = &#63; and title = &#63;.
14857             *
14858             * @param nodeId the node ID
14859             * @param title the title
14860             * @return the number of matching wiki pages
14861             * @throws SystemException if a system exception occurred
14862             */
14863            public int countByN_T(long nodeId, String title) throws SystemException {
14864                    Object[] finderArgs = new Object[] { nodeId, title };
14865    
14866                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T,
14867                                    finderArgs, this);
14868    
14869                    if (count == null) {
14870                            StringBundler query = new StringBundler(3);
14871    
14872                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14873    
14874                            query.append(_FINDER_COLUMN_N_T_NODEID_2);
14875    
14876                            if (title == null) {
14877                                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
14878                            }
14879                            else {
14880                                    if (title.equals(StringPool.BLANK)) {
14881                                            query.append(_FINDER_COLUMN_N_T_TITLE_3);
14882                                    }
14883                                    else {
14884                                            query.append(_FINDER_COLUMN_N_T_TITLE_2);
14885                                    }
14886                            }
14887    
14888                            String sql = query.toString();
14889    
14890                            Session session = null;
14891    
14892                            try {
14893                                    session = openSession();
14894    
14895                                    Query q = session.createQuery(sql);
14896    
14897                                    QueryPos qPos = QueryPos.getInstance(q);
14898    
14899                                    qPos.add(nodeId);
14900    
14901                                    if (title != null) {
14902                                            qPos.add(title);
14903                                    }
14904    
14905                                    count = (Long)q.uniqueResult();
14906                            }
14907                            catch (Exception e) {
14908                                    throw processException(e);
14909                            }
14910                            finally {
14911                                    if (count == null) {
14912                                            count = Long.valueOf(0);
14913                                    }
14914    
14915                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, finderArgs,
14916                                            count);
14917    
14918                                    closeSession(session);
14919                            }
14920                    }
14921    
14922                    return count.intValue();
14923            }
14924    
14925            /**
14926             * Returns the number of wiki pages where nodeId = &#63; and head = &#63;.
14927             *
14928             * @param nodeId the node ID
14929             * @param head the head
14930             * @return the number of matching wiki pages
14931             * @throws SystemException if a system exception occurred
14932             */
14933            public int countByN_H(long nodeId, boolean head) throws SystemException {
14934                    Object[] finderArgs = new Object[] { nodeId, head };
14935    
14936                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H,
14937                                    finderArgs, this);
14938    
14939                    if (count == null) {
14940                            StringBundler query = new StringBundler(3);
14941    
14942                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
14943    
14944                            query.append(_FINDER_COLUMN_N_H_NODEID_2);
14945    
14946                            query.append(_FINDER_COLUMN_N_H_HEAD_2);
14947    
14948                            String sql = query.toString();
14949    
14950                            Session session = null;
14951    
14952                            try {
14953                                    session = openSession();
14954    
14955                                    Query q = session.createQuery(sql);
14956    
14957                                    QueryPos qPos = QueryPos.getInstance(q);
14958    
14959                                    qPos.add(nodeId);
14960    
14961                                    qPos.add(head);
14962    
14963                                    count = (Long)q.uniqueResult();
14964                            }
14965                            catch (Exception e) {
14966                                    throw processException(e);
14967                            }
14968                            finally {
14969                                    if (count == null) {
14970                                            count = Long.valueOf(0);
14971                                    }
14972    
14973                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H, finderArgs,
14974                                            count);
14975    
14976                                    closeSession(session);
14977                            }
14978                    }
14979    
14980                    return count.intValue();
14981            }
14982    
14983            /**
14984             * Returns the number of wiki pages where nodeId = &#63; and parentTitle = &#63;.
14985             *
14986             * @param nodeId the node ID
14987             * @param parentTitle the parent title
14988             * @return the number of matching wiki pages
14989             * @throws SystemException if a system exception occurred
14990             */
14991            public int countByN_P(long nodeId, String parentTitle)
14992                    throws SystemException {
14993                    Object[] finderArgs = new Object[] { nodeId, parentTitle };
14994    
14995                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_P,
14996                                    finderArgs, this);
14997    
14998                    if (count == null) {
14999                            StringBundler query = new StringBundler(3);
15000    
15001                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15002    
15003                            query.append(_FINDER_COLUMN_N_P_NODEID_2);
15004    
15005                            if (parentTitle == null) {
15006                                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
15007                            }
15008                            else {
15009                                    if (parentTitle.equals(StringPool.BLANK)) {
15010                                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
15011                                    }
15012                                    else {
15013                                            query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
15014                                    }
15015                            }
15016    
15017                            String sql = query.toString();
15018    
15019                            Session session = null;
15020    
15021                            try {
15022                                    session = openSession();
15023    
15024                                    Query q = session.createQuery(sql);
15025    
15026                                    QueryPos qPos = QueryPos.getInstance(q);
15027    
15028                                    qPos.add(nodeId);
15029    
15030                                    if (parentTitle != null) {
15031                                            qPos.add(parentTitle);
15032                                    }
15033    
15034                                    count = (Long)q.uniqueResult();
15035                            }
15036                            catch (Exception e) {
15037                                    throw processException(e);
15038                            }
15039                            finally {
15040                                    if (count == null) {
15041                                            count = Long.valueOf(0);
15042                                    }
15043    
15044                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_P, finderArgs,
15045                                            count);
15046    
15047                                    closeSession(session);
15048                            }
15049                    }
15050    
15051                    return count.intValue();
15052            }
15053    
15054            /**
15055             * Returns the number of wiki pages where nodeId = &#63; and redirectTitle = &#63;.
15056             *
15057             * @param nodeId the node ID
15058             * @param redirectTitle the redirect title
15059             * @return the number of matching wiki pages
15060             * @throws SystemException if a system exception occurred
15061             */
15062            public int countByN_R(long nodeId, String redirectTitle)
15063                    throws SystemException {
15064                    Object[] finderArgs = new Object[] { nodeId, redirectTitle };
15065    
15066                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_R,
15067                                    finderArgs, this);
15068    
15069                    if (count == null) {
15070                            StringBundler query = new StringBundler(3);
15071    
15072                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15073    
15074                            query.append(_FINDER_COLUMN_N_R_NODEID_2);
15075    
15076                            if (redirectTitle == null) {
15077                                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
15078                            }
15079                            else {
15080                                    if (redirectTitle.equals(StringPool.BLANK)) {
15081                                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
15082                                    }
15083                                    else {
15084                                            query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
15085                                    }
15086                            }
15087    
15088                            String sql = query.toString();
15089    
15090                            Session session = null;
15091    
15092                            try {
15093                                    session = openSession();
15094    
15095                                    Query q = session.createQuery(sql);
15096    
15097                                    QueryPos qPos = QueryPos.getInstance(q);
15098    
15099                                    qPos.add(nodeId);
15100    
15101                                    if (redirectTitle != null) {
15102                                            qPos.add(redirectTitle);
15103                                    }
15104    
15105                                    count = (Long)q.uniqueResult();
15106                            }
15107                            catch (Exception e) {
15108                                    throw processException(e);
15109                            }
15110                            finally {
15111                                    if (count == null) {
15112                                            count = Long.valueOf(0);
15113                                    }
15114    
15115                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_R, finderArgs,
15116                                            count);
15117    
15118                                    closeSession(session);
15119                            }
15120                    }
15121    
15122                    return count.intValue();
15123            }
15124    
15125            /**
15126             * Returns the number of wiki pages where nodeId = &#63; and status = &#63;.
15127             *
15128             * @param nodeId the node ID
15129             * @param status the status
15130             * @return the number of matching wiki pages
15131             * @throws SystemException if a system exception occurred
15132             */
15133            public int countByN_S(long nodeId, int status) throws SystemException {
15134                    Object[] finderArgs = new Object[] { nodeId, status };
15135    
15136                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_S,
15137                                    finderArgs, this);
15138    
15139                    if (count == null) {
15140                            StringBundler query = new StringBundler(3);
15141    
15142                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15143    
15144                            query.append(_FINDER_COLUMN_N_S_NODEID_2);
15145    
15146                            query.append(_FINDER_COLUMN_N_S_STATUS_2);
15147    
15148                            String sql = query.toString();
15149    
15150                            Session session = null;
15151    
15152                            try {
15153                                    session = openSession();
15154    
15155                                    Query q = session.createQuery(sql);
15156    
15157                                    QueryPos qPos = QueryPos.getInstance(q);
15158    
15159                                    qPos.add(nodeId);
15160    
15161                                    qPos.add(status);
15162    
15163                                    count = (Long)q.uniqueResult();
15164                            }
15165                            catch (Exception e) {
15166                                    throw processException(e);
15167                            }
15168                            finally {
15169                                    if (count == null) {
15170                                            count = Long.valueOf(0);
15171                                    }
15172    
15173                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_S, finderArgs,
15174                                            count);
15175    
15176                                    closeSession(session);
15177                            }
15178                    }
15179    
15180                    return count.intValue();
15181            }
15182    
15183            /**
15184             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and version = &#63;.
15185             *
15186             * @param resourcePrimKey the resource prim key
15187             * @param nodeId the node ID
15188             * @param version the version
15189             * @return the number of matching wiki pages
15190             * @throws SystemException if a system exception occurred
15191             */
15192            public int countByR_N_V(long resourcePrimKey, long nodeId, double version)
15193                    throws SystemException {
15194                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, version };
15195    
15196                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_N_V,
15197                                    finderArgs, this);
15198    
15199                    if (count == null) {
15200                            StringBundler query = new StringBundler(4);
15201    
15202                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15203    
15204                            query.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
15205    
15206                            query.append(_FINDER_COLUMN_R_N_V_NODEID_2);
15207    
15208                            query.append(_FINDER_COLUMN_R_N_V_VERSION_2);
15209    
15210                            String sql = query.toString();
15211    
15212                            Session session = null;
15213    
15214                            try {
15215                                    session = openSession();
15216    
15217                                    Query q = session.createQuery(sql);
15218    
15219                                    QueryPos qPos = QueryPos.getInstance(q);
15220    
15221                                    qPos.add(resourcePrimKey);
15222    
15223                                    qPos.add(nodeId);
15224    
15225                                    qPos.add(version);
15226    
15227                                    count = (Long)q.uniqueResult();
15228                            }
15229                            catch (Exception e) {
15230                                    throw processException(e);
15231                            }
15232                            finally {
15233                                    if (count == null) {
15234                                            count = Long.valueOf(0);
15235                                    }
15236    
15237                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_V,
15238                                            finderArgs, count);
15239    
15240                                    closeSession(session);
15241                            }
15242                    }
15243    
15244                    return count.intValue();
15245            }
15246    
15247            /**
15248             * Returns the number of wiki pages where resourcePrimKey = &#63; and nodeId = &#63; and status = &#63;.
15249             *
15250             * @param resourcePrimKey the resource prim key
15251             * @param nodeId the node ID
15252             * @param status the status
15253             * @return the number of matching wiki pages
15254             * @throws SystemException if a system exception occurred
15255             */
15256            public int countByR_N_S(long resourcePrimKey, long nodeId, int status)
15257                    throws SystemException {
15258                    Object[] finderArgs = new Object[] { resourcePrimKey, nodeId, status };
15259    
15260                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_N_S,
15261                                    finderArgs, this);
15262    
15263                    if (count == null) {
15264                            StringBundler query = new StringBundler(4);
15265    
15266                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15267    
15268                            query.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
15269    
15270                            query.append(_FINDER_COLUMN_R_N_S_NODEID_2);
15271    
15272                            query.append(_FINDER_COLUMN_R_N_S_STATUS_2);
15273    
15274                            String sql = query.toString();
15275    
15276                            Session session = null;
15277    
15278                            try {
15279                                    session = openSession();
15280    
15281                                    Query q = session.createQuery(sql);
15282    
15283                                    QueryPos qPos = QueryPos.getInstance(q);
15284    
15285                                    qPos.add(resourcePrimKey);
15286    
15287                                    qPos.add(nodeId);
15288    
15289                                    qPos.add(status);
15290    
15291                                    count = (Long)q.uniqueResult();
15292                            }
15293                            catch (Exception e) {
15294                                    throw processException(e);
15295                            }
15296                            finally {
15297                                    if (count == null) {
15298                                            count = Long.valueOf(0);
15299                                    }
15300    
15301                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_N_S,
15302                                            finderArgs, count);
15303    
15304                                    closeSession(session);
15305                            }
15306                    }
15307    
15308                    return count.intValue();
15309            }
15310    
15311            /**
15312             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63;.
15313             *
15314             * @param groupId the group ID
15315             * @param nodeId the node ID
15316             * @param head the head
15317             * @return the number of matching wiki pages
15318             * @throws SystemException if a system exception occurred
15319             */
15320            public int countByG_N_H(long groupId, long nodeId, boolean head)
15321                    throws SystemException {
15322                    Object[] finderArgs = new Object[] { groupId, nodeId, head };
15323    
15324                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_H,
15325                                    finderArgs, this);
15326    
15327                    if (count == null) {
15328                            StringBundler query = new StringBundler(4);
15329    
15330                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15331    
15332                            query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
15333    
15334                            query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
15335    
15336                            query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
15337    
15338                            String sql = query.toString();
15339    
15340                            Session session = null;
15341    
15342                            try {
15343                                    session = openSession();
15344    
15345                                    Query q = session.createQuery(sql);
15346    
15347                                    QueryPos qPos = QueryPos.getInstance(q);
15348    
15349                                    qPos.add(groupId);
15350    
15351                                    qPos.add(nodeId);
15352    
15353                                    qPos.add(head);
15354    
15355                                    count = (Long)q.uniqueResult();
15356                            }
15357                            catch (Exception e) {
15358                                    throw processException(e);
15359                            }
15360                            finally {
15361                                    if (count == null) {
15362                                            count = Long.valueOf(0);
15363                                    }
15364    
15365                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_H,
15366                                            finderArgs, count);
15367    
15368                                    closeSession(session);
15369                            }
15370                    }
15371    
15372                    return count.intValue();
15373            }
15374    
15375            /**
15376             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63;.
15377             *
15378             * @param groupId the group ID
15379             * @param nodeId the node ID
15380             * @param head the head
15381             * @return the number of matching wiki pages that the user has permission to view
15382             * @throws SystemException if a system exception occurred
15383             */
15384            public int filterCountByG_N_H(long groupId, long nodeId, boolean head)
15385                    throws SystemException {
15386                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15387                            return countByG_N_H(groupId, nodeId, head);
15388                    }
15389    
15390                    StringBundler query = new StringBundler(4);
15391    
15392                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
15393    
15394                    query.append(_FINDER_COLUMN_G_N_H_GROUPID_2);
15395    
15396                    query.append(_FINDER_COLUMN_G_N_H_NODEID_2);
15397    
15398                    query.append(_FINDER_COLUMN_G_N_H_HEAD_2);
15399    
15400                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15401                                    WikiPage.class.getName(),
15402                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15403    
15404                    Session session = null;
15405    
15406                    try {
15407                            session = openSession();
15408    
15409                            SQLQuery q = session.createSQLQuery(sql);
15410    
15411                            q.addScalar(COUNT_COLUMN_NAME,
15412                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15413    
15414                            QueryPos qPos = QueryPos.getInstance(q);
15415    
15416                            qPos.add(groupId);
15417    
15418                            qPos.add(nodeId);
15419    
15420                            qPos.add(head);
15421    
15422                            Long count = (Long)q.uniqueResult();
15423    
15424                            return count.intValue();
15425                    }
15426                    catch (Exception e) {
15427                            throw processException(e);
15428                    }
15429                    finally {
15430                            closeSession(session);
15431                    }
15432            }
15433    
15434            /**
15435             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and status = &#63;.
15436             *
15437             * @param groupId the group ID
15438             * @param nodeId the node ID
15439             * @param status the status
15440             * @return the number of matching wiki pages
15441             * @throws SystemException if a system exception occurred
15442             */
15443            public int countByG_N_S(long groupId, long nodeId, int status)
15444                    throws SystemException {
15445                    Object[] finderArgs = new Object[] { groupId, nodeId, status };
15446    
15447                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_S,
15448                                    finderArgs, this);
15449    
15450                    if (count == null) {
15451                            StringBundler query = new StringBundler(4);
15452    
15453                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15454    
15455                            query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
15456    
15457                            query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
15458    
15459                            query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
15460    
15461                            String sql = query.toString();
15462    
15463                            Session session = null;
15464    
15465                            try {
15466                                    session = openSession();
15467    
15468                                    Query q = session.createQuery(sql);
15469    
15470                                    QueryPos qPos = QueryPos.getInstance(q);
15471    
15472                                    qPos.add(groupId);
15473    
15474                                    qPos.add(nodeId);
15475    
15476                                    qPos.add(status);
15477    
15478                                    count = (Long)q.uniqueResult();
15479                            }
15480                            catch (Exception e) {
15481                                    throw processException(e);
15482                            }
15483                            finally {
15484                                    if (count == null) {
15485                                            count = Long.valueOf(0);
15486                                    }
15487    
15488                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_S,
15489                                            finderArgs, count);
15490    
15491                                    closeSession(session);
15492                            }
15493                    }
15494    
15495                    return count.intValue();
15496            }
15497    
15498            /**
15499             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and status = &#63;.
15500             *
15501             * @param groupId the group ID
15502             * @param nodeId the node ID
15503             * @param status the status
15504             * @return the number of matching wiki pages that the user has permission to view
15505             * @throws SystemException if a system exception occurred
15506             */
15507            public int filterCountByG_N_S(long groupId, long nodeId, int status)
15508                    throws SystemException {
15509                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15510                            return countByG_N_S(groupId, nodeId, status);
15511                    }
15512    
15513                    StringBundler query = new StringBundler(4);
15514    
15515                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
15516    
15517                    query.append(_FINDER_COLUMN_G_N_S_GROUPID_2);
15518    
15519                    query.append(_FINDER_COLUMN_G_N_S_NODEID_2);
15520    
15521                    query.append(_FINDER_COLUMN_G_N_S_STATUS_2);
15522    
15523                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15524                                    WikiPage.class.getName(),
15525                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15526    
15527                    Session session = null;
15528    
15529                    try {
15530                            session = openSession();
15531    
15532                            SQLQuery q = session.createSQLQuery(sql);
15533    
15534                            q.addScalar(COUNT_COLUMN_NAME,
15535                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15536    
15537                            QueryPos qPos = QueryPos.getInstance(q);
15538    
15539                            qPos.add(groupId);
15540    
15541                            qPos.add(nodeId);
15542    
15543                            qPos.add(status);
15544    
15545                            Long count = (Long)q.uniqueResult();
15546    
15547                            return count.intValue();
15548                    }
15549                    catch (Exception e) {
15550                            throw processException(e);
15551                    }
15552                    finally {
15553                            closeSession(session);
15554                    }
15555            }
15556    
15557            /**
15558             * Returns the number of wiki pages where userId = &#63; and nodeId = &#63; and status = &#63;.
15559             *
15560             * @param userId the user ID
15561             * @param nodeId the node ID
15562             * @param status the status
15563             * @return the number of matching wiki pages
15564             * @throws SystemException if a system exception occurred
15565             */
15566            public int countByU_N_S(long userId, long nodeId, int status)
15567                    throws SystemException {
15568                    Object[] finderArgs = new Object[] { userId, nodeId, status };
15569    
15570                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_N_S,
15571                                    finderArgs, this);
15572    
15573                    if (count == null) {
15574                            StringBundler query = new StringBundler(4);
15575    
15576                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15577    
15578                            query.append(_FINDER_COLUMN_U_N_S_USERID_2);
15579    
15580                            query.append(_FINDER_COLUMN_U_N_S_NODEID_2);
15581    
15582                            query.append(_FINDER_COLUMN_U_N_S_STATUS_2);
15583    
15584                            String sql = query.toString();
15585    
15586                            Session session = null;
15587    
15588                            try {
15589                                    session = openSession();
15590    
15591                                    Query q = session.createQuery(sql);
15592    
15593                                    QueryPos qPos = QueryPos.getInstance(q);
15594    
15595                                    qPos.add(userId);
15596    
15597                                    qPos.add(nodeId);
15598    
15599                                    qPos.add(status);
15600    
15601                                    count = (Long)q.uniqueResult();
15602                            }
15603                            catch (Exception e) {
15604                                    throw processException(e);
15605                            }
15606                            finally {
15607                                    if (count == null) {
15608                                            count = Long.valueOf(0);
15609                                    }
15610    
15611                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_N_S,
15612                                            finderArgs, count);
15613    
15614                                    closeSession(session);
15615                            }
15616                    }
15617    
15618                    return count.intValue();
15619            }
15620    
15621            /**
15622             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and version = &#63;.
15623             *
15624             * @param nodeId the node ID
15625             * @param title the title
15626             * @param version the version
15627             * @return the number of matching wiki pages
15628             * @throws SystemException if a system exception occurred
15629             */
15630            public int countByN_T_V(long nodeId, String title, double version)
15631                    throws SystemException {
15632                    Object[] finderArgs = new Object[] { nodeId, title, version };
15633    
15634                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_V,
15635                                    finderArgs, this);
15636    
15637                    if (count == null) {
15638                            StringBundler query = new StringBundler(4);
15639    
15640                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15641    
15642                            query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
15643    
15644                            if (title == null) {
15645                                    query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
15646                            }
15647                            else {
15648                                    if (title.equals(StringPool.BLANK)) {
15649                                            query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
15650                                    }
15651                                    else {
15652                                            query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
15653                                    }
15654                            }
15655    
15656                            query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
15657    
15658                            String sql = query.toString();
15659    
15660                            Session session = null;
15661    
15662                            try {
15663                                    session = openSession();
15664    
15665                                    Query q = session.createQuery(sql);
15666    
15667                                    QueryPos qPos = QueryPos.getInstance(q);
15668    
15669                                    qPos.add(nodeId);
15670    
15671                                    if (title != null) {
15672                                            qPos.add(title);
15673                                    }
15674    
15675                                    qPos.add(version);
15676    
15677                                    count = (Long)q.uniqueResult();
15678                            }
15679                            catch (Exception e) {
15680                                    throw processException(e);
15681                            }
15682                            finally {
15683                                    if (count == null) {
15684                                            count = Long.valueOf(0);
15685                                    }
15686    
15687                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V,
15688                                            finderArgs, count);
15689    
15690                                    closeSession(session);
15691                            }
15692                    }
15693    
15694                    return count.intValue();
15695            }
15696    
15697            /**
15698             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and head = &#63;.
15699             *
15700             * @param nodeId the node ID
15701             * @param title the title
15702             * @param head the head
15703             * @return the number of matching wiki pages
15704             * @throws SystemException if a system exception occurred
15705             */
15706            public int countByN_T_H(long nodeId, String title, boolean head)
15707                    throws SystemException {
15708                    Object[] finderArgs = new Object[] { nodeId, title, head };
15709    
15710                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_H,
15711                                    finderArgs, this);
15712    
15713                    if (count == null) {
15714                            StringBundler query = new StringBundler(4);
15715    
15716                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15717    
15718                            query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
15719    
15720                            if (title == null) {
15721                                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
15722                            }
15723                            else {
15724                                    if (title.equals(StringPool.BLANK)) {
15725                                            query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
15726                                    }
15727                                    else {
15728                                            query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
15729                                    }
15730                            }
15731    
15732                            query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
15733    
15734                            String sql = query.toString();
15735    
15736                            Session session = null;
15737    
15738                            try {
15739                                    session = openSession();
15740    
15741                                    Query q = session.createQuery(sql);
15742    
15743                                    QueryPos qPos = QueryPos.getInstance(q);
15744    
15745                                    qPos.add(nodeId);
15746    
15747                                    if (title != null) {
15748                                            qPos.add(title);
15749                                    }
15750    
15751                                    qPos.add(head);
15752    
15753                                    count = (Long)q.uniqueResult();
15754                            }
15755                            catch (Exception e) {
15756                                    throw processException(e);
15757                            }
15758                            finally {
15759                                    if (count == null) {
15760                                            count = Long.valueOf(0);
15761                                    }
15762    
15763                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_H,
15764                                            finderArgs, count);
15765    
15766                                    closeSession(session);
15767                            }
15768                    }
15769    
15770                    return count.intValue();
15771            }
15772    
15773            /**
15774             * Returns the number of wiki pages where nodeId = &#63; and title = &#63; and status = &#63;.
15775             *
15776             * @param nodeId the node ID
15777             * @param title the title
15778             * @param status the status
15779             * @return the number of matching wiki pages
15780             * @throws SystemException if a system exception occurred
15781             */
15782            public int countByN_T_S(long nodeId, String title, int status)
15783                    throws SystemException {
15784                    Object[] finderArgs = new Object[] { nodeId, title, status };
15785    
15786                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_S,
15787                                    finderArgs, this);
15788    
15789                    if (count == null) {
15790                            StringBundler query = new StringBundler(4);
15791    
15792                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15793    
15794                            query.append(_FINDER_COLUMN_N_T_S_NODEID_2);
15795    
15796                            if (title == null) {
15797                                    query.append(_FINDER_COLUMN_N_T_S_TITLE_1);
15798                            }
15799                            else {
15800                                    if (title.equals(StringPool.BLANK)) {
15801                                            query.append(_FINDER_COLUMN_N_T_S_TITLE_3);
15802                                    }
15803                                    else {
15804                                            query.append(_FINDER_COLUMN_N_T_S_TITLE_2);
15805                                    }
15806                            }
15807    
15808                            query.append(_FINDER_COLUMN_N_T_S_STATUS_2);
15809    
15810                            String sql = query.toString();
15811    
15812                            Session session = null;
15813    
15814                            try {
15815                                    session = openSession();
15816    
15817                                    Query q = session.createQuery(sql);
15818    
15819                                    QueryPos qPos = QueryPos.getInstance(q);
15820    
15821                                    qPos.add(nodeId);
15822    
15823                                    if (title != null) {
15824                                            qPos.add(title);
15825                                    }
15826    
15827                                    qPos.add(status);
15828    
15829                                    count = (Long)q.uniqueResult();
15830                            }
15831                            catch (Exception e) {
15832                                    throw processException(e);
15833                            }
15834                            finally {
15835                                    if (count == null) {
15836                                            count = Long.valueOf(0);
15837                                    }
15838    
15839                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_S,
15840                                            finderArgs, count);
15841    
15842                                    closeSession(session);
15843                            }
15844                    }
15845    
15846                    return count.intValue();
15847            }
15848    
15849            /**
15850             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63;.
15851             *
15852             * @param nodeId the node ID
15853             * @param head the head
15854             * @param parentTitle the parent title
15855             * @return the number of matching wiki pages
15856             * @throws SystemException if a system exception occurred
15857             */
15858            public int countByN_H_P(long nodeId, boolean head, String parentTitle)
15859                    throws SystemException {
15860                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle };
15861    
15862                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H_P,
15863                                    finderArgs, this);
15864    
15865                    if (count == null) {
15866                            StringBundler query = new StringBundler(4);
15867    
15868                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15869    
15870                            query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
15871    
15872                            query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
15873    
15874                            if (parentTitle == null) {
15875                                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
15876                            }
15877                            else {
15878                                    if (parentTitle.equals(StringPool.BLANK)) {
15879                                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
15880                                    }
15881                                    else {
15882                                            query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
15883                                    }
15884                            }
15885    
15886                            String sql = query.toString();
15887    
15888                            Session session = null;
15889    
15890                            try {
15891                                    session = openSession();
15892    
15893                                    Query q = session.createQuery(sql);
15894    
15895                                    QueryPos qPos = QueryPos.getInstance(q);
15896    
15897                                    qPos.add(nodeId);
15898    
15899                                    qPos.add(head);
15900    
15901                                    if (parentTitle != null) {
15902                                            qPos.add(parentTitle);
15903                                    }
15904    
15905                                    count = (Long)q.uniqueResult();
15906                            }
15907                            catch (Exception e) {
15908                                    throw processException(e);
15909                            }
15910                            finally {
15911                                    if (count == null) {
15912                                            count = Long.valueOf(0);
15913                                    }
15914    
15915                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H_P,
15916                                            finderArgs, count);
15917    
15918                                    closeSession(session);
15919                            }
15920                    }
15921    
15922                    return count.intValue();
15923            }
15924    
15925            /**
15926             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and status = &#63;.
15927             *
15928             * @param nodeId the node ID
15929             * @param head the head
15930             * @param status the status
15931             * @return the number of matching wiki pages
15932             * @throws SystemException if a system exception occurred
15933             */
15934            public int countByN_H_S(long nodeId, boolean head, int status)
15935                    throws SystemException {
15936                    Object[] finderArgs = new Object[] { nodeId, head, status };
15937    
15938                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H_S,
15939                                    finderArgs, this);
15940    
15941                    if (count == null) {
15942                            StringBundler query = new StringBundler(4);
15943    
15944                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
15945    
15946                            query.append(_FINDER_COLUMN_N_H_S_NODEID_2);
15947    
15948                            query.append(_FINDER_COLUMN_N_H_S_HEAD_2);
15949    
15950                            query.append(_FINDER_COLUMN_N_H_S_STATUS_2);
15951    
15952                            String sql = query.toString();
15953    
15954                            Session session = null;
15955    
15956                            try {
15957                                    session = openSession();
15958    
15959                                    Query q = session.createQuery(sql);
15960    
15961                                    QueryPos qPos = QueryPos.getInstance(q);
15962    
15963                                    qPos.add(nodeId);
15964    
15965                                    qPos.add(head);
15966    
15967                                    qPos.add(status);
15968    
15969                                    count = (Long)q.uniqueResult();
15970                            }
15971                            catch (Exception e) {
15972                                    throw processException(e);
15973                            }
15974                            finally {
15975                                    if (count == null) {
15976                                            count = Long.valueOf(0);
15977                                    }
15978    
15979                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H_S,
15980                                            finderArgs, count);
15981    
15982                                    closeSession(session);
15983                            }
15984                    }
15985    
15986                    return count.intValue();
15987            }
15988    
15989            /**
15990             * Returns the number of wiki pages where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
15991             *
15992             * @param groupId the group ID
15993             * @param userId the user ID
15994             * @param nodeId the node ID
15995             * @param status the status
15996             * @return the number of matching wiki pages
15997             * @throws SystemException if a system exception occurred
15998             */
15999            public int countByG_U_N_S(long groupId, long userId, long nodeId, int status)
16000                    throws SystemException {
16001                    Object[] finderArgs = new Object[] { groupId, userId, nodeId, status };
16002    
16003                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_N_S,
16004                                    finderArgs, this);
16005    
16006                    if (count == null) {
16007                            StringBundler query = new StringBundler(5);
16008    
16009                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
16010    
16011                            query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
16012    
16013                            query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
16014    
16015                            query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
16016    
16017                            query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
16018    
16019                            String sql = query.toString();
16020    
16021                            Session session = null;
16022    
16023                            try {
16024                                    session = openSession();
16025    
16026                                    Query q = session.createQuery(sql);
16027    
16028                                    QueryPos qPos = QueryPos.getInstance(q);
16029    
16030                                    qPos.add(groupId);
16031    
16032                                    qPos.add(userId);
16033    
16034                                    qPos.add(nodeId);
16035    
16036                                    qPos.add(status);
16037    
16038                                    count = (Long)q.uniqueResult();
16039                            }
16040                            catch (Exception e) {
16041                                    throw processException(e);
16042                            }
16043                            finally {
16044                                    if (count == null) {
16045                                            count = Long.valueOf(0);
16046                                    }
16047    
16048                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_N_S,
16049                                            finderArgs, count);
16050    
16051                                    closeSession(session);
16052                            }
16053                    }
16054    
16055                    return count.intValue();
16056            }
16057    
16058            /**
16059             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and userId = &#63; and nodeId = &#63; and status = &#63;.
16060             *
16061             * @param groupId the group ID
16062             * @param userId the user ID
16063             * @param nodeId the node ID
16064             * @param status the status
16065             * @return the number of matching wiki pages that the user has permission to view
16066             * @throws SystemException if a system exception occurred
16067             */
16068            public int filterCountByG_U_N_S(long groupId, long userId, long nodeId,
16069                    int status) throws SystemException {
16070                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16071                            return countByG_U_N_S(groupId, userId, nodeId, status);
16072                    }
16073    
16074                    StringBundler query = new StringBundler(5);
16075    
16076                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
16077    
16078                    query.append(_FINDER_COLUMN_G_U_N_S_GROUPID_2);
16079    
16080                    query.append(_FINDER_COLUMN_G_U_N_S_USERID_2);
16081    
16082                    query.append(_FINDER_COLUMN_G_U_N_S_NODEID_2);
16083    
16084                    query.append(_FINDER_COLUMN_G_U_N_S_STATUS_2);
16085    
16086                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16087                                    WikiPage.class.getName(),
16088                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16089    
16090                    Session session = null;
16091    
16092                    try {
16093                            session = openSession();
16094    
16095                            SQLQuery q = session.createSQLQuery(sql);
16096    
16097                            q.addScalar(COUNT_COLUMN_NAME,
16098                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16099    
16100                            QueryPos qPos = QueryPos.getInstance(q);
16101    
16102                            qPos.add(groupId);
16103    
16104                            qPos.add(userId);
16105    
16106                            qPos.add(nodeId);
16107    
16108                            qPos.add(status);
16109    
16110                            Long count = (Long)q.uniqueResult();
16111    
16112                            return count.intValue();
16113                    }
16114                    catch (Exception e) {
16115                            throw processException(e);
16116                    }
16117                    finally {
16118                            closeSession(session);
16119                    }
16120            }
16121    
16122            /**
16123             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
16124             *
16125             * @param groupId the group ID
16126             * @param nodeId the node ID
16127             * @param title the title
16128             * @param head the head
16129             * @return the number of matching wiki pages
16130             * @throws SystemException if a system exception occurred
16131             */
16132            public int countByG_N_T_H(long groupId, long nodeId, String title,
16133                    boolean head) throws SystemException {
16134                    Object[] finderArgs = new Object[] { groupId, nodeId, title, head };
16135    
16136                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_T_H,
16137                                    finderArgs, this);
16138    
16139                    if (count == null) {
16140                            StringBundler query = new StringBundler(5);
16141    
16142                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
16143    
16144                            query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
16145    
16146                            query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
16147    
16148                            if (title == null) {
16149                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
16150                            }
16151                            else {
16152                                    if (title.equals(StringPool.BLANK)) {
16153                                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
16154                                    }
16155                                    else {
16156                                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
16157                                    }
16158                            }
16159    
16160                            query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
16161    
16162                            String sql = query.toString();
16163    
16164                            Session session = null;
16165    
16166                            try {
16167                                    session = openSession();
16168    
16169                                    Query q = session.createQuery(sql);
16170    
16171                                    QueryPos qPos = QueryPos.getInstance(q);
16172    
16173                                    qPos.add(groupId);
16174    
16175                                    qPos.add(nodeId);
16176    
16177                                    if (title != null) {
16178                                            qPos.add(title);
16179                                    }
16180    
16181                                    qPos.add(head);
16182    
16183                                    count = (Long)q.uniqueResult();
16184                            }
16185                            catch (Exception e) {
16186                                    throw processException(e);
16187                            }
16188                            finally {
16189                                    if (count == null) {
16190                                            count = Long.valueOf(0);
16191                                    }
16192    
16193                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_T_H,
16194                                            finderArgs, count);
16195    
16196                                    closeSession(session);
16197                            }
16198                    }
16199    
16200                    return count.intValue();
16201            }
16202    
16203            /**
16204             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and title = &#63; and head = &#63;.
16205             *
16206             * @param groupId the group ID
16207             * @param nodeId the node ID
16208             * @param title the title
16209             * @param head the head
16210             * @return the number of matching wiki pages that the user has permission to view
16211             * @throws SystemException if a system exception occurred
16212             */
16213            public int filterCountByG_N_T_H(long groupId, long nodeId, String title,
16214                    boolean head) throws SystemException {
16215                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16216                            return countByG_N_T_H(groupId, nodeId, title, head);
16217                    }
16218    
16219                    StringBundler query = new StringBundler(5);
16220    
16221                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
16222    
16223                    query.append(_FINDER_COLUMN_G_N_T_H_GROUPID_2);
16224    
16225                    query.append(_FINDER_COLUMN_G_N_T_H_NODEID_2);
16226    
16227                    if (title == null) {
16228                            query.append(_FINDER_COLUMN_G_N_T_H_TITLE_1);
16229                    }
16230                    else {
16231                            if (title.equals(StringPool.BLANK)) {
16232                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_3);
16233                            }
16234                            else {
16235                                    query.append(_FINDER_COLUMN_G_N_T_H_TITLE_2);
16236                            }
16237                    }
16238    
16239                    query.append(_FINDER_COLUMN_G_N_T_H_HEAD_2);
16240    
16241                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16242                                    WikiPage.class.getName(),
16243                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16244    
16245                    Session session = null;
16246    
16247                    try {
16248                            session = openSession();
16249    
16250                            SQLQuery q = session.createSQLQuery(sql);
16251    
16252                            q.addScalar(COUNT_COLUMN_NAME,
16253                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16254    
16255                            QueryPos qPos = QueryPos.getInstance(q);
16256    
16257                            qPos.add(groupId);
16258    
16259                            qPos.add(nodeId);
16260    
16261                            if (title != null) {
16262                                    qPos.add(title);
16263                            }
16264    
16265                            qPos.add(head);
16266    
16267                            Long count = (Long)q.uniqueResult();
16268    
16269                            return count.intValue();
16270                    }
16271                    catch (Exception e) {
16272                            throw processException(e);
16273                    }
16274                    finally {
16275                            closeSession(session);
16276                    }
16277            }
16278    
16279            /**
16280             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16281             *
16282             * @param groupId the group ID
16283             * @param nodeId the node ID
16284             * @param head the head
16285             * @param status the status
16286             * @return the number of matching wiki pages
16287             * @throws SystemException if a system exception occurred
16288             */
16289            public int countByG_N_H_S(long groupId, long nodeId, boolean head,
16290                    int status) throws SystemException {
16291                    Object[] finderArgs = new Object[] { groupId, nodeId, head, status };
16292    
16293                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_H_S,
16294                                    finderArgs, this);
16295    
16296                    if (count == null) {
16297                            StringBundler query = new StringBundler(5);
16298    
16299                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
16300    
16301                            query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
16302    
16303                            query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
16304    
16305                            query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
16306    
16307                            query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
16308    
16309                            String sql = query.toString();
16310    
16311                            Session session = null;
16312    
16313                            try {
16314                                    session = openSession();
16315    
16316                                    Query q = session.createQuery(sql);
16317    
16318                                    QueryPos qPos = QueryPos.getInstance(q);
16319    
16320                                    qPos.add(groupId);
16321    
16322                                    qPos.add(nodeId);
16323    
16324                                    qPos.add(head);
16325    
16326                                    qPos.add(status);
16327    
16328                                    count = (Long)q.uniqueResult();
16329                            }
16330                            catch (Exception e) {
16331                                    throw processException(e);
16332                            }
16333                            finally {
16334                                    if (count == null) {
16335                                            count = Long.valueOf(0);
16336                                    }
16337    
16338                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_H_S,
16339                                            finderArgs, count);
16340    
16341                                    closeSession(session);
16342                            }
16343                    }
16344    
16345                    return count.intValue();
16346            }
16347    
16348            /**
16349             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and status = &#63;.
16350             *
16351             * @param groupId the group ID
16352             * @param nodeId the node ID
16353             * @param head the head
16354             * @param status the status
16355             * @return the number of matching wiki pages that the user has permission to view
16356             * @throws SystemException if a system exception occurred
16357             */
16358            public int filterCountByG_N_H_S(long groupId, long nodeId, boolean head,
16359                    int status) throws SystemException {
16360                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16361                            return countByG_N_H_S(groupId, nodeId, head, status);
16362                    }
16363    
16364                    StringBundler query = new StringBundler(5);
16365    
16366                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
16367    
16368                    query.append(_FINDER_COLUMN_G_N_H_S_GROUPID_2);
16369    
16370                    query.append(_FINDER_COLUMN_G_N_H_S_NODEID_2);
16371    
16372                    query.append(_FINDER_COLUMN_G_N_H_S_HEAD_2);
16373    
16374                    query.append(_FINDER_COLUMN_G_N_H_S_STATUS_2);
16375    
16376                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16377                                    WikiPage.class.getName(),
16378                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16379    
16380                    Session session = null;
16381    
16382                    try {
16383                            session = openSession();
16384    
16385                            SQLQuery q = session.createSQLQuery(sql);
16386    
16387                            q.addScalar(COUNT_COLUMN_NAME,
16388                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16389    
16390                            QueryPos qPos = QueryPos.getInstance(q);
16391    
16392                            qPos.add(groupId);
16393    
16394                            qPos.add(nodeId);
16395    
16396                            qPos.add(head);
16397    
16398                            qPos.add(status);
16399    
16400                            Long count = (Long)q.uniqueResult();
16401    
16402                            return count.intValue();
16403                    }
16404                    catch (Exception e) {
16405                            throw processException(e);
16406                    }
16407                    finally {
16408                            closeSession(session);
16409                    }
16410            }
16411    
16412            /**
16413             * Returns the number of wiki pages where nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
16414             *
16415             * @param nodeId the node ID
16416             * @param head the head
16417             * @param parentTitle the parent title
16418             * @param status the status
16419             * @return the number of matching wiki pages
16420             * @throws SystemException if a system exception occurred
16421             */
16422            public int countByN_H_P_S(long nodeId, boolean head, String parentTitle,
16423                    int status) throws SystemException {
16424                    Object[] finderArgs = new Object[] { nodeId, head, parentTitle, status };
16425    
16426                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H_P_S,
16427                                    finderArgs, this);
16428    
16429                    if (count == null) {
16430                            StringBundler query = new StringBundler(5);
16431    
16432                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
16433    
16434                            query.append(_FINDER_COLUMN_N_H_P_S_NODEID_2);
16435    
16436                            query.append(_FINDER_COLUMN_N_H_P_S_HEAD_2);
16437    
16438                            if (parentTitle == null) {
16439                                    query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_1);
16440                            }
16441                            else {
16442                                    if (parentTitle.equals(StringPool.BLANK)) {
16443                                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_3);
16444                                    }
16445                                    else {
16446                                            query.append(_FINDER_COLUMN_N_H_P_S_PARENTTITLE_2);
16447                                    }
16448                            }
16449    
16450                            query.append(_FINDER_COLUMN_N_H_P_S_STATUS_2);
16451    
16452                            String sql = query.toString();
16453    
16454                            Session session = null;
16455    
16456                            try {
16457                                    session = openSession();
16458    
16459                                    Query q = session.createQuery(sql);
16460    
16461                                    QueryPos qPos = QueryPos.getInstance(q);
16462    
16463                                    qPos.add(nodeId);
16464    
16465                                    qPos.add(head);
16466    
16467                                    if (parentTitle != null) {
16468                                            qPos.add(parentTitle);
16469                                    }
16470    
16471                                    qPos.add(status);
16472    
16473                                    count = (Long)q.uniqueResult();
16474                            }
16475                            catch (Exception e) {
16476                                    throw processException(e);
16477                            }
16478                            finally {
16479                                    if (count == null) {
16480                                            count = Long.valueOf(0);
16481                                    }
16482    
16483                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H_P_S,
16484                                            finderArgs, count);
16485    
16486                                    closeSession(session);
16487                            }
16488                    }
16489    
16490                    return count.intValue();
16491            }
16492    
16493            /**
16494             * Returns the number of wiki pages where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
16495             *
16496             * @param groupId the group ID
16497             * @param nodeId the node ID
16498             * @param head the head
16499             * @param parentTitle the parent title
16500             * @param status the status
16501             * @return the number of matching wiki pages
16502             * @throws SystemException if a system exception occurred
16503             */
16504            public int countByG_N_H_P_S(long groupId, long nodeId, boolean head,
16505                    String parentTitle, int status) throws SystemException {
16506                    Object[] finderArgs = new Object[] {
16507                                    groupId, nodeId, head, parentTitle, status
16508                            };
16509    
16510                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_H_P_S,
16511                                    finderArgs, this);
16512    
16513                    if (count == null) {
16514                            StringBundler query = new StringBundler(6);
16515    
16516                            query.append(_SQL_COUNT_WIKIPAGE_WHERE);
16517    
16518                            query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
16519    
16520                            query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
16521    
16522                            query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
16523    
16524                            if (parentTitle == null) {
16525                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
16526                            }
16527                            else {
16528                                    if (parentTitle.equals(StringPool.BLANK)) {
16529                                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
16530                                    }
16531                                    else {
16532                                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
16533                                    }
16534                            }
16535    
16536                            query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
16537    
16538                            String sql = query.toString();
16539    
16540                            Session session = null;
16541    
16542                            try {
16543                                    session = openSession();
16544    
16545                                    Query q = session.createQuery(sql);
16546    
16547                                    QueryPos qPos = QueryPos.getInstance(q);
16548    
16549                                    qPos.add(groupId);
16550    
16551                                    qPos.add(nodeId);
16552    
16553                                    qPos.add(head);
16554    
16555                                    if (parentTitle != null) {
16556                                            qPos.add(parentTitle);
16557                                    }
16558    
16559                                    qPos.add(status);
16560    
16561                                    count = (Long)q.uniqueResult();
16562                            }
16563                            catch (Exception e) {
16564                                    throw processException(e);
16565                            }
16566                            finally {
16567                                    if (count == null) {
16568                                            count = Long.valueOf(0);
16569                                    }
16570    
16571                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_H_P_S,
16572                                            finderArgs, count);
16573    
16574                                    closeSession(session);
16575                            }
16576                    }
16577    
16578                    return count.intValue();
16579            }
16580    
16581            /**
16582             * Returns the number of wiki pages that the user has permission to view where groupId = &#63; and nodeId = &#63; and head = &#63; and parentTitle = &#63; and status = &#63;.
16583             *
16584             * @param groupId the group ID
16585             * @param nodeId the node ID
16586             * @param head the head
16587             * @param parentTitle the parent title
16588             * @param status the status
16589             * @return the number of matching wiki pages that the user has permission to view
16590             * @throws SystemException if a system exception occurred
16591             */
16592            public int filterCountByG_N_H_P_S(long groupId, long nodeId, boolean head,
16593                    String parentTitle, int status) throws SystemException {
16594                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16595                            return countByG_N_H_P_S(groupId, nodeId, head, parentTitle, status);
16596                    }
16597    
16598                    StringBundler query = new StringBundler(6);
16599    
16600                    query.append(_FILTER_SQL_COUNT_WIKIPAGE_WHERE);
16601    
16602                    query.append(_FINDER_COLUMN_G_N_H_P_S_GROUPID_2);
16603    
16604                    query.append(_FINDER_COLUMN_G_N_H_P_S_NODEID_2);
16605    
16606                    query.append(_FINDER_COLUMN_G_N_H_P_S_HEAD_2);
16607    
16608                    if (parentTitle == null) {
16609                            query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1);
16610                    }
16611                    else {
16612                            if (parentTitle.equals(StringPool.BLANK)) {
16613                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3);
16614                            }
16615                            else {
16616                                    query.append(_FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2);
16617                            }
16618                    }
16619    
16620                    query.append(_FINDER_COLUMN_G_N_H_P_S_STATUS_2);
16621    
16622                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16623                                    WikiPage.class.getName(),
16624                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16625    
16626                    Session session = null;
16627    
16628                    try {
16629                            session = openSession();
16630    
16631                            SQLQuery q = session.createSQLQuery(sql);
16632    
16633                            q.addScalar(COUNT_COLUMN_NAME,
16634                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16635    
16636                            QueryPos qPos = QueryPos.getInstance(q);
16637    
16638                            qPos.add(groupId);
16639    
16640                            qPos.add(nodeId);
16641    
16642                            qPos.add(head);
16643    
16644                            if (parentTitle != null) {
16645                                    qPos.add(parentTitle);
16646                            }
16647    
16648                            qPos.add(status);
16649    
16650                            Long count = (Long)q.uniqueResult();
16651    
16652                            return count.intValue();
16653                    }
16654                    catch (Exception e) {
16655                            throw processException(e);
16656                    }
16657                    finally {
16658                            closeSession(session);
16659                    }
16660            }
16661    
16662            /**
16663             * Returns the number of wiki pages.
16664             *
16665             * @return the number of wiki pages
16666             * @throws SystemException if a system exception occurred
16667             */
16668            public int countAll() throws SystemException {
16669                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
16670                                    FINDER_ARGS_EMPTY, this);
16671    
16672                    if (count == null) {
16673                            Session session = null;
16674    
16675                            try {
16676                                    session = openSession();
16677    
16678                                    Query q = session.createQuery(_SQL_COUNT_WIKIPAGE);
16679    
16680                                    count = (Long)q.uniqueResult();
16681                            }
16682                            catch (Exception e) {
16683                                    throw processException(e);
16684                            }
16685                            finally {
16686                                    if (count == null) {
16687                                            count = Long.valueOf(0);
16688                                    }
16689    
16690                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
16691                                            FINDER_ARGS_EMPTY, count);
16692    
16693                                    closeSession(session);
16694                            }
16695                    }
16696    
16697                    return count.intValue();
16698            }
16699    
16700            /**
16701             * Initializes the wiki page persistence.
16702             */
16703            public void afterPropertiesSet() {
16704                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
16705                                            com.liferay.portal.util.PropsUtil.get(
16706                                                    "value.object.listener.com.liferay.portlet.wiki.model.WikiPage")));
16707    
16708                    if (listenerClassNames.length > 0) {
16709                            try {
16710                                    List<ModelListener<WikiPage>> listenersList = new ArrayList<ModelListener<WikiPage>>();
16711    
16712                                    for (String listenerClassName : listenerClassNames) {
16713                                            Class<?> clazz = getClass();
16714    
16715                                            listenersList.add((ModelListener<WikiPage>)InstanceFactory.newInstance(
16716                                                            clazz.getClassLoader(), listenerClassName));
16717                                    }
16718    
16719                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
16720                            }
16721                            catch (Exception e) {
16722                                    _log.error(e);
16723                            }
16724                    }
16725            }
16726    
16727            public void destroy() {
16728                    EntityCacheUtil.removeCache(WikiPageImpl.class.getName());
16729                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
16730                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
16731            }
16732    
16733            @BeanReference(type = WikiNodePersistence.class)
16734            protected WikiNodePersistence wikiNodePersistence;
16735            @BeanReference(type = WikiPagePersistence.class)
16736            protected WikiPagePersistence wikiPagePersistence;
16737            @BeanReference(type = WikiPageResourcePersistence.class)
16738            protected WikiPageResourcePersistence wikiPageResourcePersistence;
16739            @BeanReference(type = CompanyPersistence.class)
16740            protected CompanyPersistence companyPersistence;
16741            @BeanReference(type = GroupPersistence.class)
16742            protected GroupPersistence groupPersistence;
16743            @BeanReference(type = PortletPreferencesPersistence.class)
16744            protected PortletPreferencesPersistence portletPreferencesPersistence;
16745            @BeanReference(type = ResourcePersistence.class)
16746            protected ResourcePersistence resourcePersistence;
16747            @BeanReference(type = SubscriptionPersistence.class)
16748            protected SubscriptionPersistence subscriptionPersistence;
16749            @BeanReference(type = UserPersistence.class)
16750            protected UserPersistence userPersistence;
16751            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
16752            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
16753            @BeanReference(type = AssetCategoryPersistence.class)
16754            protected AssetCategoryPersistence assetCategoryPersistence;
16755            @BeanReference(type = AssetEntryPersistence.class)
16756            protected AssetEntryPersistence assetEntryPersistence;
16757            @BeanReference(type = AssetLinkPersistence.class)
16758            protected AssetLinkPersistence assetLinkPersistence;
16759            @BeanReference(type = AssetTagPersistence.class)
16760            protected AssetTagPersistence assetTagPersistence;
16761            @BeanReference(type = ExpandoValuePersistence.class)
16762            protected ExpandoValuePersistence expandoValuePersistence;
16763            @BeanReference(type = MBMessagePersistence.class)
16764            protected MBMessagePersistence mbMessagePersistence;
16765            @BeanReference(type = SocialActivityPersistence.class)
16766            protected SocialActivityPersistence socialActivityPersistence;
16767            private static final String _SQL_SELECT_WIKIPAGE = "SELECT wikiPage FROM WikiPage wikiPage";
16768            private static final String _SQL_SELECT_WIKIPAGE_WHERE = "SELECT wikiPage FROM WikiPage wikiPage WHERE ";
16769            private static final String _SQL_COUNT_WIKIPAGE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage";
16770            private static final String _SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage WHERE ";
16771            private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiPage.uuid IS NULL";
16772            private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiPage.uuid = ?";
16773            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = ?)";
16774            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiPage.uuid IS NULL AND ";
16775            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiPage.uuid = ? AND ";
16776            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = ?) AND ";
16777            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiPage.groupId = ?";
16778            private static final String _FINDER_COLUMN_NODEID_NODEID_2 = "wikiPage.nodeId = ?";
16779            private static final String _FINDER_COLUMN_FORMAT_FORMAT_1 = "wikiPage.format IS NULL";
16780            private static final String _FINDER_COLUMN_FORMAT_FORMAT_2 = "wikiPage.format = ?";
16781            private static final String _FINDER_COLUMN_FORMAT_FORMAT_3 = "(wikiPage.format IS NULL OR wikiPage.format = ?)";
16782            private static final String _FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
16783            private static final String _FINDER_COLUMN_R_N_NODEID_2 = "wikiPage.nodeId = ?";
16784            private static final String _FINDER_COLUMN_N_T_NODEID_2 = "wikiPage.nodeId = ? AND ";
16785            private static final String _FINDER_COLUMN_N_T_TITLE_1 = "wikiPage.title IS NULL";
16786            private static final String _FINDER_COLUMN_N_T_TITLE_2 = "lower(wikiPage.title) = lower(CAST_TEXT(?))";
16787            private static final String _FINDER_COLUMN_N_T_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(CAST_TEXT(?)))";
16788            private static final String _FINDER_COLUMN_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
16789            private static final String _FINDER_COLUMN_N_H_HEAD_2 = "wikiPage.head = ?";
16790            private static final String _FINDER_COLUMN_N_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
16791            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
16792            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = lower(CAST_TEXT(?))";
16793            private static final String _FINDER_COLUMN_N_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR lower(wikiPage.parentTitle) = lower(CAST_TEXT(?)))";
16794            private static final String _FINDER_COLUMN_N_R_NODEID_2 = "wikiPage.nodeId = ? AND ";
16795            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL";
16796            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_2 = "lower(wikiPage.redirectTitle) = lower(CAST_TEXT(?))";
16797            private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR lower(wikiPage.redirectTitle) = lower(CAST_TEXT(?)))";
16798            private static final String _FINDER_COLUMN_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16799            private static final String _FINDER_COLUMN_N_S_STATUS_2 = "wikiPage.status = ?";
16800            private static final String _FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
16801            private static final String _FINDER_COLUMN_R_N_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
16802            private static final String _FINDER_COLUMN_R_N_V_VERSION_2 = "wikiPage.version = ?";
16803            private static final String _FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2 = "wikiPage.resourcePrimKey = ? AND ";
16804            private static final String _FINDER_COLUMN_R_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16805            private static final String _FINDER_COLUMN_R_N_S_STATUS_2 = "wikiPage.status = ?";
16806            private static final String _FINDER_COLUMN_G_N_H_GROUPID_2 = "wikiPage.groupId = ? AND ";
16807            private static final String _FINDER_COLUMN_G_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
16808            private static final String _FINDER_COLUMN_G_N_H_HEAD_2 = "wikiPage.head = ?";
16809            private static final String _FINDER_COLUMN_G_N_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
16810            private static final String _FINDER_COLUMN_G_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16811            private static final String _FINDER_COLUMN_G_N_S_STATUS_2 = "wikiPage.status = ?";
16812            private static final String _FINDER_COLUMN_U_N_S_USERID_2 = "wikiPage.userId = ? AND ";
16813            private static final String _FINDER_COLUMN_U_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16814            private static final String _FINDER_COLUMN_U_N_S_STATUS_2 = "wikiPage.status = ?";
16815            private static final String _FINDER_COLUMN_N_T_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
16816            private static final String _FINDER_COLUMN_N_T_V_TITLE_1 = "wikiPage.title IS NULL AND ";
16817            private static final String _FINDER_COLUMN_N_T_V_TITLE_2 = "lower(wikiPage.title) = lower(CAST_TEXT(?)) AND ";
16818            private static final String _FINDER_COLUMN_N_T_V_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(CAST_TEXT(?))) AND ";
16819            private static final String _FINDER_COLUMN_N_T_V_VERSION_2 = "wikiPage.version = ?";
16820            private static final String _FINDER_COLUMN_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
16821            private static final String _FINDER_COLUMN_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
16822            private static final String _FINDER_COLUMN_N_T_H_TITLE_2 = "lower(wikiPage.title) = lower(CAST_TEXT(?)) AND ";
16823            private static final String _FINDER_COLUMN_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(CAST_TEXT(?))) AND ";
16824            private static final String _FINDER_COLUMN_N_T_H_HEAD_2 = "wikiPage.head = ?";
16825            private static final String _FINDER_COLUMN_N_T_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16826            private static final String _FINDER_COLUMN_N_T_S_TITLE_1 = "wikiPage.title IS NULL AND ";
16827            private static final String _FINDER_COLUMN_N_T_S_TITLE_2 = "lower(wikiPage.title) = lower(CAST_TEXT(?)) AND ";
16828            private static final String _FINDER_COLUMN_N_T_S_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(CAST_TEXT(?))) AND ";
16829            private static final String _FINDER_COLUMN_N_T_S_STATUS_2 = "wikiPage.status = ?";
16830            private static final String _FINDER_COLUMN_N_H_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
16831            private static final String _FINDER_COLUMN_N_H_P_HEAD_2 = "wikiPage.head = ? AND ";
16832            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
16833            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = lower(CAST_TEXT(?))";
16834            private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR lower(wikiPage.parentTitle) = lower(CAST_TEXT(?)))";
16835            private static final String _FINDER_COLUMN_N_H_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16836            private static final String _FINDER_COLUMN_N_H_S_HEAD_2 = "wikiPage.head = ? AND ";
16837            private static final String _FINDER_COLUMN_N_H_S_STATUS_2 = "wikiPage.status = ?";
16838            private static final String _FINDER_COLUMN_G_U_N_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
16839            private static final String _FINDER_COLUMN_G_U_N_S_USERID_2 = "wikiPage.userId = ? AND ";
16840            private static final String _FINDER_COLUMN_G_U_N_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16841            private static final String _FINDER_COLUMN_G_U_N_S_STATUS_2 = "wikiPage.status = ?";
16842            private static final String _FINDER_COLUMN_G_N_T_H_GROUPID_2 = "wikiPage.groupId = ? AND ";
16843            private static final String _FINDER_COLUMN_G_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
16844            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
16845            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_2 = "lower(wikiPage.title) = lower(CAST_TEXT(?)) AND ";
16846            private static final String _FINDER_COLUMN_G_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR lower(wikiPage.title) = lower(CAST_TEXT(?))) AND ";
16847            private static final String _FINDER_COLUMN_G_N_T_H_HEAD_2 = "wikiPage.head = ?";
16848            private static final String _FINDER_COLUMN_G_N_H_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
16849            private static final String _FINDER_COLUMN_G_N_H_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16850            private static final String _FINDER_COLUMN_G_N_H_S_HEAD_2 = "wikiPage.head = ? AND ";
16851            private static final String _FINDER_COLUMN_G_N_H_S_STATUS_2 = "wikiPage.status = ?";
16852            private static final String _FINDER_COLUMN_N_H_P_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16853            private static final String _FINDER_COLUMN_N_H_P_S_HEAD_2 = "wikiPage.head = ? AND ";
16854            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL AND ";
16855            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = lower(CAST_TEXT(?)) AND ";
16856            private static final String _FINDER_COLUMN_N_H_P_S_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR lower(wikiPage.parentTitle) = lower(CAST_TEXT(?))) AND ";
16857            private static final String _FINDER_COLUMN_N_H_P_S_STATUS_2 = "wikiPage.status = ?";
16858            private static final String _FINDER_COLUMN_G_N_H_P_S_GROUPID_2 = "wikiPage.groupId = ? AND ";
16859            private static final String _FINDER_COLUMN_G_N_H_P_S_NODEID_2 = "wikiPage.nodeId = ? AND ";
16860            private static final String _FINDER_COLUMN_G_N_H_P_S_HEAD_2 = "wikiPage.head = ? AND ";
16861            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL AND ";
16862            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_2 = "lower(wikiPage.parentTitle) = lower(CAST_TEXT(?)) AND ";
16863            private static final String _FINDER_COLUMN_G_N_H_P_S_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR lower(wikiPage.parentTitle) = lower(CAST_TEXT(?))) AND ";
16864            private static final String _FINDER_COLUMN_G_N_H_P_S_STATUS_2 = "wikiPage.status = ?";
16865            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "wikiPage.resourcePrimKey";
16866            private static final String _FILTER_SQL_SELECT_WIKIPAGE_WHERE = "SELECT DISTINCT {wikiPage.*} FROM WikiPage wikiPage WHERE ";
16867            private static final String _FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_1 =
16868                    "SELECT {WikiPage.*} FROM (SELECT DISTINCT wikiPage.pageId FROM WikiPage wikiPage WHERE ";
16869            private static final String _FILTER_SQL_SELECT_WIKIPAGE_NO_INLINE_DISTINCT_WHERE_2 =
16870                    ") TEMP_TABLE INNER JOIN WikiPage ON TEMP_TABLE.pageId = WikiPage.pageId";
16871            private static final String _FILTER_SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(DISTINCT wikiPage.pageId) AS COUNT_VALUE FROM WikiPage wikiPage WHERE ";
16872            private static final String _FILTER_ENTITY_ALIAS = "wikiPage";
16873            private static final String _FILTER_ENTITY_TABLE = "WikiPage";
16874            private static final String _ORDER_BY_ENTITY_ALIAS = "wikiPage.";
16875            private static final String _ORDER_BY_ENTITY_TABLE = "WikiPage.";
16876            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiPage exists with the primary key ";
16877            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiPage exists with the key {";
16878            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
16879            private static Log _log = LogFactoryUtil.getLog(WikiPagePersistenceImpl.class);
16880            private static WikiPage _nullWikiPage = new WikiPageImpl() {
16881                            @Override
16882                            public Object clone() {
16883                                    return this;
16884                            }
16885    
16886                            @Override
16887                            public CacheModel<WikiPage> toCacheModel() {
16888                                    return _nullWikiPageCacheModel;
16889                            }
16890                    };
16891    
16892            private static CacheModel<WikiPage> _nullWikiPageCacheModel = new CacheModel<WikiPage>() {
16893                            public WikiPage toEntityModel() {
16894                                    return _nullWikiPage;
16895                            }
16896                    };
16897    }