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