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