1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.wiki.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.kernel.annotation.BeanReference;
19  import com.liferay.portal.kernel.cache.CacheRegistry;
20  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
21  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderPath;
24  import com.liferay.portal.kernel.dao.orm.Query;
25  import com.liferay.portal.kernel.dao.orm.QueryPos;
26  import com.liferay.portal.kernel.dao.orm.QueryUtil;
27  import com.liferay.portal.kernel.dao.orm.Session;
28  import com.liferay.portal.kernel.exception.SystemException;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.OrderByComparator;
33  import com.liferay.portal.kernel.util.StringBundler;
34  import com.liferay.portal.kernel.util.StringPool;
35  import com.liferay.portal.kernel.util.StringUtil;
36  import com.liferay.portal.kernel.util.Validator;
37  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
38  import com.liferay.portal.model.ModelListener;
39  import com.liferay.portal.service.persistence.BatchSessionUtil;
40  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41  
42  import com.liferay.portlet.wiki.NoSuchPageException;
43  import com.liferay.portlet.wiki.model.WikiPage;
44  import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
45  import com.liferay.portlet.wiki.model.impl.WikiPageModelImpl;
46  
47  import java.io.Serializable;
48  
49  import java.util.ArrayList;
50  import java.util.Collections;
51  import java.util.List;
52  
53  /**
54   * <a href="WikiPagePersistenceImpl.java.html"><b><i>View Source</i></b></a>
55   *
56   * <p>
57   * ServiceBuilder generated this class. Modifications in this class will be
58   * overwritten the next time is generated.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       WikiPagePersistence
63   * @see       WikiPageUtil
64   * @generated
65   */
66  public class WikiPagePersistenceImpl extends BasePersistenceImpl<WikiPage>
67      implements WikiPagePersistence {
68      public static final String FINDER_CLASS_NAME_ENTITY = WikiPageImpl.class.getName();
69      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
70          ".List";
71      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
72              WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
73              "findByUuid", new String[] { String.class.getName() });
74      public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
75              WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
76              "findByUuid",
77              new String[] {
78                  String.class.getName(),
79                  
80              "java.lang.Integer", "java.lang.Integer",
81                  "com.liferay.portal.kernel.util.OrderByComparator"
82              });
83      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
84              WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85              "countByUuid", new String[] { String.class.getName() });
86      public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
87              WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
88              "fetchByUUID_G",
89              new String[] { String.class.getName(), Long.class.getName() });
90      public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
91              WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
92              "countByUUID_G",
93              new String[] { String.class.getName(), Long.class.getName() });
94      public static final FinderPath FINDER_PATH_FIND_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
95              WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96              "findByNodeId", new String[] { Long.class.getName() });
97      public static final FinderPath FINDER_PATH_FIND_BY_OBC_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
98              WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
99              "findByNodeId",
100             new String[] {
101                 Long.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_COUNT_BY_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
107             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108             "countByNodeId", new String[] { Long.class.getName() });
109     public static final FinderPath FINDER_PATH_FIND_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
110             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111             "findByFormat", new String[] { String.class.getName() });
112     public static final FinderPath FINDER_PATH_FIND_BY_OBC_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
113             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
114             "findByFormat",
115             new String[] {
116                 String.class.getName(),
117                 
118             "java.lang.Integer", "java.lang.Integer",
119                 "com.liferay.portal.kernel.util.OrderByComparator"
120             });
121     public static final FinderPath FINDER_PATH_COUNT_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
122             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
123             "countByFormat", new String[] { String.class.getName() });
124     public static final FinderPath FINDER_PATH_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
125             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
126             "findByN_T",
127             new String[] { Long.class.getName(), String.class.getName() });
128     public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
129             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
130             "findByN_T",
131             new String[] {
132                 Long.class.getName(), String.class.getName(),
133                 
134             "java.lang.Integer", "java.lang.Integer",
135                 "com.liferay.portal.kernel.util.OrderByComparator"
136             });
137     public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
138             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
139             "countByN_T",
140             new String[] { Long.class.getName(), String.class.getName() });
141     public static final FinderPath FINDER_PATH_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
142             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
143             "findByN_H",
144             new String[] { Long.class.getName(), Boolean.class.getName() });
145     public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
146             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
147             "findByN_H",
148             new String[] {
149                 Long.class.getName(), Boolean.class.getName(),
150                 
151             "java.lang.Integer", "java.lang.Integer",
152                 "com.liferay.portal.kernel.util.OrderByComparator"
153             });
154     public static final FinderPath FINDER_PATH_COUNT_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
155             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
156             "countByN_H",
157             new String[] { Long.class.getName(), Boolean.class.getName() });
158     public static final FinderPath FINDER_PATH_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
159             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
160             "findByN_P",
161             new String[] { Long.class.getName(), String.class.getName() });
162     public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
163             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
164             "findByN_P",
165             new String[] {
166                 Long.class.getName(), String.class.getName(),
167                 
168             "java.lang.Integer", "java.lang.Integer",
169                 "com.liferay.portal.kernel.util.OrderByComparator"
170             });
171     public static final FinderPath FINDER_PATH_COUNT_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
172             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
173             "countByN_P",
174             new String[] { Long.class.getName(), String.class.getName() });
175     public static final FinderPath FINDER_PATH_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
176             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
177             "findByN_R",
178             new String[] { Long.class.getName(), String.class.getName() });
179     public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
180             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
181             "findByN_R",
182             new String[] {
183                 Long.class.getName(), String.class.getName(),
184                 
185             "java.lang.Integer", "java.lang.Integer",
186                 "com.liferay.portal.kernel.util.OrderByComparator"
187             });
188     public static final FinderPath FINDER_PATH_COUNT_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
189             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
190             "countByN_R",
191             new String[] { Long.class.getName(), String.class.getName() });
192     public static final FinderPath FINDER_PATH_FETCH_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
193             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
194             "fetchByN_T_V",
195             new String[] {
196                 Long.class.getName(), String.class.getName(),
197                 Double.class.getName()
198             });
199     public static final FinderPath FINDER_PATH_COUNT_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
200             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
201             "countByN_T_V",
202             new String[] {
203                 Long.class.getName(), String.class.getName(),
204                 Double.class.getName()
205             });
206     public static final FinderPath FINDER_PATH_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
207             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
208             "findByN_T_H",
209             new String[] {
210                 Long.class.getName(), String.class.getName(),
211                 Boolean.class.getName()
212             });
213     public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
214             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
215             "findByN_T_H",
216             new String[] {
217                 Long.class.getName(), String.class.getName(),
218                 Boolean.class.getName(),
219                 
220             "java.lang.Integer", "java.lang.Integer",
221                 "com.liferay.portal.kernel.util.OrderByComparator"
222             });
223     public static final FinderPath FINDER_PATH_COUNT_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
224             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
225             "countByN_T_H",
226             new String[] {
227                 Long.class.getName(), String.class.getName(),
228                 Boolean.class.getName()
229             });
230     public static final FinderPath FINDER_PATH_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
231             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
232             "findByN_H_P",
233             new String[] {
234                 Long.class.getName(), Boolean.class.getName(),
235                 String.class.getName()
236             });
237     public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
238             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
239             "findByN_H_P",
240             new String[] {
241                 Long.class.getName(), Boolean.class.getName(),
242                 String.class.getName(),
243                 
244             "java.lang.Integer", "java.lang.Integer",
245                 "com.liferay.portal.kernel.util.OrderByComparator"
246             });
247     public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
248             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
249             "countByN_H_P",
250             new String[] {
251                 Long.class.getName(), Boolean.class.getName(),
252                 String.class.getName()
253             });
254     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
255             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
256             "findAll", new String[0]);
257     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
258             WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
259             "countAll", new String[0]);
260 
261     public void cacheResult(WikiPage wikiPage) {
262         EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
263             WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
264 
265         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
266             new Object[] { wikiPage.getUuid(), new Long(wikiPage.getGroupId()) },
267             wikiPage);
268 
269         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
270             new Object[] {
271                 new Long(wikiPage.getNodeId()),
272                 
273             wikiPage.getTitle(), new Double(wikiPage.getVersion())
274             }, wikiPage);
275     }
276 
277     public void cacheResult(List<WikiPage> wikiPages) {
278         for (WikiPage wikiPage : wikiPages) {
279             if (EntityCacheUtil.getResult(
280                         WikiPageModelImpl.ENTITY_CACHE_ENABLED,
281                         WikiPageImpl.class, wikiPage.getPrimaryKey(), this) == null) {
282                 cacheResult(wikiPage);
283             }
284         }
285     }
286 
287     public void clearCache() {
288         CacheRegistry.clear(WikiPageImpl.class.getName());
289         EntityCacheUtil.clearCache(WikiPageImpl.class.getName());
290         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
291         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
292     }
293 
294     public WikiPage create(long pageId) {
295         WikiPage wikiPage = new WikiPageImpl();
296 
297         wikiPage.setNew(true);
298         wikiPage.setPrimaryKey(pageId);
299 
300         String uuid = PortalUUIDUtil.generate();
301 
302         wikiPage.setUuid(uuid);
303 
304         return wikiPage;
305     }
306 
307     public WikiPage remove(Serializable primaryKey)
308         throws NoSuchModelException, SystemException {
309         return remove(((Long)primaryKey).longValue());
310     }
311 
312     public WikiPage remove(long pageId)
313         throws NoSuchPageException, SystemException {
314         Session session = null;
315 
316         try {
317             session = openSession();
318 
319             WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
320                     new Long(pageId));
321 
322             if (wikiPage == null) {
323                 if (_log.isWarnEnabled()) {
324                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + pageId);
325                 }
326 
327                 throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
328                     pageId);
329             }
330 
331             return remove(wikiPage);
332         }
333         catch (NoSuchPageException nsee) {
334             throw nsee;
335         }
336         catch (Exception e) {
337             throw processException(e);
338         }
339         finally {
340             closeSession(session);
341         }
342     }
343 
344     public WikiPage remove(WikiPage wikiPage) throws SystemException {
345         for (ModelListener<WikiPage> listener : listeners) {
346             listener.onBeforeRemove(wikiPage);
347         }
348 
349         wikiPage = removeImpl(wikiPage);
350 
351         for (ModelListener<WikiPage> listener : listeners) {
352             listener.onAfterRemove(wikiPage);
353         }
354 
355         return wikiPage;
356     }
357 
358     protected WikiPage removeImpl(WikiPage wikiPage) throws SystemException {
359         wikiPage = toUnwrappedModel(wikiPage);
360 
361         Session session = null;
362 
363         try {
364             session = openSession();
365 
366             if (wikiPage.isCachedModel() || BatchSessionUtil.isEnabled()) {
367                 Object staleObject = session.get(WikiPageImpl.class,
368                         wikiPage.getPrimaryKeyObj());
369 
370                 if (staleObject != null) {
371                     session.evict(staleObject);
372                 }
373             }
374 
375             session.delete(wikiPage);
376 
377             session.flush();
378         }
379         catch (Exception e) {
380             throw processException(e);
381         }
382         finally {
383             closeSession(session);
384         }
385 
386         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
387 
388         WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
389 
390         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
391             new Object[] {
392                 wikiPageModelImpl.getOriginalUuid(),
393                 new Long(wikiPageModelImpl.getOriginalGroupId())
394             });
395 
396         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
397             new Object[] {
398                 new Long(wikiPageModelImpl.getOriginalNodeId()),
399                 
400             wikiPageModelImpl.getOriginalTitle(),
401                 new Double(wikiPageModelImpl.getOriginalVersion())
402             });
403 
404         EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
405             WikiPageImpl.class, wikiPage.getPrimaryKey());
406 
407         return wikiPage;
408     }
409 
410     public WikiPage updateImpl(
411         com.liferay.portlet.wiki.model.WikiPage wikiPage, boolean merge)
412         throws SystemException {
413         wikiPage = toUnwrappedModel(wikiPage);
414 
415         boolean isNew = wikiPage.isNew();
416 
417         WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
418 
419         if (Validator.isNull(wikiPage.getUuid())) {
420             String uuid = PortalUUIDUtil.generate();
421 
422             wikiPage.setUuid(uuid);
423         }
424 
425         Session session = null;
426 
427         try {
428             session = openSession();
429 
430             BatchSessionUtil.update(session, wikiPage, merge);
431 
432             wikiPage.setNew(false);
433         }
434         catch (Exception e) {
435             throw processException(e);
436         }
437         finally {
438             closeSession(session);
439         }
440 
441         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
442 
443         EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
444             WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
445 
446         if (!isNew &&
447                 (!Validator.equals(wikiPage.getUuid(),
448                     wikiPageModelImpl.getOriginalUuid()) ||
449                 (wikiPage.getGroupId() != wikiPageModelImpl.getOriginalGroupId()))) {
450             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
451                 new Object[] {
452                     wikiPageModelImpl.getOriginalUuid(),
453                     new Long(wikiPageModelImpl.getOriginalGroupId())
454                 });
455         }
456 
457         if (isNew ||
458                 (!Validator.equals(wikiPage.getUuid(),
459                     wikiPageModelImpl.getOriginalUuid()) ||
460                 (wikiPage.getGroupId() != wikiPageModelImpl.getOriginalGroupId()))) {
461             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
462                 new Object[] { wikiPage.getUuid(), new Long(
463                         wikiPage.getGroupId()) }, wikiPage);
464         }
465 
466         if (!isNew &&
467                 ((wikiPage.getNodeId() != wikiPageModelImpl.getOriginalNodeId()) ||
468                 !Validator.equals(wikiPage.getTitle(),
469                     wikiPageModelImpl.getOriginalTitle()) ||
470                 (wikiPage.getVersion() != wikiPageModelImpl.getOriginalVersion()))) {
471             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
472                 new Object[] {
473                     new Long(wikiPageModelImpl.getOriginalNodeId()),
474                     
475                 wikiPageModelImpl.getOriginalTitle(),
476                     new Double(wikiPageModelImpl.getOriginalVersion())
477                 });
478         }
479 
480         if (isNew ||
481                 ((wikiPage.getNodeId() != wikiPageModelImpl.getOriginalNodeId()) ||
482                 !Validator.equals(wikiPage.getTitle(),
483                     wikiPageModelImpl.getOriginalTitle()) ||
484                 (wikiPage.getVersion() != wikiPageModelImpl.getOriginalVersion()))) {
485             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
486                 new Object[] {
487                     new Long(wikiPage.getNodeId()),
488                     
489                 wikiPage.getTitle(), new Double(wikiPage.getVersion())
490                 }, wikiPage);
491         }
492 
493         return wikiPage;
494     }
495 
496     protected WikiPage toUnwrappedModel(WikiPage wikiPage) {
497         if (wikiPage instanceof WikiPageImpl) {
498             return wikiPage;
499         }
500 
501         WikiPageImpl wikiPageImpl = new WikiPageImpl();
502 
503         wikiPageImpl.setNew(wikiPage.isNew());
504         wikiPageImpl.setPrimaryKey(wikiPage.getPrimaryKey());
505 
506         wikiPageImpl.setUuid(wikiPage.getUuid());
507         wikiPageImpl.setPageId(wikiPage.getPageId());
508         wikiPageImpl.setResourcePrimKey(wikiPage.getResourcePrimKey());
509         wikiPageImpl.setGroupId(wikiPage.getGroupId());
510         wikiPageImpl.setCompanyId(wikiPage.getCompanyId());
511         wikiPageImpl.setUserId(wikiPage.getUserId());
512         wikiPageImpl.setUserName(wikiPage.getUserName());
513         wikiPageImpl.setCreateDate(wikiPage.getCreateDate());
514         wikiPageImpl.setModifiedDate(wikiPage.getModifiedDate());
515         wikiPageImpl.setNodeId(wikiPage.getNodeId());
516         wikiPageImpl.setTitle(wikiPage.getTitle());
517         wikiPageImpl.setVersion(wikiPage.getVersion());
518         wikiPageImpl.setMinorEdit(wikiPage.isMinorEdit());
519         wikiPageImpl.setContent(wikiPage.getContent());
520         wikiPageImpl.setStatus(wikiPage.getStatus());
521         wikiPageImpl.setStatusByUserId(wikiPage.getStatusByUserId());
522         wikiPageImpl.setStatusByUserName(wikiPage.getStatusByUserName());
523         wikiPageImpl.setStatusDate(wikiPage.getStatusDate());
524         wikiPageImpl.setSummary(wikiPage.getSummary());
525         wikiPageImpl.setFormat(wikiPage.getFormat());
526         wikiPageImpl.setHead(wikiPage.isHead());
527         wikiPageImpl.setParentTitle(wikiPage.getParentTitle());
528         wikiPageImpl.setRedirectTitle(wikiPage.getRedirectTitle());
529 
530         return wikiPageImpl;
531     }
532 
533     public WikiPage findByPrimaryKey(Serializable primaryKey)
534         throws NoSuchModelException, SystemException {
535         return findByPrimaryKey(((Long)primaryKey).longValue());
536     }
537 
538     public WikiPage findByPrimaryKey(long pageId)
539         throws NoSuchPageException, SystemException {
540         WikiPage wikiPage = fetchByPrimaryKey(pageId);
541 
542         if (wikiPage == null) {
543             if (_log.isWarnEnabled()) {
544                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + pageId);
545             }
546 
547             throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
548                 pageId);
549         }
550 
551         return wikiPage;
552     }
553 
554     public WikiPage fetchByPrimaryKey(Serializable primaryKey)
555         throws SystemException {
556         return fetchByPrimaryKey(((Long)primaryKey).longValue());
557     }
558 
559     public WikiPage fetchByPrimaryKey(long pageId) throws SystemException {
560         WikiPage wikiPage = (WikiPage)EntityCacheUtil.getResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
561                 WikiPageImpl.class, pageId, this);
562 
563         if (wikiPage == null) {
564             Session session = null;
565 
566             try {
567                 session = openSession();
568 
569                 wikiPage = (WikiPage)session.get(WikiPageImpl.class,
570                         new Long(pageId));
571             }
572             catch (Exception e) {
573                 throw processException(e);
574             }
575             finally {
576                 if (wikiPage != null) {
577                     cacheResult(wikiPage);
578                 }
579 
580                 closeSession(session);
581             }
582         }
583 
584         return wikiPage;
585     }
586 
587     public List<WikiPage> findByUuid(String uuid) throws SystemException {
588         Object[] finderArgs = new Object[] { uuid };
589 
590         List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
591                 finderArgs, this);
592 
593         if (list == null) {
594             Session session = null;
595 
596             try {
597                 session = openSession();
598 
599                 StringBundler query = new StringBundler(3);
600 
601                 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
602 
603                 if (uuid == null) {
604                     query.append(_FINDER_COLUMN_UUID_UUID_1);
605                 }
606                 else {
607                     if (uuid.equals(StringPool.BLANK)) {
608                         query.append(_FINDER_COLUMN_UUID_UUID_3);
609                     }
610                     else {
611                         query.append(_FINDER_COLUMN_UUID_UUID_2);
612                     }
613                 }
614 
615                 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
616 
617                 String sql = query.toString();
618 
619                 Query q = session.createQuery(sql);
620 
621                 QueryPos qPos = QueryPos.getInstance(q);
622 
623                 if (uuid != null) {
624                     qPos.add(uuid);
625                 }
626 
627                 list = q.list();
628             }
629             catch (Exception e) {
630                 throw processException(e);
631             }
632             finally {
633                 if (list == null) {
634                     list = new ArrayList<WikiPage>();
635                 }
636 
637                 cacheResult(list);
638 
639                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
640                     list);
641 
642                 closeSession(session);
643             }
644         }
645 
646         return list;
647     }
648 
649     public List<WikiPage> findByUuid(String uuid, int start, int end)
650         throws SystemException {
651         return findByUuid(uuid, start, end, null);
652     }
653 
654     public List<WikiPage> findByUuid(String uuid, int start, int end,
655         OrderByComparator obc) throws SystemException {
656         Object[] finderArgs = new Object[] {
657                 uuid,
658                 
659                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
660             };
661 
662         List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
663                 finderArgs, this);
664 
665         if (list == null) {
666             Session session = null;
667 
668             try {
669                 session = openSession();
670 
671                 StringBundler query = null;
672 
673                 if (obc != null) {
674                     query = new StringBundler(3 +
675                             (obc.getOrderByFields().length * 3));
676                 }
677                 else {
678                     query = new StringBundler(3);
679                 }
680 
681                 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
682 
683                 if (uuid == null) {
684                     query.append(_FINDER_COLUMN_UUID_UUID_1);
685                 }
686                 else {
687                     if (uuid.equals(StringPool.BLANK)) {
688                         query.append(_FINDER_COLUMN_UUID_UUID_3);
689                     }
690                     else {
691                         query.append(_FINDER_COLUMN_UUID_UUID_2);
692                     }
693                 }
694 
695                 if (obc != null) {
696                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
697                 }
698 
699                 else {
700                     query.append(WikiPageModelImpl.ORDER_BY_JPQL);
701                 }
702 
703                 String sql = query.toString();
704 
705                 Query q = session.createQuery(sql);
706 
707                 QueryPos qPos = QueryPos.getInstance(q);
708 
709                 if (uuid != null) {
710                     qPos.add(uuid);
711                 }
712 
713                 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
714                         end);
715             }
716             catch (Exception e) {
717                 throw processException(e);
718             }
719             finally {
720                 if (list == null) {
721                     list = new ArrayList<WikiPage>();
722                 }
723 
724                 cacheResult(list);
725 
726                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
727                     finderArgs, list);
728 
729                 closeSession(session);
730             }
731         }
732 
733         return list;
734     }
735 
736     public WikiPage findByUuid_First(String uuid, OrderByComparator obc)
737         throws NoSuchPageException, SystemException {
738         List<WikiPage> list = findByUuid(uuid, 0, 1, obc);
739 
740         if (list.isEmpty()) {
741             StringBundler msg = new StringBundler(4);
742 
743             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
744 
745             msg.append("uuid=");
746             msg.append(uuid);
747 
748             msg.append(StringPool.CLOSE_CURLY_BRACE);
749 
750             throw new NoSuchPageException(msg.toString());
751         }
752         else {
753             return list.get(0);
754         }
755     }
756 
757     public WikiPage findByUuid_Last(String uuid, OrderByComparator obc)
758         throws NoSuchPageException, SystemException {
759         int count = countByUuid(uuid);
760 
761         List<WikiPage> list = findByUuid(uuid, count - 1, count, obc);
762 
763         if (list.isEmpty()) {
764             StringBundler msg = new StringBundler(4);
765 
766             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
767 
768             msg.append("uuid=");
769             msg.append(uuid);
770 
771             msg.append(StringPool.CLOSE_CURLY_BRACE);
772 
773             throw new NoSuchPageException(msg.toString());
774         }
775         else {
776             return list.get(0);
777         }
778     }
779 
780     public WikiPage[] findByUuid_PrevAndNext(long pageId, String uuid,
781         OrderByComparator obc) throws NoSuchPageException, SystemException {
782         WikiPage wikiPage = findByPrimaryKey(pageId);
783 
784         int count = countByUuid(uuid);
785 
786         Session session = null;
787 
788         try {
789             session = openSession();
790 
791             StringBundler query = null;
792 
793             if (obc != null) {
794                 query = new StringBundler(3 +
795                         (obc.getOrderByFields().length * 3));
796             }
797             else {
798                 query = new StringBundler(3);
799             }
800 
801             query.append(_SQL_SELECT_WIKIPAGE_WHERE);
802 
803             if (uuid == null) {
804                 query.append(_FINDER_COLUMN_UUID_UUID_1);
805             }
806             else {
807                 if (uuid.equals(StringPool.BLANK)) {
808                     query.append(_FINDER_COLUMN_UUID_UUID_3);
809                 }
810                 else {
811                     query.append(_FINDER_COLUMN_UUID_UUID_2);
812                 }
813             }
814 
815             if (obc != null) {
816                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
817             }
818 
819             else {
820                 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
821             }
822 
823             String sql = query.toString();
824 
825             Query q = session.createQuery(sql);
826 
827             QueryPos qPos = QueryPos.getInstance(q);
828 
829             if (uuid != null) {
830                 qPos.add(uuid);
831             }
832 
833             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
834 
835             WikiPage[] array = new WikiPageImpl[3];
836 
837             array[0] = (WikiPage)objArray[0];
838             array[1] = (WikiPage)objArray[1];
839             array[2] = (WikiPage)objArray[2];
840 
841             return array;
842         }
843         catch (Exception e) {
844             throw processException(e);
845         }
846         finally {
847             closeSession(session);
848         }
849     }
850 
851     public WikiPage findByUUID_G(String uuid, long groupId)
852         throws NoSuchPageException, SystemException {
853         WikiPage wikiPage = fetchByUUID_G(uuid, groupId);
854 
855         if (wikiPage == null) {
856             StringBundler msg = new StringBundler(6);
857 
858             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
859 
860             msg.append("uuid=");
861             msg.append(uuid);
862 
863             msg.append(", groupId=");
864             msg.append(groupId);
865 
866             msg.append(StringPool.CLOSE_CURLY_BRACE);
867 
868             if (_log.isWarnEnabled()) {
869                 _log.warn(msg.toString());
870             }
871 
872             throw new NoSuchPageException(msg.toString());
873         }
874 
875         return wikiPage;
876     }
877 
878     public WikiPage fetchByUUID_G(String uuid, long groupId)
879         throws SystemException {
880         return fetchByUUID_G(uuid, groupId, true);
881     }
882 
883     public WikiPage fetchByUUID_G(String uuid, long groupId,
884         boolean retrieveFromCache) throws SystemException {
885         Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
886 
887         Object result = null;
888 
889         if (retrieveFromCache) {
890             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
891                     finderArgs, this);
892         }
893 
894         if (result == null) {
895             Session session = null;
896 
897             try {
898                 session = openSession();
899 
900                 StringBundler query = new StringBundler(4);
901 
902                 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
903 
904                 if (uuid == null) {
905                     query.append(_FINDER_COLUMN_UUID_G_UUID_1);
906                 }
907                 else {
908                     if (uuid.equals(StringPool.BLANK)) {
909                         query.append(_FINDER_COLUMN_UUID_G_UUID_3);
910                     }
911                     else {
912                         query.append(_FINDER_COLUMN_UUID_G_UUID_2);
913                     }
914                 }
915 
916                 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
917 
918                 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
919 
920                 String sql = query.toString();
921 
922                 Query q = session.createQuery(sql);
923 
924                 QueryPos qPos = QueryPos.getInstance(q);
925 
926                 if (uuid != null) {
927                     qPos.add(uuid);
928                 }
929 
930                 qPos.add(groupId);
931 
932                 List<WikiPage> list = q.list();
933 
934                 result = list;
935 
936                 WikiPage wikiPage = null;
937 
938                 if (list.isEmpty()) {
939                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
940                         finderArgs, list);
941                 }
942                 else {
943                     wikiPage = list.get(0);
944 
945                     cacheResult(wikiPage);
946 
947                     if ((wikiPage.getUuid() == null) ||
948                             !wikiPage.getUuid().equals(uuid) ||
949                             (wikiPage.getGroupId() != groupId)) {
950                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
951                             finderArgs, wikiPage);
952                     }
953                 }
954 
955                 return wikiPage;
956             }
957             catch (Exception e) {
958                 throw processException(e);
959             }
960             finally {
961                 if (result == null) {
962                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
963                         finderArgs, new ArrayList<WikiPage>());
964                 }
965 
966                 closeSession(session);
967             }
968         }
969         else {
970             if (result instanceof List<?>) {
971                 return null;
972             }
973             else {
974                 return (WikiPage)result;
975             }
976         }
977     }
978 
979     public List<WikiPage> findByNodeId(long nodeId) throws SystemException {
980         Object[] finderArgs = new Object[] { new Long(nodeId) };
981 
982         List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_NODEID,
983                 finderArgs, this);
984 
985         if (list == null) {
986             Session session = null;
987 
988             try {
989                 session = openSession();
990 
991                 StringBundler query = new StringBundler(3);
992 
993                 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
994 
995                 query.append(_FINDER_COLUMN_NODEID_NODEID_2);
996 
997                 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
998 
999                 String sql = query.toString();
1000
1001                Query q = session.createQuery(sql);
1002
1003                QueryPos qPos = QueryPos.getInstance(q);
1004
1005                qPos.add(nodeId);
1006
1007                list = q.list();
1008            }
1009            catch (Exception e) {
1010                throw processException(e);
1011            }
1012            finally {
1013                if (list == null) {
1014                    list = new ArrayList<WikiPage>();
1015                }
1016
1017                cacheResult(list);
1018
1019                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_NODEID,
1020                    finderArgs, list);
1021
1022                closeSession(session);
1023            }
1024        }
1025
1026        return list;
1027    }
1028
1029    public List<WikiPage> findByNodeId(long nodeId, int start, int end)
1030        throws SystemException {
1031        return findByNodeId(nodeId, start, end, null);
1032    }
1033
1034    public List<WikiPage> findByNodeId(long nodeId, int start, int end,
1035        OrderByComparator obc) throws SystemException {
1036        Object[] finderArgs = new Object[] {
1037                new Long(nodeId),
1038                
1039                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1040            };
1041
1042        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_NODEID,
1043                finderArgs, this);
1044
1045        if (list == null) {
1046            Session session = null;
1047
1048            try {
1049                session = openSession();
1050
1051                StringBundler query = null;
1052
1053                if (obc != null) {
1054                    query = new StringBundler(3 +
1055                            (obc.getOrderByFields().length * 3));
1056                }
1057                else {
1058                    query = new StringBundler(3);
1059                }
1060
1061                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1062
1063                query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1064
1065                if (obc != null) {
1066                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1067                }
1068
1069                else {
1070                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1071                }
1072
1073                String sql = query.toString();
1074
1075                Query q = session.createQuery(sql);
1076
1077                QueryPos qPos = QueryPos.getInstance(q);
1078
1079                qPos.add(nodeId);
1080
1081                list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1082                        end);
1083            }
1084            catch (Exception e) {
1085                throw processException(e);
1086            }
1087            finally {
1088                if (list == null) {
1089                    list = new ArrayList<WikiPage>();
1090                }
1091
1092                cacheResult(list);
1093
1094                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_NODEID,
1095                    finderArgs, list);
1096
1097                closeSession(session);
1098            }
1099        }
1100
1101        return list;
1102    }
1103
1104    public WikiPage findByNodeId_First(long nodeId, OrderByComparator obc)
1105        throws NoSuchPageException, SystemException {
1106        List<WikiPage> list = findByNodeId(nodeId, 0, 1, obc);
1107
1108        if (list.isEmpty()) {
1109            StringBundler msg = new StringBundler(4);
1110
1111            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1112
1113            msg.append("nodeId=");
1114            msg.append(nodeId);
1115
1116            msg.append(StringPool.CLOSE_CURLY_BRACE);
1117
1118            throw new NoSuchPageException(msg.toString());
1119        }
1120        else {
1121            return list.get(0);
1122        }
1123    }
1124
1125    public WikiPage findByNodeId_Last(long nodeId, OrderByComparator obc)
1126        throws NoSuchPageException, SystemException {
1127        int count = countByNodeId(nodeId);
1128
1129        List<WikiPage> list = findByNodeId(nodeId, count - 1, count, obc);
1130
1131        if (list.isEmpty()) {
1132            StringBundler msg = new StringBundler(4);
1133
1134            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1135
1136            msg.append("nodeId=");
1137            msg.append(nodeId);
1138
1139            msg.append(StringPool.CLOSE_CURLY_BRACE);
1140
1141            throw new NoSuchPageException(msg.toString());
1142        }
1143        else {
1144            return list.get(0);
1145        }
1146    }
1147
1148    public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
1149        OrderByComparator obc) throws NoSuchPageException, SystemException {
1150        WikiPage wikiPage = findByPrimaryKey(pageId);
1151
1152        int count = countByNodeId(nodeId);
1153
1154        Session session = null;
1155
1156        try {
1157            session = openSession();
1158
1159            StringBundler query = null;
1160
1161            if (obc != null) {
1162                query = new StringBundler(3 +
1163                        (obc.getOrderByFields().length * 3));
1164            }
1165            else {
1166                query = new StringBundler(3);
1167            }
1168
1169            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1170
1171            query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1172
1173            if (obc != null) {
1174                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1175            }
1176
1177            else {
1178                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1179            }
1180
1181            String sql = query.toString();
1182
1183            Query q = session.createQuery(sql);
1184
1185            QueryPos qPos = QueryPos.getInstance(q);
1186
1187            qPos.add(nodeId);
1188
1189            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1190
1191            WikiPage[] array = new WikiPageImpl[3];
1192
1193            array[0] = (WikiPage)objArray[0];
1194            array[1] = (WikiPage)objArray[1];
1195            array[2] = (WikiPage)objArray[2];
1196
1197            return array;
1198        }
1199        catch (Exception e) {
1200            throw processException(e);
1201        }
1202        finally {
1203            closeSession(session);
1204        }
1205    }
1206
1207    public List<WikiPage> findByFormat(String format) throws SystemException {
1208        Object[] finderArgs = new Object[] { format };
1209
1210        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FORMAT,
1211                finderArgs, this);
1212
1213        if (list == null) {
1214            Session session = null;
1215
1216            try {
1217                session = openSession();
1218
1219                StringBundler query = new StringBundler(3);
1220
1221                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1222
1223                if (format == null) {
1224                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
1225                }
1226                else {
1227                    if (format.equals(StringPool.BLANK)) {
1228                        query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
1229                    }
1230                    else {
1231                        query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
1232                    }
1233                }
1234
1235                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1236
1237                String sql = query.toString();
1238
1239                Query q = session.createQuery(sql);
1240
1241                QueryPos qPos = QueryPos.getInstance(q);
1242
1243                if (format != null) {
1244                    qPos.add(format);
1245                }
1246
1247                list = q.list();
1248            }
1249            catch (Exception e) {
1250                throw processException(e);
1251            }
1252            finally {
1253                if (list == null) {
1254                    list = new ArrayList<WikiPage>();
1255                }
1256
1257                cacheResult(list);
1258
1259                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FORMAT,
1260                    finderArgs, list);
1261
1262                closeSession(session);
1263            }
1264        }
1265
1266        return list;
1267    }
1268
1269    public List<WikiPage> findByFormat(String format, int start, int end)
1270        throws SystemException {
1271        return findByFormat(format, start, end, null);
1272    }
1273
1274    public List<WikiPage> findByFormat(String format, int start, int end,
1275        OrderByComparator obc) throws SystemException {
1276        Object[] finderArgs = new Object[] {
1277                format,
1278                
1279                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1280            };
1281
1282        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_FORMAT,
1283                finderArgs, this);
1284
1285        if (list == null) {
1286            Session session = null;
1287
1288            try {
1289                session = openSession();
1290
1291                StringBundler query = null;
1292
1293                if (obc != null) {
1294                    query = new StringBundler(3 +
1295                            (obc.getOrderByFields().length * 3));
1296                }
1297                else {
1298                    query = new StringBundler(3);
1299                }
1300
1301                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1302
1303                if (format == null) {
1304                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
1305                }
1306                else {
1307                    if (format.equals(StringPool.BLANK)) {
1308                        query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
1309                    }
1310                    else {
1311                        query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
1312                    }
1313                }
1314
1315                if (obc != null) {
1316                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1317                }
1318
1319                else {
1320                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1321                }
1322
1323                String sql = query.toString();
1324
1325                Query q = session.createQuery(sql);
1326
1327                QueryPos qPos = QueryPos.getInstance(q);
1328
1329                if (format != null) {
1330                    qPos.add(format);
1331                }
1332
1333                list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1334                        end);
1335            }
1336            catch (Exception e) {
1337                throw processException(e);
1338            }
1339            finally {
1340                if (list == null) {
1341                    list = new ArrayList<WikiPage>();
1342                }
1343
1344                cacheResult(list);
1345
1346                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_FORMAT,
1347                    finderArgs, list);
1348
1349                closeSession(session);
1350            }
1351        }
1352
1353        return list;
1354    }
1355
1356    public WikiPage findByFormat_First(String format, OrderByComparator obc)
1357        throws NoSuchPageException, SystemException {
1358        List<WikiPage> list = findByFormat(format, 0, 1, obc);
1359
1360        if (list.isEmpty()) {
1361            StringBundler msg = new StringBundler(4);
1362
1363            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1364
1365            msg.append("format=");
1366            msg.append(format);
1367
1368            msg.append(StringPool.CLOSE_CURLY_BRACE);
1369
1370            throw new NoSuchPageException(msg.toString());
1371        }
1372        else {
1373            return list.get(0);
1374        }
1375    }
1376
1377    public WikiPage findByFormat_Last(String format, OrderByComparator obc)
1378        throws NoSuchPageException, SystemException {
1379        int count = countByFormat(format);
1380
1381        List<WikiPage> list = findByFormat(format, count - 1, count, obc);
1382
1383        if (list.isEmpty()) {
1384            StringBundler msg = new StringBundler(4);
1385
1386            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1387
1388            msg.append("format=");
1389            msg.append(format);
1390
1391            msg.append(StringPool.CLOSE_CURLY_BRACE);
1392
1393            throw new NoSuchPageException(msg.toString());
1394        }
1395        else {
1396            return list.get(0);
1397        }
1398    }
1399
1400    public WikiPage[] findByFormat_PrevAndNext(long pageId, String format,
1401        OrderByComparator obc) throws NoSuchPageException, SystemException {
1402        WikiPage wikiPage = findByPrimaryKey(pageId);
1403
1404        int count = countByFormat(format);
1405
1406        Session session = null;
1407
1408        try {
1409            session = openSession();
1410
1411            StringBundler query = null;
1412
1413            if (obc != null) {
1414                query = new StringBundler(3 +
1415                        (obc.getOrderByFields().length * 3));
1416            }
1417            else {
1418                query = new StringBundler(3);
1419            }
1420
1421            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1422
1423            if (format == null) {
1424                query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
1425            }
1426            else {
1427                if (format.equals(StringPool.BLANK)) {
1428                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
1429                }
1430                else {
1431                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
1432                }
1433            }
1434
1435            if (obc != null) {
1436                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1437            }
1438
1439            else {
1440                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1441            }
1442
1443            String sql = query.toString();
1444
1445            Query q = session.createQuery(sql);
1446
1447            QueryPos qPos = QueryPos.getInstance(q);
1448
1449            if (format != null) {
1450                qPos.add(format);
1451            }
1452
1453            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1454
1455            WikiPage[] array = new WikiPageImpl[3];
1456
1457            array[0] = (WikiPage)objArray[0];
1458            array[1] = (WikiPage)objArray[1];
1459            array[2] = (WikiPage)objArray[2];
1460
1461            return array;
1462        }
1463        catch (Exception e) {
1464            throw processException(e);
1465        }
1466        finally {
1467            closeSession(session);
1468        }
1469    }
1470
1471    public List<WikiPage> findByN_T(long nodeId, String title)
1472        throws SystemException {
1473        Object[] finderArgs = new Object[] { new Long(nodeId), title };
1474
1475        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_T,
1476                finderArgs, this);
1477
1478        if (list == null) {
1479            Session session = null;
1480
1481            try {
1482                session = openSession();
1483
1484                StringBundler query = new StringBundler(4);
1485
1486                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1487
1488                query.append(_FINDER_COLUMN_N_T_NODEID_2);
1489
1490                if (title == null) {
1491                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
1492                }
1493                else {
1494                    if (title.equals(StringPool.BLANK)) {
1495                        query.append(_FINDER_COLUMN_N_T_TITLE_3);
1496                    }
1497                    else {
1498                        query.append(_FINDER_COLUMN_N_T_TITLE_2);
1499                    }
1500                }
1501
1502                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1503
1504                String sql = query.toString();
1505
1506                Query q = session.createQuery(sql);
1507
1508                QueryPos qPos = QueryPos.getInstance(q);
1509
1510                qPos.add(nodeId);
1511
1512                if (title != null) {
1513                    qPos.add(title);
1514                }
1515
1516                list = q.list();
1517            }
1518            catch (Exception e) {
1519                throw processException(e);
1520            }
1521            finally {
1522                if (list == null) {
1523                    list = new ArrayList<WikiPage>();
1524                }
1525
1526                cacheResult(list);
1527
1528                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_T, finderArgs,
1529                    list);
1530
1531                closeSession(session);
1532            }
1533        }
1534
1535        return list;
1536    }
1537
1538    public List<WikiPage> findByN_T(long nodeId, String title, int start,
1539        int end) throws SystemException {
1540        return findByN_T(nodeId, title, start, end, null);
1541    }
1542
1543    public List<WikiPage> findByN_T(long nodeId, String title, int start,
1544        int end, OrderByComparator obc) throws SystemException {
1545        Object[] finderArgs = new Object[] {
1546                new Long(nodeId),
1547                
1548                title,
1549                
1550                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1551            };
1552
1553        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_T,
1554                finderArgs, this);
1555
1556        if (list == null) {
1557            Session session = null;
1558
1559            try {
1560                session = openSession();
1561
1562                StringBundler query = null;
1563
1564                if (obc != null) {
1565                    query = new StringBundler(4 +
1566                            (obc.getOrderByFields().length * 3));
1567                }
1568                else {
1569                    query = new StringBundler(4);
1570                }
1571
1572                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1573
1574                query.append(_FINDER_COLUMN_N_T_NODEID_2);
1575
1576                if (title == null) {
1577                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
1578                }
1579                else {
1580                    if (title.equals(StringPool.BLANK)) {
1581                        query.append(_FINDER_COLUMN_N_T_TITLE_3);
1582                    }
1583                    else {
1584                        query.append(_FINDER_COLUMN_N_T_TITLE_2);
1585                    }
1586                }
1587
1588                if (obc != null) {
1589                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1590                }
1591
1592                else {
1593                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1594                }
1595
1596                String sql = query.toString();
1597
1598                Query q = session.createQuery(sql);
1599
1600                QueryPos qPos = QueryPos.getInstance(q);
1601
1602                qPos.add(nodeId);
1603
1604                if (title != null) {
1605                    qPos.add(title);
1606                }
1607
1608                list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1609                        end);
1610            }
1611            catch (Exception e) {
1612                throw processException(e);
1613            }
1614            finally {
1615                if (list == null) {
1616                    list = new ArrayList<WikiPage>();
1617                }
1618
1619                cacheResult(list);
1620
1621                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_T,
1622                    finderArgs, list);
1623
1624                closeSession(session);
1625            }
1626        }
1627
1628        return list;
1629    }
1630
1631    public WikiPage findByN_T_First(long nodeId, String title,
1632        OrderByComparator obc) throws NoSuchPageException, SystemException {
1633        List<WikiPage> list = findByN_T(nodeId, title, 0, 1, obc);
1634
1635        if (list.isEmpty()) {
1636            StringBundler msg = new StringBundler(6);
1637
1638            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1639
1640            msg.append("nodeId=");
1641            msg.append(nodeId);
1642
1643            msg.append(", title=");
1644            msg.append(title);
1645
1646            msg.append(StringPool.CLOSE_CURLY_BRACE);
1647
1648            throw new NoSuchPageException(msg.toString());
1649        }
1650        else {
1651            return list.get(0);
1652        }
1653    }
1654
1655    public WikiPage findByN_T_Last(long nodeId, String title,
1656        OrderByComparator obc) throws NoSuchPageException, SystemException {
1657        int count = countByN_T(nodeId, title);
1658
1659        List<WikiPage> list = findByN_T(nodeId, title, count - 1, count, obc);
1660
1661        if (list.isEmpty()) {
1662            StringBundler msg = new StringBundler(6);
1663
1664            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1665
1666            msg.append("nodeId=");
1667            msg.append(nodeId);
1668
1669            msg.append(", title=");
1670            msg.append(title);
1671
1672            msg.append(StringPool.CLOSE_CURLY_BRACE);
1673
1674            throw new NoSuchPageException(msg.toString());
1675        }
1676        else {
1677            return list.get(0);
1678        }
1679    }
1680
1681    public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
1682        String title, OrderByComparator obc)
1683        throws NoSuchPageException, SystemException {
1684        WikiPage wikiPage = findByPrimaryKey(pageId);
1685
1686        int count = countByN_T(nodeId, title);
1687
1688        Session session = null;
1689
1690        try {
1691            session = openSession();
1692
1693            StringBundler query = null;
1694
1695            if (obc != null) {
1696                query = new StringBundler(4 +
1697                        (obc.getOrderByFields().length * 3));
1698            }
1699            else {
1700                query = new StringBundler(4);
1701            }
1702
1703            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1704
1705            query.append(_FINDER_COLUMN_N_T_NODEID_2);
1706
1707            if (title == null) {
1708                query.append(_FINDER_COLUMN_N_T_TITLE_1);
1709            }
1710            else {
1711                if (title.equals(StringPool.BLANK)) {
1712                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
1713                }
1714                else {
1715                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
1716                }
1717            }
1718
1719            if (obc != null) {
1720                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1721            }
1722
1723            else {
1724                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1725            }
1726
1727            String sql = query.toString();
1728
1729            Query q = session.createQuery(sql);
1730
1731            QueryPos qPos = QueryPos.getInstance(q);
1732
1733            qPos.add(nodeId);
1734
1735            if (title != null) {
1736                qPos.add(title);
1737            }
1738
1739            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1740
1741            WikiPage[] array = new WikiPageImpl[3];
1742
1743            array[0] = (WikiPage)objArray[0];
1744            array[1] = (WikiPage)objArray[1];
1745            array[2] = (WikiPage)objArray[2];
1746
1747            return array;
1748        }
1749        catch (Exception e) {
1750            throw processException(e);
1751        }
1752        finally {
1753            closeSession(session);
1754        }
1755    }
1756
1757    public List<WikiPage> findByN_H(long nodeId, boolean head)
1758        throws SystemException {
1759        Object[] finderArgs = new Object[] {
1760                new Long(nodeId), Boolean.valueOf(head)
1761            };
1762
1763        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_H,
1764                finderArgs, this);
1765
1766        if (list == null) {
1767            Session session = null;
1768
1769            try {
1770                session = openSession();
1771
1772                StringBundler query = new StringBundler(4);
1773
1774                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1775
1776                query.append(_FINDER_COLUMN_N_H_NODEID_2);
1777
1778                query.append(_FINDER_COLUMN_N_H_HEAD_2);
1779
1780                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1781
1782                String sql = query.toString();
1783
1784                Query q = session.createQuery(sql);
1785
1786                QueryPos qPos = QueryPos.getInstance(q);
1787
1788                qPos.add(nodeId);
1789
1790                qPos.add(head);
1791
1792                list = q.list();
1793            }
1794            catch (Exception e) {
1795                throw processException(e);
1796            }
1797            finally {
1798                if (list == null) {
1799                    list = new ArrayList<WikiPage>();
1800                }
1801
1802                cacheResult(list);
1803
1804                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_H, finderArgs,
1805                    list);
1806
1807                closeSession(session);
1808            }
1809        }
1810
1811        return list;
1812    }
1813
1814    public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
1815        int end) throws SystemException {
1816        return findByN_H(nodeId, head, start, end, null);
1817    }
1818
1819    public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
1820        int end, OrderByComparator obc) throws SystemException {
1821        Object[] finderArgs = new Object[] {
1822                new Long(nodeId), Boolean.valueOf(head),
1823                
1824                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1825            };
1826
1827        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_H,
1828                finderArgs, this);
1829
1830        if (list == null) {
1831            Session session = null;
1832
1833            try {
1834                session = openSession();
1835
1836                StringBundler query = null;
1837
1838                if (obc != null) {
1839                    query = new StringBundler(4 +
1840                            (obc.getOrderByFields().length * 3));
1841                }
1842                else {
1843                    query = new StringBundler(4);
1844                }
1845
1846                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1847
1848                query.append(_FINDER_COLUMN_N_H_NODEID_2);
1849
1850                query.append(_FINDER_COLUMN_N_H_HEAD_2);
1851
1852                if (obc != null) {
1853                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1854                }
1855
1856                else {
1857                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1858                }
1859
1860                String sql = query.toString();
1861
1862                Query q = session.createQuery(sql);
1863
1864                QueryPos qPos = QueryPos.getInstance(q);
1865
1866                qPos.add(nodeId);
1867
1868                qPos.add(head);
1869
1870                list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1871                        end);
1872            }
1873            catch (Exception e) {
1874                throw processException(e);
1875            }
1876            finally {
1877                if (list == null) {
1878                    list = new ArrayList<WikiPage>();
1879                }
1880
1881                cacheResult(list);
1882
1883                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_H,
1884                    finderArgs, list);
1885
1886                closeSession(session);
1887            }
1888        }
1889
1890        return list;
1891    }
1892
1893    public WikiPage findByN_H_First(long nodeId, boolean head,
1894        OrderByComparator obc) throws NoSuchPageException, SystemException {
1895        List<WikiPage> list = findByN_H(nodeId, head, 0, 1, obc);
1896
1897        if (list.isEmpty()) {
1898            StringBundler msg = new StringBundler(6);
1899
1900            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1901
1902            msg.append("nodeId=");
1903            msg.append(nodeId);
1904
1905            msg.append(", head=");
1906            msg.append(head);
1907
1908            msg.append(StringPool.CLOSE_CURLY_BRACE);
1909
1910            throw new NoSuchPageException(msg.toString());
1911        }
1912        else {
1913            return list.get(0);
1914        }
1915    }
1916
1917    public WikiPage findByN_H_Last(long nodeId, boolean head,
1918        OrderByComparator obc) throws NoSuchPageException, SystemException {
1919        int count = countByN_H(nodeId, head);
1920
1921        List<WikiPage> list = findByN_H(nodeId, head, count - 1, count, obc);
1922
1923        if (list.isEmpty()) {
1924            StringBundler msg = new StringBundler(6);
1925
1926            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1927
1928            msg.append("nodeId=");
1929            msg.append(nodeId);
1930
1931            msg.append(", head=");
1932            msg.append(head);
1933
1934            msg.append(StringPool.CLOSE_CURLY_BRACE);
1935
1936            throw new NoSuchPageException(msg.toString());
1937        }
1938        else {
1939            return list.get(0);
1940        }
1941    }
1942
1943    public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
1944        boolean head, OrderByComparator obc)
1945        throws NoSuchPageException, SystemException {
1946        WikiPage wikiPage = findByPrimaryKey(pageId);
1947
1948        int count = countByN_H(nodeId, head);
1949
1950        Session session = null;
1951
1952        try {
1953            session = openSession();
1954
1955            StringBundler query = null;
1956
1957            if (obc != null) {
1958                query = new StringBundler(4 +
1959                        (obc.getOrderByFields().length * 3));
1960            }
1961            else {
1962                query = new StringBundler(4);
1963            }
1964
1965            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1966
1967            query.append(_FINDER_COLUMN_N_H_NODEID_2);
1968
1969            query.append(_FINDER_COLUMN_N_H_HEAD_2);
1970
1971            if (obc != null) {
1972                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1973            }
1974
1975            else {
1976                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1977            }
1978
1979            String sql = query.toString();
1980
1981            Query q = session.createQuery(sql);
1982
1983            QueryPos qPos = QueryPos.getInstance(q);
1984
1985            qPos.add(nodeId);
1986
1987            qPos.add(head);
1988
1989            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1990
1991            WikiPage[] array = new WikiPageImpl[3];
1992
1993            array[0] = (WikiPage)objArray[0];
1994            array[1] = (WikiPage)objArray[1];
1995            array[2] = (WikiPage)objArray[2];
1996
1997            return array;
1998        }
1999        catch (Exception e) {
2000            throw processException(e);
2001        }
2002        finally {
2003            closeSession(session);
2004        }
2005    }
2006
2007    public List<WikiPage> findByN_P(long nodeId, String parentTitle)
2008        throws SystemException {
2009        Object[] finderArgs = new Object[] { new Long(nodeId), parentTitle };
2010
2011        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_P,
2012                finderArgs, this);
2013
2014        if (list == null) {
2015            Session session = null;
2016
2017            try {
2018                session = openSession();
2019
2020                StringBundler query = new StringBundler(4);
2021
2022                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2023
2024                query.append(_FINDER_COLUMN_N_P_NODEID_2);
2025
2026                if (parentTitle == null) {
2027                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
2028                }
2029                else {
2030                    if (parentTitle.equals(StringPool.BLANK)) {
2031                        query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
2032                    }
2033                    else {
2034                        query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
2035                    }
2036                }
2037
2038                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2039
2040                String sql = query.toString();
2041
2042                Query q = session.createQuery(sql);
2043
2044                QueryPos qPos = QueryPos.getInstance(q);
2045
2046                qPos.add(nodeId);
2047
2048                if (parentTitle != null) {
2049                    qPos.add(parentTitle);
2050                }
2051
2052                list = q.list();
2053            }
2054            catch (Exception e) {
2055                throw processException(e);
2056            }
2057            finally {
2058                if (list == null) {
2059                    list = new ArrayList<WikiPage>();
2060                }
2061
2062                cacheResult(list);
2063
2064                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_P, finderArgs,
2065                    list);
2066
2067                closeSession(session);
2068            }
2069        }
2070
2071        return list;
2072    }
2073
2074    public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
2075        int end) throws SystemException {
2076        return findByN_P(nodeId, parentTitle, start, end, null);
2077    }
2078
2079    public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
2080        int end, OrderByComparator obc) throws SystemException {
2081        Object[] finderArgs = new Object[] {
2082                new Long(nodeId),
2083                
2084                parentTitle,
2085                
2086                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2087            };
2088
2089        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_P,
2090                finderArgs, this);
2091
2092        if (list == null) {
2093            Session session = null;
2094
2095            try {
2096                session = openSession();
2097
2098                StringBundler query = null;
2099
2100                if (obc != null) {
2101                    query = new StringBundler(4 +
2102                            (obc.getOrderByFields().length * 3));
2103                }
2104                else {
2105                    query = new StringBundler(4);
2106                }
2107
2108                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2109
2110                query.append(_FINDER_COLUMN_N_P_NODEID_2);
2111
2112                if (parentTitle == null) {
2113                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
2114                }
2115                else {
2116                    if (parentTitle.equals(StringPool.BLANK)) {
2117                        query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
2118                    }
2119                    else {
2120                        query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
2121                    }
2122                }
2123
2124                if (obc != null) {
2125                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2126                }
2127
2128                else {
2129                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2130                }
2131
2132                String sql = query.toString();
2133
2134                Query q = session.createQuery(sql);
2135
2136                QueryPos qPos = QueryPos.getInstance(q);
2137
2138                qPos.add(nodeId);
2139
2140                if (parentTitle != null) {
2141                    qPos.add(parentTitle);
2142                }
2143
2144                list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2145                        end);
2146            }
2147            catch (Exception e) {
2148                throw processException(e);
2149            }
2150            finally {
2151                if (list == null) {
2152                    list = new ArrayList<WikiPage>();
2153                }
2154
2155                cacheResult(list);
2156
2157                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_P,
2158                    finderArgs, list);
2159
2160                closeSession(session);
2161            }
2162        }
2163
2164        return list;
2165    }
2166
2167    public WikiPage findByN_P_First(long nodeId, String parentTitle,
2168        OrderByComparator obc) throws NoSuchPageException, SystemException {
2169        List<WikiPage> list = findByN_P(nodeId, parentTitle, 0, 1, obc);
2170
2171        if (list.isEmpty()) {
2172            StringBundler msg = new StringBundler(6);
2173
2174            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2175
2176            msg.append("nodeId=");
2177            msg.append(nodeId);
2178
2179            msg.append(", parentTitle=");
2180            msg.append(parentTitle);
2181
2182            msg.append(StringPool.CLOSE_CURLY_BRACE);
2183
2184            throw new NoSuchPageException(msg.toString());
2185        }
2186        else {
2187            return list.get(0);
2188        }
2189    }
2190
2191    public WikiPage findByN_P_Last(long nodeId, String parentTitle,
2192        OrderByComparator obc) throws NoSuchPageException, SystemException {
2193        int count = countByN_P(nodeId, parentTitle);
2194
2195        List<WikiPage> list = findByN_P(nodeId, parentTitle, count - 1, count,
2196                obc);
2197
2198        if (list.isEmpty()) {
2199            StringBundler msg = new StringBundler(6);
2200
2201            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2202
2203            msg.append("nodeId=");
2204            msg.append(nodeId);
2205
2206            msg.append(", parentTitle=");
2207            msg.append(parentTitle);
2208
2209            msg.append(StringPool.CLOSE_CURLY_BRACE);
2210
2211            throw new NoSuchPageException(msg.toString());
2212        }
2213        else {
2214            return list.get(0);
2215        }
2216    }
2217
2218    public WikiPage[] findByN_P_PrevAndNext(long pageId, long nodeId,
2219        String parentTitle, OrderByComparator obc)
2220        throws NoSuchPageException, SystemException {
2221        WikiPage wikiPage = findByPrimaryKey(pageId);
2222
2223        int count = countByN_P(nodeId, parentTitle);
2224
2225        Session session = null;
2226
2227        try {
2228            session = openSession();
2229
2230            StringBundler query = null;
2231
2232            if (obc != null) {
2233                query = new StringBundler(4 +
2234                        (obc.getOrderByFields().length * 3));
2235            }
2236            else {
2237                query = new StringBundler(4);
2238            }
2239
2240            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2241
2242            query.append(_FINDER_COLUMN_N_P_NODEID_2);
2243
2244            if (parentTitle == null) {
2245                query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
2246            }
2247            else {
2248                if (parentTitle.equals(StringPool.BLANK)) {
2249                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
2250                }
2251                else {
2252                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
2253                }
2254            }
2255
2256            if (obc != null) {
2257                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2258            }
2259
2260            else {
2261                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2262            }
2263
2264            String sql = query.toString();
2265
2266            Query q = session.createQuery(sql);
2267
2268            QueryPos qPos = QueryPos.getInstance(q);
2269
2270            qPos.add(nodeId);
2271
2272            if (parentTitle != null) {
2273                qPos.add(parentTitle);
2274            }
2275
2276            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
2277
2278            WikiPage[] array = new WikiPageImpl[3];
2279
2280            array[0] = (WikiPage)objArray[0];
2281            array[1] = (WikiPage)objArray[1];
2282            array[2] = (WikiPage)objArray[2];
2283
2284            return array;
2285        }
2286        catch (Exception e) {
2287            throw processException(e);
2288        }
2289        finally {
2290            closeSession(session);
2291        }
2292    }
2293
2294    public List<WikiPage> findByN_R(long nodeId, String redirectTitle)
2295        throws SystemException {
2296        Object[] finderArgs = new Object[] { new Long(nodeId), redirectTitle };
2297
2298        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_R,
2299                finderArgs, this);
2300
2301        if (list == null) {
2302            Session session = null;
2303
2304            try {
2305                session = openSession();
2306
2307                StringBundler query = new StringBundler(4);
2308
2309                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2310
2311                query.append(_FINDER_COLUMN_N_R_NODEID_2);
2312
2313                if (redirectTitle == null) {
2314                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
2315                }
2316                else {
2317                    if (redirectTitle.equals(StringPool.BLANK)) {
2318                        query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
2319                    }
2320                    else {
2321                        query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
2322                    }
2323                }
2324
2325                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2326
2327                String sql = query.toString();
2328
2329                Query q = session.createQuery(sql);
2330
2331                QueryPos qPos = QueryPos.getInstance(q);
2332
2333                qPos.add(nodeId);
2334
2335                if (redirectTitle != null) {
2336                    qPos.add(redirectTitle);
2337                }
2338
2339                list = q.list();
2340            }
2341            catch (Exception e) {
2342                throw processException(e);
2343            }
2344            finally {
2345                if (list == null) {
2346                    list = new ArrayList<WikiPage>();
2347                }
2348
2349                cacheResult(list);
2350
2351                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_R, finderArgs,
2352                    list);
2353
2354                closeSession(session);
2355            }
2356        }
2357
2358        return list;
2359    }
2360
2361    public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
2362        int start, int end) throws SystemException {
2363        return findByN_R(nodeId, redirectTitle, start, end, null);
2364    }
2365
2366    public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
2367        int start, int end, OrderByComparator obc) throws SystemException {
2368        Object[] finderArgs = new Object[] {
2369                new Long(nodeId),
2370                
2371                redirectTitle,
2372                
2373                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2374            };
2375
2376        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_R,
2377                finderArgs, this);
2378
2379        if (list == null) {
2380            Session session = null;
2381
2382            try {
2383                session = openSession();
2384
2385                StringBundler query = null;
2386
2387                if (obc != null) {
2388                    query = new StringBundler(4 +
2389                            (obc.getOrderByFields().length * 3));
2390                }
2391                else {
2392                    query = new StringBundler(4);
2393                }
2394
2395                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2396
2397                query.append(_FINDER_COLUMN_N_R_NODEID_2);
2398
2399                if (redirectTitle == null) {
2400                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
2401                }
2402                else {
2403                    if (redirectTitle.equals(StringPool.BLANK)) {
2404                        query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
2405                    }
2406                    else {
2407                        query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
2408                    }
2409                }
2410
2411                if (obc != null) {
2412                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2413                }
2414
2415                else {
2416                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2417                }
2418
2419                String sql = query.toString();
2420
2421                Query q = session.createQuery(sql);
2422
2423                QueryPos qPos = QueryPos.getInstance(q);
2424
2425                qPos.add(nodeId);
2426
2427                if (redirectTitle != null) {
2428                    qPos.add(redirectTitle);
2429                }
2430
2431                list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2432                        end);
2433            }
2434            catch (Exception e) {
2435                throw processException(e);
2436            }
2437            finally {
2438                if (list == null) {
2439                    list = new ArrayList<WikiPage>();
2440                }
2441
2442                cacheResult(list);
2443
2444                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_R,
2445                    finderArgs, list);
2446
2447                closeSession(session);
2448            }
2449        }
2450
2451        return list;
2452    }
2453
2454    public WikiPage findByN_R_First(long nodeId, String redirectTitle,
2455        OrderByComparator obc) throws NoSuchPageException, SystemException {
2456        List<WikiPage> list = findByN_R(nodeId, redirectTitle, 0, 1, obc);
2457
2458        if (list.isEmpty()) {
2459            StringBundler msg = new StringBundler(6);
2460
2461            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2462
2463            msg.append("nodeId=");
2464            msg.append(nodeId);
2465
2466            msg.append(", redirectTitle=");
2467            msg.append(redirectTitle);
2468
2469            msg.append(StringPool.CLOSE_CURLY_BRACE);
2470
2471            throw new NoSuchPageException(msg.toString());
2472        }
2473        else {
2474            return list.get(0);
2475        }
2476    }
2477
2478    public WikiPage findByN_R_Last(long nodeId, String redirectTitle,
2479        OrderByComparator obc) throws NoSuchPageException, SystemException {
2480        int count = countByN_R(nodeId, redirectTitle);
2481
2482        List<WikiPage> list = findByN_R(nodeId, redirectTitle, count - 1,
2483                count, obc);
2484
2485        if (list.isEmpty()) {
2486            StringBundler msg = new StringBundler(6);
2487
2488            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2489
2490            msg.append("nodeId=");
2491            msg.append(nodeId);
2492
2493            msg.append(", redirectTitle=");
2494            msg.append(redirectTitle);
2495
2496            msg.append(StringPool.CLOSE_CURLY_BRACE);
2497
2498            throw new NoSuchPageException(msg.toString());
2499        }
2500        else {
2501            return list.get(0);
2502        }
2503    }
2504
2505    public WikiPage[] findByN_R_PrevAndNext(long pageId, long nodeId,
2506        String redirectTitle, OrderByComparator obc)
2507        throws NoSuchPageException, SystemException {
2508        WikiPage wikiPage = findByPrimaryKey(pageId);
2509
2510        int count = countByN_R(nodeId, redirectTitle);
2511
2512        Session session = null;
2513
2514        try {
2515            session = openSession();
2516
2517            StringBundler query = null;
2518
2519            if (obc != null) {
2520                query = new StringBundler(4 +
2521                        (obc.getOrderByFields().length * 3));
2522            }
2523            else {
2524                query = new StringBundler(4);
2525            }
2526
2527            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2528
2529            query.append(_FINDER_COLUMN_N_R_NODEID_2);
2530
2531            if (redirectTitle == null) {
2532                query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
2533            }
2534            else {
2535                if (redirectTitle.equals(StringPool.BLANK)) {
2536                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
2537                }
2538                else {
2539                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
2540                }
2541            }
2542
2543            if (obc != null) {
2544                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2545            }
2546
2547            else {
2548                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2549            }
2550
2551            String sql = query.toString();
2552
2553            Query q = session.createQuery(sql);
2554
2555            QueryPos qPos = QueryPos.getInstance(q);
2556
2557            qPos.add(nodeId);
2558
2559            if (redirectTitle != null) {
2560                qPos.add(redirectTitle);
2561            }
2562
2563            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
2564
2565            WikiPage[] array = new WikiPageImpl[3];
2566
2567            array[0] = (WikiPage)objArray[0];
2568            array[1] = (WikiPage)objArray[1];
2569            array[2] = (WikiPage)objArray[2];
2570
2571            return array;
2572        }
2573        catch (Exception e) {
2574            throw processException(e);
2575        }
2576        finally {
2577            closeSession(session);
2578        }
2579    }
2580
2581    public WikiPage findByN_T_V(long nodeId, String title, double version)
2582        throws NoSuchPageException, SystemException {
2583        WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
2584
2585        if (wikiPage == null) {
2586            StringBundler msg = new StringBundler(8);
2587
2588            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2589
2590            msg.append("nodeId=");
2591            msg.append(nodeId);
2592
2593            msg.append(", title=");
2594            msg.append(title);
2595
2596            msg.append(", version=");
2597            msg.append(version);
2598
2599            msg.append(StringPool.CLOSE_CURLY_BRACE);
2600
2601            if (_log.isWarnEnabled()) {
2602                _log.warn(msg.toString());
2603            }
2604
2605            throw new NoSuchPageException(msg.toString());
2606        }
2607
2608        return wikiPage;
2609    }
2610
2611    public WikiPage fetchByN_T_V(long nodeId, String title, double version)
2612        throws SystemException {
2613        return fetchByN_T_V(nodeId, title, version, true);
2614    }
2615
2616    public WikiPage fetchByN_T_V(long nodeId, String title, double version,
2617        boolean retrieveFromCache) throws SystemException {
2618        Object[] finderArgs = new Object[] {
2619                new Long(nodeId),
2620                
2621                title, new Double(version)
2622            };
2623
2624        Object result = null;
2625
2626        if (retrieveFromCache) {
2627            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T_V,
2628                    finderArgs, this);
2629        }
2630
2631        if (result == null) {
2632            Session session = null;
2633
2634            try {
2635                session = openSession();
2636
2637                StringBundler query = new StringBundler(5);
2638
2639                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2640
2641                query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
2642
2643                if (title == null) {
2644                    query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
2645                }
2646                else {
2647                    if (title.equals(StringPool.BLANK)) {
2648                        query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
2649                    }
2650                    else {
2651                        query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
2652                    }
2653                }
2654
2655                query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
2656
2657                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2658
2659                String sql = query.toString();
2660
2661                Query q = session.createQuery(sql);
2662
2663                QueryPos qPos = QueryPos.getInstance(q);
2664
2665                qPos.add(nodeId);
2666
2667                if (title != null) {
2668                    qPos.add(title);
2669                }
2670
2671                qPos.add(version);
2672
2673                List<WikiPage> list = q.list();
2674
2675                result = list;
2676
2677                WikiPage wikiPage = null;
2678
2679                if (list.isEmpty()) {
2680                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
2681                        finderArgs, list);
2682                }
2683                else {
2684                    wikiPage = list.get(0);
2685
2686                    cacheResult(wikiPage);
2687
2688                    if ((wikiPage.getNodeId() != nodeId) ||
2689                            (wikiPage.getTitle() == null) ||
2690                            !wikiPage.getTitle().equals(title) ||
2691                            (wikiPage.getVersion() != version)) {
2692                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
2693                            finderArgs, wikiPage);
2694                    }
2695                }
2696
2697                return wikiPage;
2698            }
2699            catch (Exception e) {
2700                throw processException(e);
2701            }
2702            finally {
2703                if (result == null) {
2704                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
2705                        finderArgs, new ArrayList<WikiPage>());
2706                }
2707
2708                closeSession(session);
2709            }
2710        }
2711        else {
2712            if (result instanceof List<?>) {
2713                return null;
2714            }
2715            else {
2716                return (WikiPage)result;
2717            }
2718        }
2719    }
2720
2721    public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head)
2722        throws SystemException {
2723        Object[] finderArgs = new Object[] {
2724                new Long(nodeId),
2725                
2726                title, Boolean.valueOf(head)
2727            };
2728
2729        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_T_H,
2730                finderArgs, this);
2731
2732        if (list == null) {
2733            Session session = null;
2734
2735            try {
2736                session = openSession();
2737
2738                StringBundler query = new StringBundler(5);
2739
2740                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2741
2742                query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
2743
2744                if (title == null) {
2745                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
2746                }
2747                else {
2748                    if (title.equals(StringPool.BLANK)) {
2749                        query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
2750                    }
2751                    else {
2752                        query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
2753                    }
2754                }
2755
2756                query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
2757
2758                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2759
2760                String sql = query.toString();
2761
2762                Query q = session.createQuery(sql);
2763
2764                QueryPos qPos = QueryPos.getInstance(q);
2765
2766                qPos.add(nodeId);
2767
2768                if (title != null) {
2769                    qPos.add(title);
2770                }
2771
2772                qPos.add(head);
2773
2774                list = q.list();
2775            }
2776            catch (Exception e) {
2777                throw processException(e);
2778            }
2779            finally {
2780                if (list == null) {
2781                    list = new ArrayList<WikiPage>();
2782                }
2783
2784                cacheResult(list);
2785
2786                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_T_H,
2787                    finderArgs, list);
2788
2789                closeSession(session);
2790            }
2791        }
2792
2793        return list;
2794    }
2795
2796    public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
2797        int start, int end) throws SystemException {
2798        return findByN_T_H(nodeId, title, head, start, end, null);
2799    }
2800
2801    public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
2802        int start, int end, OrderByComparator obc) throws SystemException {
2803        Object[] finderArgs = new Object[] {
2804                new Long(nodeId),
2805                
2806                title, Boolean.valueOf(head),
2807                
2808                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2809            };
2810
2811        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_T_H,
2812                finderArgs, this);
2813
2814        if (list == null) {
2815            Session session = null;
2816
2817            try {
2818                session = openSession();
2819
2820                StringBundler query = null;
2821
2822                if (obc != null) {
2823                    query = new StringBundler(5 +
2824                            (obc.getOrderByFields().length * 3));
2825                }
2826                else {
2827                    query = new StringBundler(5);
2828                }
2829
2830                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2831
2832                query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
2833
2834                if (title == null) {
2835                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
2836                }
2837                else {
2838                    if (title.equals(StringPool.BLANK)) {
2839                        query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
2840                    }
2841                    else {
2842                        query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
2843                    }
2844                }
2845
2846                query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
2847
2848                if (obc != null) {
2849                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2850                }
2851
2852                else {
2853                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2854                }
2855
2856                String sql = query.toString();
2857
2858                Query q = session.createQuery(sql);
2859
2860                QueryPos qPos = QueryPos.getInstance(q);
2861
2862                qPos.add(nodeId);
2863
2864                if (title != null) {
2865                    qPos.add(title);
2866                }
2867
2868                qPos.add(head);
2869
2870                list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2871                        end);
2872            }
2873            catch (Exception e) {
2874                throw processException(e);
2875            }
2876            finally {
2877                if (list == null) {
2878                    list = new ArrayList<WikiPage>();
2879                }
2880
2881                cacheResult(list);
2882
2883                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_T_H,
2884                    finderArgs, list);
2885
2886                closeSession(session);
2887            }
2888        }
2889
2890        return list;
2891    }
2892
2893    public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
2894        OrderByComparator obc) throws NoSuchPageException, SystemException {
2895        List<WikiPage> list = findByN_T_H(nodeId, title, head, 0, 1, obc);
2896
2897        if (list.isEmpty()) {
2898            StringBundler msg = new StringBundler(8);
2899
2900            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2901
2902            msg.append("nodeId=");
2903            msg.append(nodeId);
2904
2905            msg.append(", title=");
2906            msg.append(title);
2907
2908            msg.append(", head=");
2909            msg.append(head);
2910
2911            msg.append(StringPool.CLOSE_CURLY_BRACE);
2912
2913            throw new NoSuchPageException(msg.toString());
2914        }
2915        else {
2916            return list.get(0);
2917        }
2918    }
2919
2920    public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
2921        OrderByComparator obc) throws NoSuchPageException, SystemException {
2922        int count = countByN_T_H(nodeId, title, head);
2923
2924        List<WikiPage> list = findByN_T_H(nodeId, title, head, count - 1,
2925                count, obc);
2926
2927        if (list.isEmpty()) {
2928            StringBundler msg = new StringBundler(8);
2929
2930            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2931
2932            msg.append("nodeId=");
2933            msg.append(nodeId);
2934
2935            msg.append(", title=");
2936            msg.append(title);
2937
2938            msg.append(", head=");
2939            msg.append(head);
2940
2941            msg.append(StringPool.CLOSE_CURLY_BRACE);
2942
2943            throw new NoSuchPageException(msg.toString());
2944        }
2945        else {
2946            return list.get(0);
2947        }
2948    }
2949
2950    public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
2951        String title, boolean head, OrderByComparator obc)
2952        throws NoSuchPageException, SystemException {
2953        WikiPage wikiPage = findByPrimaryKey(pageId);
2954
2955        int count = countByN_T_H(nodeId, title, head);
2956
2957        Session session = null;
2958
2959        try {
2960            session = openSession();
2961
2962            StringBundler query = null;
2963
2964            if (obc != null) {
2965                query = new StringBundler(5 +
2966                        (obc.getOrderByFields().length * 3));
2967            }
2968            else {
2969                query = new StringBundler(5);
2970            }
2971
2972            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2973
2974            query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
2975
2976            if (title == null) {
2977                query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
2978            }
2979            else {
2980                if (title.equals(StringPool.BLANK)) {
2981                    query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
2982                }
2983                else {
2984                    query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
2985                }
2986            }
2987
2988            query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
2989
2990            if (obc != null) {
2991                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2992            }
2993
2994            else {
2995                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2996            }
2997
2998            String sql = query.toString();
2999
3000            Query q = session.createQuery(sql);
3001
3002            QueryPos qPos = QueryPos.getInstance(q);
3003
3004            qPos.add(nodeId);
3005
3006            if (title != null) {
3007                qPos.add(title);
3008            }
3009
3010            qPos.add(head);
3011
3012            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
3013
3014            WikiPage[] array = new WikiPageImpl[3];
3015
3016            array[0] = (WikiPage)objArray[0];
3017            array[1] = (WikiPage)objArray[1];
3018            array[2] = (WikiPage)objArray[2];
3019
3020            return array;
3021        }
3022        catch (Exception e) {
3023            throw processException(e);
3024        }
3025        finally {
3026            closeSession(session);
3027        }
3028    }
3029
3030    public List<WikiPage> findByN_H_P(long nodeId, boolean head,
3031        String parentTitle) throws SystemException {
3032        Object[] finderArgs = new Object[] {
3033                new Long(nodeId), Boolean.valueOf(head),
3034                
3035                parentTitle
3036            };
3037
3038        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_H_P,
3039                finderArgs, this);
3040
3041        if (list == null) {
3042            Session session = null;
3043
3044            try {
3045                session = openSession();
3046
3047                StringBundler query = new StringBundler(5);
3048
3049                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3050
3051                query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
3052
3053                query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
3054
3055                if (parentTitle == null) {
3056                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
3057                }
3058                else {
3059                    if (parentTitle.equals(StringPool.BLANK)) {
3060                        query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
3061                    }
3062                    else {
3063                        query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
3064                    }
3065                }
3066
3067                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3068
3069                String sql = query.toString();
3070
3071                Query q = session.createQuery(sql);
3072
3073                QueryPos qPos = QueryPos.getInstance(q);
3074
3075                qPos.add(nodeId);
3076
3077                qPos.add(head);
3078
3079                if (parentTitle != null) {
3080                    qPos.add(parentTitle);
3081                }
3082
3083                list = q.list();
3084            }
3085            catch (Exception e) {
3086                throw processException(e);
3087            }
3088            finally {
3089                if (list == null) {
3090                    list = new ArrayList<WikiPage>();
3091                }
3092
3093                cacheResult(list);
3094
3095                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_H_P,
3096                    finderArgs, list);
3097
3098                closeSession(session);
3099            }
3100        }
3101
3102        return list;
3103    }
3104
3105    public List<WikiPage> findByN_H_P(long nodeId, boolean head,
3106        String parentTitle, int start, int end) throws SystemException {
3107        return findByN_H_P(nodeId, head, parentTitle, start, end, null);
3108    }
3109
3110    public List<WikiPage> findByN_H_P(long nodeId, boolean head,
3111        String parentTitle, int start, int end, OrderByComparator obc)
3112        throws SystemException {
3113        Object[] finderArgs = new Object[] {
3114                new Long(nodeId), Boolean.valueOf(head),
3115                
3116                parentTitle,
3117                
3118                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3119            };
3120
3121        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_H_P,
3122                finderArgs, this);
3123
3124        if (list == null) {
3125            Session session = null;
3126
3127            try {
3128                session = openSession();
3129
3130                StringBundler query = null;
3131
3132                if (obc != null) {
3133                    query = new StringBundler(5 +
3134                            (obc.getOrderByFields().length * 3));
3135                }
3136                else {
3137                    query = new StringBundler(5);
3138                }
3139
3140                query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3141
3142                query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
3143
3144                query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
3145
3146                if (parentTitle == null) {
3147                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
3148                }
3149                else {
3150                    if (parentTitle.equals(StringPool.BLANK)) {
3151                        query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
3152                    }
3153                    else {
3154                        query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
3155                    }
3156                }
3157
3158                if (obc != null) {
3159                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3160                }
3161
3162                else {
3163                    query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3164                }
3165
3166                String sql = query.toString();
3167
3168                Query q = session.createQuery(sql);
3169
3170                QueryPos qPos = QueryPos.getInstance(q);
3171
3172                qPos.add(nodeId);
3173
3174                qPos.add(head);
3175
3176                if (parentTitle != null) {
3177                    qPos.add(parentTitle);
3178                }
3179
3180                list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
3181                        end);
3182            }
3183            catch (Exception e) {
3184                throw processException(e);
3185            }
3186            finally {
3187                if (list == null) {
3188                    list = new ArrayList<WikiPage>();
3189                }
3190
3191                cacheResult(list);
3192
3193                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_H_P,
3194                    finderArgs, list);
3195
3196                closeSession(session);
3197            }
3198        }
3199
3200        return list;
3201    }
3202
3203    public WikiPage findByN_H_P_First(long nodeId, boolean head,
3204        String parentTitle, OrderByComparator obc)
3205        throws NoSuchPageException, SystemException {
3206        List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, 0, 1, obc);
3207
3208        if (list.isEmpty()) {
3209            StringBundler msg = new StringBundler(8);
3210
3211            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3212
3213            msg.append("nodeId=");
3214            msg.append(nodeId);
3215
3216            msg.append(", head=");
3217            msg.append(head);
3218
3219            msg.append(", parentTitle=");
3220            msg.append(parentTitle);
3221
3222            msg.append(StringPool.CLOSE_CURLY_BRACE);
3223
3224            throw new NoSuchPageException(msg.toString());
3225        }
3226        else {
3227            return list.get(0);
3228        }
3229    }
3230
3231    public WikiPage findByN_H_P_Last(long nodeId, boolean head,
3232        String parentTitle, OrderByComparator obc)
3233        throws NoSuchPageException, SystemException {
3234        int count = countByN_H_P(nodeId, head, parentTitle);
3235
3236        List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, count - 1,
3237                count, obc);
3238
3239        if (list.isEmpty()) {
3240            StringBundler msg = new StringBundler(8);
3241
3242            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3243
3244            msg.append("nodeId=");
3245            msg.append(nodeId);
3246
3247            msg.append(", head=");
3248            msg.append(head);
3249
3250            msg.append(", parentTitle=");
3251            msg.append(parentTitle);
3252
3253            msg.append(StringPool.CLOSE_CURLY_BRACE);
3254
3255            throw new NoSuchPageException(msg.toString());
3256        }
3257        else {
3258            return list.get(0);
3259        }
3260    }
3261
3262    public WikiPage[] findByN_H_P_PrevAndNext(long pageId, long nodeId,
3263        boolean head, String parentTitle, OrderByComparator obc)
3264        throws NoSuchPageException, SystemException {
3265        WikiPage wikiPage = findByPrimaryKey(pageId);
3266
3267        int count = countByN_H_P(nodeId, head, parentTitle);
3268
3269        Session session = null;
3270
3271        try {
3272            session = openSession();
3273
3274            StringBundler query = null;
3275
3276            if (obc != null) {
3277                query = new StringBundler(5 +
3278                        (obc.getOrderByFields().length * 3));
3279            }
3280            else {
3281                query = new StringBundler(5);
3282            }
3283
3284            query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3285
3286            query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
3287
3288            query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
3289
3290            if (parentTitle == null) {
3291                query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
3292            }
3293            else {
3294                if (parentTitle.equals(StringPool.BLANK)) {
3295                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
3296                }
3297                else {
3298                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
3299                }
3300            }
3301
3302            if (obc != null) {
3303                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3304            }
3305
3306            else {
3307                query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3308            }
3309
3310            String sql = query.toString();
3311
3312            Query q = session.createQuery(sql);
3313
3314            QueryPos qPos = QueryPos.getInstance(q);
3315
3316            qPos.add(nodeId);
3317
3318            qPos.add(head);
3319
3320            if (parentTitle != null) {
3321                qPos.add(parentTitle);
3322            }
3323
3324            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
3325
3326            WikiPage[] array = new WikiPageImpl[3];
3327
3328            array[0] = (WikiPage)objArray[0];
3329            array[1] = (WikiPage)objArray[1];
3330            array[2] = (WikiPage)objArray[2];
3331
3332            return array;
3333        }
3334        catch (Exception e) {
3335            throw processException(e);
3336        }
3337        finally {
3338            closeSession(session);
3339        }
3340    }
3341
3342    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
3343        throws SystemException {
3344        Session session = null;
3345
3346        try {
3347            session = openSession();
3348
3349            dynamicQuery.compile(session);
3350
3351            return dynamicQuery.list();
3352        }
3353        catch (Exception e) {
3354            throw processException(e);
3355        }
3356        finally {
3357            closeSession(session);
3358        }
3359    }
3360
3361    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
3362        int start, int end) throws SystemException {
3363        Session session = null;
3364
3365        try {
3366            session = openSession();
3367
3368            dynamicQuery.setLimit(start, end);
3369
3370            dynamicQuery.compile(session);
3371
3372            return dynamicQuery.list();
3373        }
3374        catch (Exception e) {
3375            throw processException(e);
3376        }
3377        finally {
3378            closeSession(session);
3379        }
3380    }
3381
3382    public List<WikiPage> findAll() throws SystemException {
3383        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3384    }
3385
3386    public List<WikiPage> findAll(int start, int end) throws SystemException {
3387        return findAll(start, end, null);
3388    }
3389
3390    public List<WikiPage> findAll(int start, int end, OrderByComparator obc)
3391        throws SystemException {
3392        Object[] finderArgs = new Object[] {
3393                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3394            };
3395
3396        List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3397                finderArgs, this);
3398
3399        if (list == null) {
3400            Session session = null;
3401
3402            try {
3403                session = openSession();
3404
3405                StringBundler query = null;
3406                String sql = null;
3407
3408                if (obc != null) {
3409                    query = new StringBundler(2 +
3410                            (obc.getOrderByFields().length * 3));
3411
3412                    query.append(_SQL_SELECT_WIKIPAGE);
3413
3414                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3415
3416                    sql = query.toString();
3417                }
3418
3419                else {
3420                    sql = _SQL_SELECT_WIKIPAGE.concat(WikiPageModelImpl.ORDER_BY_JPQL);
3421                }
3422
3423                Query q = session.createQuery(sql);
3424
3425                if (obc == null) {
3426                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3427                            start, end, false);
3428
3429                    Collections.sort(list);
3430                }
3431                else {
3432                    list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3433                            start, end);
3434                }
3435            }
3436            catch (Exception e) {
3437                throw processException(e);
3438            }
3439            finally {
3440                if (list == null) {
3441                    list = new ArrayList<WikiPage>();
3442                }
3443
3444                cacheResult(list);
3445
3446                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3447
3448                closeSession(session);
3449            }
3450        }
3451
3452        return list;
3453    }
3454
3455    public void removeByUuid(String uuid) throws SystemException {
3456        for (WikiPage wikiPage : findByUuid(uuid)) {
3457            remove(wikiPage);
3458        }
3459    }
3460
3461    public void removeByUUID_G(String uuid, long groupId)
3462        throws NoSuchPageException, SystemException {
3463        WikiPage wikiPage = findByUUID_G(uuid, groupId);
3464
3465        remove(wikiPage);
3466    }
3467
3468    public void removeByNodeId(long nodeId) throws SystemException {
3469        for (WikiPage wikiPage : findByNodeId(nodeId)) {
3470            remove(wikiPage);
3471        }
3472    }
3473
3474    public void removeByFormat(String format) throws SystemException {
3475        for (WikiPage wikiPage : findByFormat(format)) {
3476            remove(wikiPage);
3477        }
3478    }
3479
3480    public void removeByN_T(long nodeId, String title)
3481        throws SystemException {
3482        for (WikiPage wikiPage : findByN_T(nodeId, title)) {
3483            remove(wikiPage);
3484        }
3485    }
3486
3487    public void removeByN_H(long nodeId, boolean head)
3488        throws SystemException {
3489        for (WikiPage wikiPage : findByN_H(nodeId, head)) {
3490            remove(wikiPage);
3491        }
3492    }
3493
3494    public void removeByN_P(long nodeId, String parentTitle)
3495        throws SystemException {
3496        for (WikiPage wikiPage : findByN_P(nodeId, parentTitle)) {
3497            remove(wikiPage);
3498        }
3499    }
3500
3501    public void removeByN_R(long nodeId, String redirectTitle)
3502        throws SystemException {
3503        for (WikiPage wikiPage : findByN_R(nodeId, redirectTitle)) {
3504            remove(wikiPage);
3505        }
3506    }
3507
3508    public void removeByN_T_V(long nodeId, String title, double version)
3509        throws NoSuchPageException, SystemException {
3510        WikiPage wikiPage = findByN_T_V(nodeId, title, version);
3511
3512        remove(wikiPage);
3513    }
3514
3515    public void removeByN_T_H(long nodeId, String title, boolean head)
3516        throws SystemException {
3517        for (WikiPage wikiPage : findByN_T_H(nodeId, title, head)) {
3518            remove(wikiPage);
3519        }
3520    }
3521
3522    public void removeByN_H_P(long nodeId, boolean head, String parentTitle)
3523        throws SystemException {
3524        for (WikiPage wikiPage : findByN_H_P(nodeId, head, parentTitle)) {
3525            remove(wikiPage);
3526        }
3527    }
3528
3529    public void removeAll() throws SystemException {
3530        for (WikiPage wikiPage : findAll()) {
3531            remove(wikiPage);
3532        }
3533    }
3534
3535    public int countByUuid(String uuid) throws SystemException {
3536        Object[] finderArgs = new Object[] { uuid };
3537
3538        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3539                finderArgs, this);
3540
3541        if (count == null) {
3542            Session session = null;
3543
3544            try {
3545                session = openSession();
3546
3547                StringBundler query = new StringBundler(2);
3548
3549                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3550
3551                if (uuid == null) {
3552                    query.append(_FINDER_COLUMN_UUID_UUID_1);
3553                }
3554                else {
3555                    if (uuid.equals(StringPool.BLANK)) {
3556                        query.append(_FINDER_COLUMN_UUID_UUID_3);
3557                    }
3558                    else {
3559                        query.append(_FINDER_COLUMN_UUID_UUID_2);
3560                    }
3561                }
3562
3563                String sql = query.toString();
3564
3565                Query q = session.createQuery(sql);
3566
3567                QueryPos qPos = QueryPos.getInstance(q);
3568
3569                if (uuid != null) {
3570                    qPos.add(uuid);
3571                }
3572
3573                count = (Long)q.uniqueResult();
3574            }
3575            catch (Exception e) {
3576                throw processException(e);
3577            }
3578            finally {
3579                if (count == null) {
3580                    count = Long.valueOf(0);
3581                }
3582
3583                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3584                    finderArgs, count);
3585
3586                closeSession(session);
3587            }
3588        }
3589
3590        return count.intValue();
3591    }
3592
3593    public int countByUUID_G(String uuid, long groupId)
3594        throws SystemException {
3595        Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
3596
3597        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3598                finderArgs, this);
3599
3600        if (count == null) {
3601            Session session = null;
3602
3603            try {
3604                session = openSession();
3605
3606                StringBundler query = new StringBundler(3);
3607
3608                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3609
3610                if (uuid == null) {
3611                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3612                }
3613                else {
3614                    if (uuid.equals(StringPool.BLANK)) {
3615                        query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3616                    }
3617                    else {
3618                        query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3619                    }
3620                }
3621
3622                query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3623
3624                String sql = query.toString();
3625
3626                Query q = session.createQuery(sql);
3627
3628                QueryPos qPos = QueryPos.getInstance(q);
3629
3630                if (uuid != null) {
3631                    qPos.add(uuid);
3632                }
3633
3634                qPos.add(groupId);
3635
3636                count = (Long)q.uniqueResult();
3637            }
3638            catch (Exception e) {
3639                throw processException(e);
3640            }
3641            finally {
3642                if (count == null) {
3643                    count = Long.valueOf(0);
3644                }
3645
3646                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3647                    finderArgs, count);
3648
3649                closeSession(session);
3650            }
3651        }
3652
3653        return count.intValue();
3654    }
3655
3656    public int countByNodeId(long nodeId) throws SystemException {
3657        Object[] finderArgs = new Object[] { new Long(nodeId) };
3658
3659        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NODEID,
3660                finderArgs, this);
3661
3662        if (count == null) {
3663            Session session = null;
3664
3665            try {
3666                session = openSession();
3667
3668                StringBundler query = new StringBundler(2);
3669
3670                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3671
3672                query.append(_FINDER_COLUMN_NODEID_NODEID_2);
3673
3674                String sql = query.toString();
3675
3676                Query q = session.createQuery(sql);
3677
3678                QueryPos qPos = QueryPos.getInstance(q);
3679
3680                qPos.add(nodeId);
3681
3682                count = (Long)q.uniqueResult();
3683            }
3684            catch (Exception e) {
3685                throw processException(e);
3686            }
3687            finally {
3688                if (count == null) {
3689                    count = Long.valueOf(0);
3690                }
3691
3692                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NODEID,
3693                    finderArgs, count);
3694
3695                closeSession(session);
3696            }
3697        }
3698
3699        return count.intValue();
3700    }
3701
3702    public int countByFormat(String format) throws SystemException {
3703        Object[] finderArgs = new Object[] { format };
3704
3705        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FORMAT,
3706                finderArgs, this);
3707
3708        if (count == null) {
3709            Session session = null;
3710
3711            try {
3712                session = openSession();
3713
3714                StringBundler query = new StringBundler(2);
3715
3716                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3717
3718                if (format == null) {
3719                    query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
3720                }
3721                else {
3722                    if (format.equals(StringPool.BLANK)) {
3723                        query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
3724                    }
3725                    else {
3726                        query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
3727                    }
3728                }
3729
3730                String sql = query.toString();
3731
3732                Query q = session.createQuery(sql);
3733
3734                QueryPos qPos = QueryPos.getInstance(q);
3735
3736                if (format != null) {
3737                    qPos.add(format);
3738                }
3739
3740                count = (Long)q.uniqueResult();
3741            }
3742            catch (Exception e) {
3743                throw processException(e);
3744            }
3745            finally {
3746                if (count == null) {
3747                    count = Long.valueOf(0);
3748                }
3749
3750                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FORMAT,
3751                    finderArgs, count);
3752
3753                closeSession(session);
3754            }
3755        }
3756
3757        return count.intValue();
3758    }
3759
3760    public int countByN_T(long nodeId, String title) throws SystemException {
3761        Object[] finderArgs = new Object[] { new Long(nodeId), title };
3762
3763        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T,
3764                finderArgs, this);
3765
3766        if (count == null) {
3767            Session session = null;
3768
3769            try {
3770                session = openSession();
3771
3772                StringBundler query = new StringBundler(3);
3773
3774                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3775
3776                query.append(_FINDER_COLUMN_N_T_NODEID_2);
3777
3778                if (title == null) {
3779                    query.append(_FINDER_COLUMN_N_T_TITLE_1);
3780                }
3781                else {
3782                    if (title.equals(StringPool.BLANK)) {
3783                        query.append(_FINDER_COLUMN_N_T_TITLE_3);
3784                    }
3785                    else {
3786                        query.append(_FINDER_COLUMN_N_T_TITLE_2);
3787                    }
3788                }
3789
3790                String sql = query.toString();
3791
3792                Query q = session.createQuery(sql);
3793
3794                QueryPos qPos = QueryPos.getInstance(q);
3795
3796                qPos.add(nodeId);
3797
3798                if (title != null) {
3799                    qPos.add(title);
3800                }
3801
3802                count = (Long)q.uniqueResult();
3803            }
3804            catch (Exception e) {
3805                throw processException(e);
3806            }
3807            finally {
3808                if (count == null) {
3809                    count = Long.valueOf(0);
3810                }
3811
3812                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, finderArgs,
3813                    count);
3814
3815                closeSession(session);
3816            }
3817        }
3818
3819        return count.intValue();
3820    }
3821
3822    public int countByN_H(long nodeId, boolean head) throws SystemException {
3823        Object[] finderArgs = new Object[] {
3824                new Long(nodeId), Boolean.valueOf(head)
3825            };
3826
3827        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H,
3828                finderArgs, this);
3829
3830        if (count == null) {
3831            Session session = null;
3832
3833            try {
3834                session = openSession();
3835
3836                StringBundler query = new StringBundler(3);
3837
3838                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3839
3840                query.append(_FINDER_COLUMN_N_H_NODEID_2);
3841
3842                query.append(_FINDER_COLUMN_N_H_HEAD_2);
3843
3844                String sql = query.toString();
3845
3846                Query q = session.createQuery(sql);
3847
3848                QueryPos qPos = QueryPos.getInstance(q);
3849
3850                qPos.add(nodeId);
3851
3852                qPos.add(head);
3853
3854                count = (Long)q.uniqueResult();
3855            }
3856            catch (Exception e) {
3857                throw processException(e);
3858            }
3859            finally {
3860                if (count == null) {
3861                    count = Long.valueOf(0);
3862                }
3863
3864                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H, finderArgs,
3865                    count);
3866
3867                closeSession(session);
3868            }
3869        }
3870
3871        return count.intValue();
3872    }
3873
3874    public int countByN_P(long nodeId, String parentTitle)
3875        throws SystemException {
3876        Object[] finderArgs = new Object[] { new Long(nodeId), parentTitle };
3877
3878        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_P,
3879                finderArgs, this);
3880
3881        if (count == null) {
3882            Session session = null;
3883
3884            try {
3885                session = openSession();
3886
3887                StringBundler query = new StringBundler(3);
3888
3889                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3890
3891                query.append(_FINDER_COLUMN_N_P_NODEID_2);
3892
3893                if (parentTitle == null) {
3894                    query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
3895                }
3896                else {
3897                    if (parentTitle.equals(StringPool.BLANK)) {
3898                        query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
3899                    }
3900                    else {
3901                        query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
3902                    }
3903                }
3904
3905                String sql = query.toString();
3906
3907                Query q = session.createQuery(sql);
3908
3909                QueryPos qPos = QueryPos.getInstance(q);
3910
3911                qPos.add(nodeId);
3912
3913                if (parentTitle != null) {
3914                    qPos.add(parentTitle);
3915                }
3916
3917                count = (Long)q.uniqueResult();
3918            }
3919            catch (Exception e) {
3920                throw processException(e);
3921            }
3922            finally {
3923                if (count == null) {
3924                    count = Long.valueOf(0);
3925                }
3926
3927                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_P, finderArgs,
3928                    count);
3929
3930                closeSession(session);
3931            }
3932        }
3933
3934        return count.intValue();
3935    }
3936
3937    public int countByN_R(long nodeId, String redirectTitle)
3938        throws SystemException {
3939        Object[] finderArgs = new Object[] { new Long(nodeId), redirectTitle };
3940
3941        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_R,
3942                finderArgs, this);
3943
3944        if (count == null) {
3945            Session session = null;
3946
3947            try {
3948                session = openSession();
3949
3950                StringBundler query = new StringBundler(3);
3951
3952                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3953
3954                query.append(_FINDER_COLUMN_N_R_NODEID_2);
3955
3956                if (redirectTitle == null) {
3957                    query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
3958                }
3959                else {
3960                    if (redirectTitle.equals(StringPool.BLANK)) {
3961                        query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
3962                    }
3963                    else {
3964                        query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
3965                    }
3966                }
3967
3968                String sql = query.toString();
3969
3970                Query q = session.createQuery(sql);
3971
3972                QueryPos qPos = QueryPos.getInstance(q);
3973
3974                qPos.add(nodeId);
3975
3976                if (redirectTitle != null) {
3977                    qPos.add(redirectTitle);
3978                }
3979
3980                count = (Long)q.uniqueResult();
3981            }
3982            catch (Exception e) {
3983                throw processException(e);
3984            }
3985            finally {
3986                if (count == null) {
3987                    count = Long.valueOf(0);
3988                }
3989
3990                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_R, finderArgs,
3991                    count);
3992
3993                closeSession(session);
3994            }
3995        }
3996
3997        return count.intValue();
3998    }
3999
4000    public int countByN_T_V(long nodeId, String title, double version)
4001        throws SystemException {
4002        Object[] finderArgs = new Object[] {
4003                new Long(nodeId),
4004                
4005                title, new Double(version)
4006            };
4007
4008        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_V,
4009                finderArgs, this);
4010
4011        if (count == null) {
4012            Session session = null;
4013
4014            try {
4015                session = openSession();
4016
4017                StringBundler query = new StringBundler(4);
4018
4019                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4020
4021                query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
4022
4023                if (title == null) {
4024                    query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
4025                }
4026                else {
4027                    if (title.equals(StringPool.BLANK)) {
4028                        query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
4029                    }
4030                    else {
4031                        query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
4032                    }
4033                }
4034
4035                query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
4036
4037                String sql = query.toString();
4038
4039                Query q = session.createQuery(sql);
4040
4041                QueryPos qPos = QueryPos.getInstance(q);
4042
4043                qPos.add(nodeId);
4044
4045                if (title != null) {
4046                    qPos.add(title);
4047                }
4048
4049                qPos.add(version);
4050
4051                count = (Long)q.uniqueResult();
4052            }
4053            catch (Exception e) {
4054                throw processException(e);
4055            }
4056            finally {
4057                if (count == null) {
4058                    count = Long.valueOf(0);
4059                }
4060
4061                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V,
4062                    finderArgs, count);
4063
4064                closeSession(session);
4065            }
4066        }
4067
4068        return count.intValue();
4069    }
4070
4071    public int countByN_T_H(long nodeId, String title, boolean head)
4072        throws SystemException {
4073        Object[] finderArgs = new Object[] {
4074                new Long(nodeId),
4075                
4076                title, Boolean.valueOf(head)
4077            };
4078
4079        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_H,
4080                finderArgs, this);
4081
4082        if (count == null) {
4083            Session session = null;
4084
4085            try {
4086                session = openSession();
4087
4088                StringBundler query = new StringBundler(4);
4089
4090                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4091
4092                query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
4093
4094                if (title == null) {
4095                    query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
4096                }
4097                else {
4098                    if (title.equals(StringPool.BLANK)) {
4099                        query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
4100                    }
4101                    else {
4102                        query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
4103                    }
4104                }
4105
4106                query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
4107
4108                String sql = query.toString();
4109
4110                Query q = session.createQuery(sql);
4111
4112                QueryPos qPos = QueryPos.getInstance(q);
4113
4114                qPos.add(nodeId);
4115
4116                if (title != null) {
4117                    qPos.add(title);
4118                }
4119
4120                qPos.add(head);
4121
4122                count = (Long)q.uniqueResult();
4123            }
4124            catch (Exception e) {
4125                throw processException(e);
4126            }
4127            finally {
4128                if (count == null) {
4129                    count = Long.valueOf(0);
4130                }
4131
4132                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_H,
4133                    finderArgs, count);
4134
4135                closeSession(session);
4136            }
4137        }
4138
4139        return count.intValue();
4140    }
4141
4142    public int countByN_H_P(long nodeId, boolean head, String parentTitle)
4143        throws SystemException {
4144        Object[] finderArgs = new Object[] {
4145                new Long(nodeId), Boolean.valueOf(head),
4146                
4147                parentTitle
4148            };
4149
4150        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H_P,
4151                finderArgs, this);
4152
4153        if (count == null) {
4154            Session session = null;
4155
4156            try {
4157                session = openSession();
4158
4159                StringBundler query = new StringBundler(4);
4160
4161                query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4162
4163                query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
4164
4165                query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
4166
4167                if (parentTitle == null) {
4168                    query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
4169                }
4170                else {
4171                    if (parentTitle.equals(StringPool.BLANK)) {
4172                        query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
4173                    }
4174                    else {
4175                        query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
4176                    }
4177                }
4178
4179                String sql = query.toString();
4180
4181                Query q = session.createQuery(sql);
4182
4183                QueryPos qPos = QueryPos.getInstance(q);
4184
4185                qPos.add(nodeId);
4186
4187                qPos.add(head);
4188
4189                if (parentTitle != null) {
4190                    qPos.add(parentTitle);
4191                }
4192
4193                count = (Long)q.uniqueResult();
4194            }
4195            catch (Exception e) {
4196                throw processException(e);
4197            }
4198            finally {
4199                if (count == null) {
4200                    count = Long.valueOf(0);
4201                }
4202
4203                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H_P,
4204                    finderArgs, count);
4205
4206                closeSession(session);
4207            }
4208        }
4209
4210        return count.intValue();
4211    }
4212
4213    public int countAll() throws SystemException {
4214        Object[] finderArgs = new Object[0];
4215
4216        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4217                finderArgs, this);
4218
4219        if (count == null) {
4220            Session session = null;
4221
4222            try {
4223                session = openSession();
4224
4225                Query q = session.createQuery(_SQL_COUNT_WIKIPAGE);
4226
4227                count = (Long)q.uniqueResult();
4228            }
4229            catch (Exception e) {
4230                throw processException(e);
4231            }
4232            finally {
4233                if (count == null) {
4234                    count = Long.valueOf(0);
4235                }
4236
4237                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
4238                    count);
4239
4240                closeSession(session);
4241            }
4242        }
4243
4244        return count.intValue();
4245    }
4246
4247    public void afterPropertiesSet() {
4248        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4249                    com.liferay.portal.util.PropsUtil.get(
4250                        "value.object.listener.com.liferay.portlet.wiki.model.WikiPage")));
4251
4252        if (listenerClassNames.length > 0) {
4253            try {
4254                List<ModelListener<WikiPage>> listenersList = new ArrayList<ModelListener<WikiPage>>();
4255
4256                for (String listenerClassName : listenerClassNames) {
4257                    listenersList.add((ModelListener<WikiPage>)Class.forName(
4258                            listenerClassName).newInstance());
4259                }
4260
4261                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4262            }
4263            catch (Exception e) {
4264                _log.error(e);
4265            }
4266        }
4267    }
4268
4269    @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiNodePersistence")
4270    protected com.liferay.portlet.wiki.service.persistence.WikiNodePersistence wikiNodePersistence;
4271    @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPagePersistence")
4272    protected com.liferay.portlet.wiki.service.persistence.WikiPagePersistence wikiPagePersistence;
4273    @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence")
4274    protected com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence wikiPageResourcePersistence;
4275    @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
4276    protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
4277    @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
4278    protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
4279    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
4280    protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
4281    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
4282    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
4283    @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
4284    protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
4285    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
4286    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
4287    @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence")
4288    protected com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4289    @BeanReference(name = "com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence")
4290    protected com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence assetCategoryPersistence;
4291    @BeanReference(name = "com.liferay.portlet.asset.service.persistence.AssetEntryPersistence")
4292    protected com.liferay.portlet.asset.service.persistence.AssetEntryPersistence assetEntryPersistence;
4293    @BeanReference(name = "com.liferay.portlet.asset.service.persistence.AssetTagPersistence")
4294    protected com.liferay.portlet.asset.service.persistence.AssetTagPersistence assetTagPersistence;
4295    @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence")
4296    protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
4297    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence")
4298    protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
4299    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence")
4300    protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
4301    private static final String _SQL_SELECT_WIKIPAGE = "SELECT wikiPage FROM WikiPage wikiPage";
4302    private static final String _SQL_SELECT_WIKIPAGE_WHERE = "SELECT wikiPage FROM WikiPage wikiPage WHERE ";
4303    private static final String _SQL_COUNT_WIKIPAGE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage";
4304    private static final String _SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage WHERE ";
4305    private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiPage.uuid IS NULL";
4306    private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiPage.uuid = ?";
4307    private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = ?)";
4308    private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiPage.uuid IS NULL AND ";
4309    private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiPage.uuid = ? AND ";
4310    private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = ?) AND ";
4311    private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiPage.groupId = ?";
4312    private static final String _FINDER_COLUMN_NODEID_NODEID_2 = "wikiPage.nodeId = ?";
4313    private static final String _FINDER_COLUMN_FORMAT_FORMAT_1 = "wikiPage.format IS NULL";
4314    private static final String _FINDER_COLUMN_FORMAT_FORMAT_2 = "wikiPage.format = ?";
4315    private static final String _FINDER_COLUMN_FORMAT_FORMAT_3 = "(wikiPage.format IS NULL OR wikiPage.format = ?)";
4316    private static final String _FINDER_COLUMN_N_T_NODEID_2 = "wikiPage.nodeId = ? AND ";
4317    private static final String _FINDER_COLUMN_N_T_TITLE_1 = "wikiPage.title IS NULL";
4318    private static final String _FINDER_COLUMN_N_T_TITLE_2 = "wikiPage.title = ?";
4319    private static final String _FINDER_COLUMN_N_T_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = ?)";
4320    private static final String _FINDER_COLUMN_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
4321    private static final String _FINDER_COLUMN_N_H_HEAD_2 = "wikiPage.head = ?";
4322    private static final String _FINDER_COLUMN_N_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
4323    private static final String _FINDER_COLUMN_N_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
4324    private static final String _FINDER_COLUMN_N_P_PARENTTITLE_2 = "wikiPage.parentTitle = ?";
4325    private static final String _FINDER_COLUMN_N_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = ?)";
4326    private static final String _FINDER_COLUMN_N_R_NODEID_2 = "wikiPage.nodeId = ? AND ";
4327    private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL";
4328    private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_2 = "wikiPage.redirectTitle = ?";
4329    private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR wikiPage.redirectTitle = ?)";
4330    private static final String _FINDER_COLUMN_N_T_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
4331    private static final String _FINDER_COLUMN_N_T_V_TITLE_1 = "wikiPage.title IS NULL AND ";
4332    private static final String _FINDER_COLUMN_N_T_V_TITLE_2 = "wikiPage.title = ? AND ";
4333    private static final String _FINDER_COLUMN_N_T_V_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = ?) AND ";
4334    private static final String _FINDER_COLUMN_N_T_V_VERSION_2 = "wikiPage.version = ?";
4335    private static final String _FINDER_COLUMN_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
4336    private static final String _FINDER_COLUMN_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
4337    private static final String _FINDER_COLUMN_N_T_H_TITLE_2 = "wikiPage.title = ? AND ";
4338    private static final String _FINDER_COLUMN_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = ?) AND ";
4339    private static final String _FINDER_COLUMN_N_T_H_HEAD_2 = "wikiPage.head = ?";
4340    private static final String _FINDER_COLUMN_N_H_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
4341    private static final String _FINDER_COLUMN_N_H_P_HEAD_2 = "wikiPage.head = ? AND ";
4342    private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
4343    private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_2 = "wikiPage.parentTitle = ?";
4344    private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = ?)";
4345    private static final String _ORDER_BY_ENTITY_ALIAS = "wikiPage.";
4346    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiPage exists with the primary key ";
4347    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiPage exists with the key {";
4348    private static Log _log = LogFactoryUtil.getLog(WikiPagePersistenceImpl.class);
4349}