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