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