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