1
22
23 package com.liferay.portlet.wiki.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.DynamicQuery;
27 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
28 import com.liferay.portal.kernel.util.OrderByComparator;
29 import com.liferay.portal.kernel.util.StringMaker;
30 import com.liferay.portal.kernel.util.StringPool;
31 import com.liferay.portal.service.persistence.BasePersistence;
32 import com.liferay.portal.spring.hibernate.FinderCache;
33 import com.liferay.portal.spring.hibernate.HibernateUtil;
34
35 import com.liferay.portlet.wiki.NoSuchPageException;
36 import com.liferay.portlet.wiki.model.WikiPage;
37 import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
38
39 import com.liferay.util.dao.hibernate.QueryUtil;
40
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43
44 import org.hibernate.Query;
45 import org.hibernate.Session;
46
47 import java.util.Collections;
48 import java.util.Iterator;
49 import java.util.List;
50
51
57 public class WikiPagePersistenceImpl extends BasePersistence
58 implements WikiPagePersistence {
59 public WikiPage create(long pageId) {
60 WikiPage wikiPage = new WikiPageImpl();
61 wikiPage.setNew(true);
62 wikiPage.setPrimaryKey(pageId);
63
64 return wikiPage;
65 }
66
67 public WikiPage remove(long pageId)
68 throws NoSuchPageException, SystemException {
69 Session session = null;
70
71 try {
72 session = openSession();
73
74 WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
75 new Long(pageId));
76
77 if (wikiPage == null) {
78 if (_log.isWarnEnabled()) {
79 _log.warn("No WikiPage exists with the primary key " +
80 pageId);
81 }
82
83 throw new NoSuchPageException(
84 "No WikiPage exists with the primary key " + pageId);
85 }
86
87 return remove(wikiPage);
88 }
89 catch (NoSuchPageException nsee) {
90 throw nsee;
91 }
92 catch (Exception e) {
93 throw HibernateUtil.processException(e);
94 }
95 finally {
96 closeSession(session);
97 }
98 }
99
100 public WikiPage remove(WikiPage wikiPage) throws SystemException {
101 Session session = null;
102
103 try {
104 session = openSession();
105 session.delete(wikiPage);
106 session.flush();
107
108 return wikiPage;
109 }
110 catch (Exception e) {
111 throw HibernateUtil.processException(e);
112 }
113 finally {
114 closeSession(session);
115 FinderCache.clearCache(WikiPage.class.getName());
116 }
117 }
118
119 public WikiPage update(com.liferay.portlet.wiki.model.WikiPage wikiPage)
120 throws SystemException {
121 return update(wikiPage, false);
122 }
123
124 public WikiPage update(com.liferay.portlet.wiki.model.WikiPage wikiPage,
125 boolean merge) throws SystemException {
126 Session session = null;
127
128 try {
129 session = openSession();
130
131 if (merge) {
132 session.merge(wikiPage);
133 }
134 else {
135 if (wikiPage.isNew()) {
136 session.save(wikiPage);
137 }
138 }
139
140 session.flush();
141 wikiPage.setNew(false);
142
143 return wikiPage;
144 }
145 catch (Exception e) {
146 throw HibernateUtil.processException(e);
147 }
148 finally {
149 closeSession(session);
150 FinderCache.clearCache(WikiPage.class.getName());
151 }
152 }
153
154 public WikiPage findByPrimaryKey(long pageId)
155 throws NoSuchPageException, SystemException {
156 WikiPage wikiPage = fetchByPrimaryKey(pageId);
157
158 if (wikiPage == null) {
159 if (_log.isWarnEnabled()) {
160 _log.warn("No WikiPage exists with the primary key " + pageId);
161 }
162
163 throw new NoSuchPageException(
164 "No WikiPage exists with the primary key " + pageId);
165 }
166
167 return wikiPage;
168 }
169
170 public WikiPage fetchByPrimaryKey(long pageId) throws SystemException {
171 Session session = null;
172
173 try {
174 session = openSession();
175
176 return (WikiPage)session.get(WikiPageImpl.class, new Long(pageId));
177 }
178 catch (Exception e) {
179 throw HibernateUtil.processException(e);
180 }
181 finally {
182 closeSession(session);
183 }
184 }
185
186 public List findByNodeId(long nodeId) throws SystemException {
187 String finderClassName = WikiPage.class.getName();
188 String finderMethodName = "findByNodeId";
189 String[] finderParams = new String[] { Long.class.getName() };
190 Object[] finderArgs = new Object[] { new Long(nodeId) };
191 Object result = FinderCache.getResult(finderClassName,
192 finderMethodName, finderParams, finderArgs, getSessionFactory());
193
194 if (result == null) {
195 Session session = null;
196
197 try {
198 session = openSession();
199
200 StringMaker query = new StringMaker();
201 query.append(
202 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
203 query.append("nodeId = ?");
204 query.append(" ");
205 query.append("ORDER BY ");
206 query.append("nodeId ASC").append(", ");
207 query.append("title ASC").append(", ");
208 query.append("version ASC");
209
210 Query q = session.createQuery(query.toString());
211 int queryPos = 0;
212 q.setLong(queryPos++, nodeId);
213
214 List list = q.list();
215 FinderCache.putResult(finderClassName, finderMethodName,
216 finderParams, finderArgs, list);
217
218 return list;
219 }
220 catch (Exception e) {
221 throw HibernateUtil.processException(e);
222 }
223 finally {
224 closeSession(session);
225 }
226 }
227 else {
228 return (List)result;
229 }
230 }
231
232 public List findByNodeId(long nodeId, int begin, int end)
233 throws SystemException {
234 return findByNodeId(nodeId, begin, end, null);
235 }
236
237 public List findByNodeId(long nodeId, int begin, int end,
238 OrderByComparator obc) throws SystemException {
239 String finderClassName = WikiPage.class.getName();
240 String finderMethodName = "findByNodeId";
241 String[] finderParams = new String[] {
242 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
243 "com.liferay.portal.kernel.util.OrderByComparator"
244 };
245 Object[] finderArgs = new Object[] {
246 new Long(nodeId), String.valueOf(begin), String.valueOf(end),
247 String.valueOf(obc)
248 };
249 Object result = FinderCache.getResult(finderClassName,
250 finderMethodName, finderParams, finderArgs, getSessionFactory());
251
252 if (result == null) {
253 Session session = null;
254
255 try {
256 session = openSession();
257
258 StringMaker query = new StringMaker();
259 query.append(
260 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
261 query.append("nodeId = ?");
262 query.append(" ");
263
264 if (obc != null) {
265 query.append("ORDER BY ");
266 query.append(obc.getOrderBy());
267 }
268 else {
269 query.append("ORDER BY ");
270 query.append("nodeId ASC").append(", ");
271 query.append("title ASC").append(", ");
272 query.append("version ASC");
273 }
274
275 Query q = session.createQuery(query.toString());
276 int queryPos = 0;
277 q.setLong(queryPos++, nodeId);
278
279 List list = QueryUtil.list(q, getDialect(), begin, end);
280 FinderCache.putResult(finderClassName, finderMethodName,
281 finderParams, finderArgs, list);
282
283 return list;
284 }
285 catch (Exception e) {
286 throw HibernateUtil.processException(e);
287 }
288 finally {
289 closeSession(session);
290 }
291 }
292 else {
293 return (List)result;
294 }
295 }
296
297 public WikiPage findByNodeId_First(long nodeId, OrderByComparator obc)
298 throws NoSuchPageException, SystemException {
299 List list = findByNodeId(nodeId, 0, 1, obc);
300
301 if (list.size() == 0) {
302 StringMaker msg = new StringMaker();
303 msg.append("No WikiPage exists with the key ");
304 msg.append(StringPool.OPEN_CURLY_BRACE);
305 msg.append("nodeId=");
306 msg.append(nodeId);
307 msg.append(StringPool.CLOSE_CURLY_BRACE);
308 throw new NoSuchPageException(msg.toString());
309 }
310 else {
311 return (WikiPage)list.get(0);
312 }
313 }
314
315 public WikiPage findByNodeId_Last(long nodeId, OrderByComparator obc)
316 throws NoSuchPageException, SystemException {
317 int count = countByNodeId(nodeId);
318 List list = findByNodeId(nodeId, count - 1, count, obc);
319
320 if (list.size() == 0) {
321 StringMaker msg = new StringMaker();
322 msg.append("No WikiPage exists with the key ");
323 msg.append(StringPool.OPEN_CURLY_BRACE);
324 msg.append("nodeId=");
325 msg.append(nodeId);
326 msg.append(StringPool.CLOSE_CURLY_BRACE);
327 throw new NoSuchPageException(msg.toString());
328 }
329 else {
330 return (WikiPage)list.get(0);
331 }
332 }
333
334 public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
335 OrderByComparator obc) throws NoSuchPageException, SystemException {
336 WikiPage wikiPage = findByPrimaryKey(pageId);
337 int count = countByNodeId(nodeId);
338 Session session = null;
339
340 try {
341 session = openSession();
342
343 StringMaker query = new StringMaker();
344 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
345 query.append("nodeId = ?");
346 query.append(" ");
347
348 if (obc != null) {
349 query.append("ORDER BY ");
350 query.append(obc.getOrderBy());
351 }
352 else {
353 query.append("ORDER BY ");
354 query.append("nodeId ASC").append(", ");
355 query.append("title ASC").append(", ");
356 query.append("version ASC");
357 }
358
359 Query q = session.createQuery(query.toString());
360 int queryPos = 0;
361 q.setLong(queryPos++, nodeId);
362
363 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
364 WikiPage[] array = new WikiPageImpl[3];
365 array[0] = (WikiPage)objArray[0];
366 array[1] = (WikiPage)objArray[1];
367 array[2] = (WikiPage)objArray[2];
368
369 return array;
370 }
371 catch (Exception e) {
372 throw HibernateUtil.processException(e);
373 }
374 finally {
375 closeSession(session);
376 }
377 }
378
379 public List findByN_T(long nodeId, String title) throws SystemException {
380 String finderClassName = WikiPage.class.getName();
381 String finderMethodName = "findByN_T";
382 String[] finderParams = new String[] {
383 Long.class.getName(), String.class.getName()
384 };
385 Object[] finderArgs = new Object[] { new Long(nodeId), title };
386 Object result = FinderCache.getResult(finderClassName,
387 finderMethodName, finderParams, finderArgs, getSessionFactory());
388
389 if (result == null) {
390 Session session = null;
391
392 try {
393 session = openSession();
394
395 StringMaker query = new StringMaker();
396 query.append(
397 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
398 query.append("nodeId = ?");
399 query.append(" AND ");
400
401 if (title == null) {
402 query.append("title IS NULL");
403 }
404 else {
405 query.append("title = ?");
406 }
407
408 query.append(" ");
409 query.append("ORDER BY ");
410 query.append("nodeId ASC").append(", ");
411 query.append("title ASC").append(", ");
412 query.append("version ASC");
413
414 Query q = session.createQuery(query.toString());
415 int queryPos = 0;
416 q.setLong(queryPos++, nodeId);
417
418 if (title != null) {
419 q.setString(queryPos++, title);
420 }
421
422 List list = q.list();
423 FinderCache.putResult(finderClassName, finderMethodName,
424 finderParams, finderArgs, list);
425
426 return list;
427 }
428 catch (Exception e) {
429 throw HibernateUtil.processException(e);
430 }
431 finally {
432 closeSession(session);
433 }
434 }
435 else {
436 return (List)result;
437 }
438 }
439
440 public List findByN_T(long nodeId, String title, int begin, int end)
441 throws SystemException {
442 return findByN_T(nodeId, title, begin, end, null);
443 }
444
445 public List findByN_T(long nodeId, String title, int begin, int end,
446 OrderByComparator obc) throws SystemException {
447 String finderClassName = WikiPage.class.getName();
448 String finderMethodName = "findByN_T";
449 String[] finderParams = new String[] {
450 Long.class.getName(), String.class.getName(),
451 "java.lang.Integer", "java.lang.Integer",
452 "com.liferay.portal.kernel.util.OrderByComparator"
453 };
454 Object[] finderArgs = new Object[] {
455 new Long(nodeId), title, String.valueOf(begin),
456 String.valueOf(end), String.valueOf(obc)
457 };
458 Object result = FinderCache.getResult(finderClassName,
459 finderMethodName, finderParams, finderArgs, getSessionFactory());
460
461 if (result == null) {
462 Session session = null;
463
464 try {
465 session = openSession();
466
467 StringMaker query = new StringMaker();
468 query.append(
469 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
470 query.append("nodeId = ?");
471 query.append(" AND ");
472
473 if (title == null) {
474 query.append("title IS NULL");
475 }
476 else {
477 query.append("title = ?");
478 }
479
480 query.append(" ");
481
482 if (obc != null) {
483 query.append("ORDER BY ");
484 query.append(obc.getOrderBy());
485 }
486 else {
487 query.append("ORDER BY ");
488 query.append("nodeId ASC").append(", ");
489 query.append("title ASC").append(", ");
490 query.append("version ASC");
491 }
492
493 Query q = session.createQuery(query.toString());
494 int queryPos = 0;
495 q.setLong(queryPos++, nodeId);
496
497 if (title != null) {
498 q.setString(queryPos++, title);
499 }
500
501 List list = QueryUtil.list(q, getDialect(), begin, end);
502 FinderCache.putResult(finderClassName, finderMethodName,
503 finderParams, finderArgs, list);
504
505 return list;
506 }
507 catch (Exception e) {
508 throw HibernateUtil.processException(e);
509 }
510 finally {
511 closeSession(session);
512 }
513 }
514 else {
515 return (List)result;
516 }
517 }
518
519 public WikiPage findByN_T_First(long nodeId, String title,
520 OrderByComparator obc) throws NoSuchPageException, SystemException {
521 List list = findByN_T(nodeId, title, 0, 1, obc);
522
523 if (list.size() == 0) {
524 StringMaker msg = new StringMaker();
525 msg.append("No WikiPage exists with the key ");
526 msg.append(StringPool.OPEN_CURLY_BRACE);
527 msg.append("nodeId=");
528 msg.append(nodeId);
529 msg.append(", ");
530 msg.append("title=");
531 msg.append(title);
532 msg.append(StringPool.CLOSE_CURLY_BRACE);
533 throw new NoSuchPageException(msg.toString());
534 }
535 else {
536 return (WikiPage)list.get(0);
537 }
538 }
539
540 public WikiPage findByN_T_Last(long nodeId, String title,
541 OrderByComparator obc) throws NoSuchPageException, SystemException {
542 int count = countByN_T(nodeId, title);
543 List list = findByN_T(nodeId, title, count - 1, count, obc);
544
545 if (list.size() == 0) {
546 StringMaker msg = new StringMaker();
547 msg.append("No WikiPage exists with the key ");
548 msg.append(StringPool.OPEN_CURLY_BRACE);
549 msg.append("nodeId=");
550 msg.append(nodeId);
551 msg.append(", ");
552 msg.append("title=");
553 msg.append(title);
554 msg.append(StringPool.CLOSE_CURLY_BRACE);
555 throw new NoSuchPageException(msg.toString());
556 }
557 else {
558 return (WikiPage)list.get(0);
559 }
560 }
561
562 public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
563 String title, OrderByComparator obc)
564 throws NoSuchPageException, SystemException {
565 WikiPage wikiPage = findByPrimaryKey(pageId);
566 int count = countByN_T(nodeId, title);
567 Session session = null;
568
569 try {
570 session = openSession();
571
572 StringMaker query = new StringMaker();
573 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
574 query.append("nodeId = ?");
575 query.append(" AND ");
576
577 if (title == null) {
578 query.append("title IS NULL");
579 }
580 else {
581 query.append("title = ?");
582 }
583
584 query.append(" ");
585
586 if (obc != null) {
587 query.append("ORDER BY ");
588 query.append(obc.getOrderBy());
589 }
590 else {
591 query.append("ORDER BY ");
592 query.append("nodeId ASC").append(", ");
593 query.append("title ASC").append(", ");
594 query.append("version ASC");
595 }
596
597 Query q = session.createQuery(query.toString());
598 int queryPos = 0;
599 q.setLong(queryPos++, nodeId);
600
601 if (title != null) {
602 q.setString(queryPos++, title);
603 }
604
605 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
606 WikiPage[] array = new WikiPageImpl[3];
607 array[0] = (WikiPage)objArray[0];
608 array[1] = (WikiPage)objArray[1];
609 array[2] = (WikiPage)objArray[2];
610
611 return array;
612 }
613 catch (Exception e) {
614 throw HibernateUtil.processException(e);
615 }
616 finally {
617 closeSession(session);
618 }
619 }
620
621 public List findByN_H(long nodeId, boolean head) throws SystemException {
622 String finderClassName = WikiPage.class.getName();
623 String finderMethodName = "findByN_H";
624 String[] finderParams = new String[] {
625 Long.class.getName(), Boolean.class.getName()
626 };
627 Object[] finderArgs = new Object[] {
628 new Long(nodeId), Boolean.valueOf(head)
629 };
630 Object result = FinderCache.getResult(finderClassName,
631 finderMethodName, finderParams, finderArgs, getSessionFactory());
632
633 if (result == null) {
634 Session session = null;
635
636 try {
637 session = openSession();
638
639 StringMaker query = new StringMaker();
640 query.append(
641 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
642 query.append("nodeId = ?");
643 query.append(" AND ");
644 query.append("head = ?");
645 query.append(" ");
646 query.append("ORDER BY ");
647 query.append("nodeId ASC").append(", ");
648 query.append("title ASC").append(", ");
649 query.append("version ASC");
650
651 Query q = session.createQuery(query.toString());
652 int queryPos = 0;
653 q.setLong(queryPos++, nodeId);
654 q.setBoolean(queryPos++, head);
655
656 List list = q.list();
657 FinderCache.putResult(finderClassName, finderMethodName,
658 finderParams, finderArgs, list);
659
660 return list;
661 }
662 catch (Exception e) {
663 throw HibernateUtil.processException(e);
664 }
665 finally {
666 closeSession(session);
667 }
668 }
669 else {
670 return (List)result;
671 }
672 }
673
674 public List findByN_H(long nodeId, boolean head, int begin, int end)
675 throws SystemException {
676 return findByN_H(nodeId, head, begin, end, null);
677 }
678
679 public List findByN_H(long nodeId, boolean head, int begin, int end,
680 OrderByComparator obc) throws SystemException {
681 String finderClassName = WikiPage.class.getName();
682 String finderMethodName = "findByN_H";
683 String[] finderParams = new String[] {
684 Long.class.getName(), Boolean.class.getName(),
685 "java.lang.Integer", "java.lang.Integer",
686 "com.liferay.portal.kernel.util.OrderByComparator"
687 };
688 Object[] finderArgs = new Object[] {
689 new Long(nodeId), Boolean.valueOf(head), String.valueOf(begin),
690 String.valueOf(end), String.valueOf(obc)
691 };
692 Object result = FinderCache.getResult(finderClassName,
693 finderMethodName, finderParams, finderArgs, getSessionFactory());
694
695 if (result == null) {
696 Session session = null;
697
698 try {
699 session = openSession();
700
701 StringMaker query = new StringMaker();
702 query.append(
703 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
704 query.append("nodeId = ?");
705 query.append(" AND ");
706 query.append("head = ?");
707 query.append(" ");
708
709 if (obc != null) {
710 query.append("ORDER BY ");
711 query.append(obc.getOrderBy());
712 }
713 else {
714 query.append("ORDER BY ");
715 query.append("nodeId ASC").append(", ");
716 query.append("title ASC").append(", ");
717 query.append("version ASC");
718 }
719
720 Query q = session.createQuery(query.toString());
721 int queryPos = 0;
722 q.setLong(queryPos++, nodeId);
723 q.setBoolean(queryPos++, head);
724
725 List list = QueryUtil.list(q, getDialect(), begin, end);
726 FinderCache.putResult(finderClassName, finderMethodName,
727 finderParams, finderArgs, list);
728
729 return list;
730 }
731 catch (Exception e) {
732 throw HibernateUtil.processException(e);
733 }
734 finally {
735 closeSession(session);
736 }
737 }
738 else {
739 return (List)result;
740 }
741 }
742
743 public WikiPage findByN_H_First(long nodeId, boolean head,
744 OrderByComparator obc) throws NoSuchPageException, SystemException {
745 List list = findByN_H(nodeId, head, 0, 1, obc);
746
747 if (list.size() == 0) {
748 StringMaker msg = new StringMaker();
749 msg.append("No WikiPage exists with the key ");
750 msg.append(StringPool.OPEN_CURLY_BRACE);
751 msg.append("nodeId=");
752 msg.append(nodeId);
753 msg.append(", ");
754 msg.append("head=");
755 msg.append(head);
756 msg.append(StringPool.CLOSE_CURLY_BRACE);
757 throw new NoSuchPageException(msg.toString());
758 }
759 else {
760 return (WikiPage)list.get(0);
761 }
762 }
763
764 public WikiPage findByN_H_Last(long nodeId, boolean head,
765 OrderByComparator obc) throws NoSuchPageException, SystemException {
766 int count = countByN_H(nodeId, head);
767 List list = findByN_H(nodeId, head, count - 1, count, obc);
768
769 if (list.size() == 0) {
770 StringMaker msg = new StringMaker();
771 msg.append("No WikiPage exists with the key ");
772 msg.append(StringPool.OPEN_CURLY_BRACE);
773 msg.append("nodeId=");
774 msg.append(nodeId);
775 msg.append(", ");
776 msg.append("head=");
777 msg.append(head);
778 msg.append(StringPool.CLOSE_CURLY_BRACE);
779 throw new NoSuchPageException(msg.toString());
780 }
781 else {
782 return (WikiPage)list.get(0);
783 }
784 }
785
786 public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
787 boolean head, OrderByComparator obc)
788 throws NoSuchPageException, SystemException {
789 WikiPage wikiPage = findByPrimaryKey(pageId);
790 int count = countByN_H(nodeId, head);
791 Session session = null;
792
793 try {
794 session = openSession();
795
796 StringMaker query = new StringMaker();
797 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
798 query.append("nodeId = ?");
799 query.append(" AND ");
800 query.append("head = ?");
801 query.append(" ");
802
803 if (obc != null) {
804 query.append("ORDER BY ");
805 query.append(obc.getOrderBy());
806 }
807 else {
808 query.append("ORDER BY ");
809 query.append("nodeId ASC").append(", ");
810 query.append("title ASC").append(", ");
811 query.append("version ASC");
812 }
813
814 Query q = session.createQuery(query.toString());
815 int queryPos = 0;
816 q.setLong(queryPos++, nodeId);
817 q.setBoolean(queryPos++, head);
818
819 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
820 WikiPage[] array = new WikiPageImpl[3];
821 array[0] = (WikiPage)objArray[0];
822 array[1] = (WikiPage)objArray[1];
823 array[2] = (WikiPage)objArray[2];
824
825 return array;
826 }
827 catch (Exception e) {
828 throw HibernateUtil.processException(e);
829 }
830 finally {
831 closeSession(session);
832 }
833 }
834
835 public WikiPage findByN_T_V(long nodeId, String title, double version)
836 throws NoSuchPageException, SystemException {
837 WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
838
839 if (wikiPage == null) {
840 StringMaker msg = new StringMaker();
841 msg.append("No WikiPage exists with the key ");
842 msg.append(StringPool.OPEN_CURLY_BRACE);
843 msg.append("nodeId=");
844 msg.append(nodeId);
845 msg.append(", ");
846 msg.append("title=");
847 msg.append(title);
848 msg.append(", ");
849 msg.append("version=");
850 msg.append(version);
851 msg.append(StringPool.CLOSE_CURLY_BRACE);
852
853 if (_log.isWarnEnabled()) {
854 _log.warn(msg.toString());
855 }
856
857 throw new NoSuchPageException(msg.toString());
858 }
859
860 return wikiPage;
861 }
862
863 public WikiPage fetchByN_T_V(long nodeId, String title, double version)
864 throws SystemException {
865 String finderClassName = WikiPage.class.getName();
866 String finderMethodName = "fetchByN_T_V";
867 String[] finderParams = new String[] {
868 Long.class.getName(), String.class.getName(),
869 Double.class.getName()
870 };
871 Object[] finderArgs = new Object[] {
872 new Long(nodeId), title, new Double(version)
873 };
874 Object result = FinderCache.getResult(finderClassName,
875 finderMethodName, finderParams, finderArgs, getSessionFactory());
876
877 if (result == null) {
878 Session session = null;
879
880 try {
881 session = openSession();
882
883 StringMaker query = new StringMaker();
884 query.append(
885 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
886 query.append("nodeId = ?");
887 query.append(" AND ");
888
889 if (title == null) {
890 query.append("title IS NULL");
891 }
892 else {
893 query.append("title = ?");
894 }
895
896 query.append(" AND ");
897 query.append("version = ?");
898 query.append(" ");
899 query.append("ORDER BY ");
900 query.append("nodeId ASC").append(", ");
901 query.append("title ASC").append(", ");
902 query.append("version ASC");
903
904 Query q = session.createQuery(query.toString());
905 int queryPos = 0;
906 q.setLong(queryPos++, nodeId);
907
908 if (title != null) {
909 q.setString(queryPos++, title);
910 }
911
912 q.setDouble(queryPos++, version);
913
914 List list = q.list();
915 FinderCache.putResult(finderClassName, finderMethodName,
916 finderParams, finderArgs, list);
917
918 if (list.size() == 0) {
919 return null;
920 }
921 else {
922 return (WikiPage)list.get(0);
923 }
924 }
925 catch (Exception e) {
926 throw HibernateUtil.processException(e);
927 }
928 finally {
929 closeSession(session);
930 }
931 }
932 else {
933 List list = (List)result;
934
935 if (list.size() == 0) {
936 return null;
937 }
938 else {
939 return (WikiPage)list.get(0);
940 }
941 }
942 }
943
944 public List findByN_T_H(long nodeId, String title, boolean head)
945 throws SystemException {
946 String finderClassName = WikiPage.class.getName();
947 String finderMethodName = "findByN_T_H";
948 String[] finderParams = new String[] {
949 Long.class.getName(), String.class.getName(),
950 Boolean.class.getName()
951 };
952 Object[] finderArgs = new Object[] {
953 new Long(nodeId), title, Boolean.valueOf(head)
954 };
955 Object result = FinderCache.getResult(finderClassName,
956 finderMethodName, finderParams, finderArgs, getSessionFactory());
957
958 if (result == null) {
959 Session session = null;
960
961 try {
962 session = openSession();
963
964 StringMaker query = new StringMaker();
965 query.append(
966 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
967 query.append("nodeId = ?");
968 query.append(" AND ");
969
970 if (title == null) {
971 query.append("title IS NULL");
972 }
973 else {
974 query.append("title = ?");
975 }
976
977 query.append(" AND ");
978 query.append("head = ?");
979 query.append(" ");
980 query.append("ORDER BY ");
981 query.append("nodeId ASC").append(", ");
982 query.append("title ASC").append(", ");
983 query.append("version ASC");
984
985 Query q = session.createQuery(query.toString());
986 int queryPos = 0;
987 q.setLong(queryPos++, nodeId);
988
989 if (title != null) {
990 q.setString(queryPos++, title);
991 }
992
993 q.setBoolean(queryPos++, head);
994
995 List list = q.list();
996 FinderCache.putResult(finderClassName, finderMethodName,
997 finderParams, finderArgs, list);
998
999 return list;
1000 }
1001 catch (Exception e) {
1002 throw HibernateUtil.processException(e);
1003 }
1004 finally {
1005 closeSession(session);
1006 }
1007 }
1008 else {
1009 return (List)result;
1010 }
1011 }
1012
1013 public List findByN_T_H(long nodeId, String title, boolean head, int begin,
1014 int end) throws SystemException {
1015 return findByN_T_H(nodeId, title, head, begin, end, null);
1016 }
1017
1018 public List findByN_T_H(long nodeId, String title, boolean head, int begin,
1019 int end, OrderByComparator obc) throws SystemException {
1020 String finderClassName = WikiPage.class.getName();
1021 String finderMethodName = "findByN_T_H";
1022 String[] finderParams = new String[] {
1023 Long.class.getName(), String.class.getName(),
1024 Boolean.class.getName(), "java.lang.Integer",
1025 "java.lang.Integer",
1026 "com.liferay.portal.kernel.util.OrderByComparator"
1027 };
1028 Object[] finderArgs = new Object[] {
1029 new Long(nodeId), title, Boolean.valueOf(head),
1030 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1031 };
1032 Object result = FinderCache.getResult(finderClassName,
1033 finderMethodName, finderParams, finderArgs, getSessionFactory());
1034
1035 if (result == null) {
1036 Session session = null;
1037
1038 try {
1039 session = openSession();
1040
1041 StringMaker query = new StringMaker();
1042 query.append(
1043 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1044 query.append("nodeId = ?");
1045 query.append(" AND ");
1046
1047 if (title == null) {
1048 query.append("title IS NULL");
1049 }
1050 else {
1051 query.append("title = ?");
1052 }
1053
1054 query.append(" AND ");
1055 query.append("head = ?");
1056 query.append(" ");
1057
1058 if (obc != null) {
1059 query.append("ORDER BY ");
1060 query.append(obc.getOrderBy());
1061 }
1062 else {
1063 query.append("ORDER BY ");
1064 query.append("nodeId ASC").append(", ");
1065 query.append("title ASC").append(", ");
1066 query.append("version ASC");
1067 }
1068
1069 Query q = session.createQuery(query.toString());
1070 int queryPos = 0;
1071 q.setLong(queryPos++, nodeId);
1072
1073 if (title != null) {
1074 q.setString(queryPos++, title);
1075 }
1076
1077 q.setBoolean(queryPos++, head);
1078
1079 List list = QueryUtil.list(q, getDialect(), begin, end);
1080 FinderCache.putResult(finderClassName, finderMethodName,
1081 finderParams, finderArgs, list);
1082
1083 return list;
1084 }
1085 catch (Exception e) {
1086 throw HibernateUtil.processException(e);
1087 }
1088 finally {
1089 closeSession(session);
1090 }
1091 }
1092 else {
1093 return (List)result;
1094 }
1095 }
1096
1097 public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
1098 OrderByComparator obc) throws NoSuchPageException, SystemException {
1099 List list = findByN_T_H(nodeId, title, head, 0, 1, obc);
1100
1101 if (list.size() == 0) {
1102 StringMaker msg = new StringMaker();
1103 msg.append("No WikiPage exists with the key ");
1104 msg.append(StringPool.OPEN_CURLY_BRACE);
1105 msg.append("nodeId=");
1106 msg.append(nodeId);
1107 msg.append(", ");
1108 msg.append("title=");
1109 msg.append(title);
1110 msg.append(", ");
1111 msg.append("head=");
1112 msg.append(head);
1113 msg.append(StringPool.CLOSE_CURLY_BRACE);
1114 throw new NoSuchPageException(msg.toString());
1115 }
1116 else {
1117 return (WikiPage)list.get(0);
1118 }
1119 }
1120
1121 public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
1122 OrderByComparator obc) throws NoSuchPageException, SystemException {
1123 int count = countByN_T_H(nodeId, title, head);
1124 List list = findByN_T_H(nodeId, title, head, count - 1, count, obc);
1125
1126 if (list.size() == 0) {
1127 StringMaker msg = new StringMaker();
1128 msg.append("No WikiPage exists with the key ");
1129 msg.append(StringPool.OPEN_CURLY_BRACE);
1130 msg.append("nodeId=");
1131 msg.append(nodeId);
1132 msg.append(", ");
1133 msg.append("title=");
1134 msg.append(title);
1135 msg.append(", ");
1136 msg.append("head=");
1137 msg.append(head);
1138 msg.append(StringPool.CLOSE_CURLY_BRACE);
1139 throw new NoSuchPageException(msg.toString());
1140 }
1141 else {
1142 return (WikiPage)list.get(0);
1143 }
1144 }
1145
1146 public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
1147 String title, boolean head, OrderByComparator obc)
1148 throws NoSuchPageException, SystemException {
1149 WikiPage wikiPage = findByPrimaryKey(pageId);
1150 int count = countByN_T_H(nodeId, title, head);
1151 Session session = null;
1152
1153 try {
1154 session = openSession();
1155
1156 StringMaker query = new StringMaker();
1157 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1158 query.append("nodeId = ?");
1159 query.append(" AND ");
1160
1161 if (title == null) {
1162 query.append("title IS NULL");
1163 }
1164 else {
1165 query.append("title = ?");
1166 }
1167
1168 query.append(" AND ");
1169 query.append("head = ?");
1170 query.append(" ");
1171
1172 if (obc != null) {
1173 query.append("ORDER BY ");
1174 query.append(obc.getOrderBy());
1175 }
1176 else {
1177 query.append("ORDER BY ");
1178 query.append("nodeId ASC").append(", ");
1179 query.append("title ASC").append(", ");
1180 query.append("version ASC");
1181 }
1182
1183 Query q = session.createQuery(query.toString());
1184 int queryPos = 0;
1185 q.setLong(queryPos++, nodeId);
1186
1187 if (title != null) {
1188 q.setString(queryPos++, title);
1189 }
1190
1191 q.setBoolean(queryPos++, head);
1192
1193 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1194 WikiPage[] array = new WikiPageImpl[3];
1195 array[0] = (WikiPage)objArray[0];
1196 array[1] = (WikiPage)objArray[1];
1197 array[2] = (WikiPage)objArray[2];
1198
1199 return array;
1200 }
1201 catch (Exception e) {
1202 throw HibernateUtil.processException(e);
1203 }
1204 finally {
1205 closeSession(session);
1206 }
1207 }
1208
1209 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
1210 throws SystemException {
1211 Session session = null;
1212
1213 try {
1214 session = openSession();
1215
1216 DynamicQuery query = queryInitializer.initialize(session);
1217
1218 return query.list();
1219 }
1220 catch (Exception e) {
1221 throw HibernateUtil.processException(e);
1222 }
1223 finally {
1224 closeSession(session);
1225 }
1226 }
1227
1228 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
1229 int begin, int end) throws SystemException {
1230 Session session = null;
1231
1232 try {
1233 session = openSession();
1234
1235 DynamicQuery query = queryInitializer.initialize(session);
1236 query.setLimit(begin, end);
1237
1238 return query.list();
1239 }
1240 catch (Exception e) {
1241 throw HibernateUtil.processException(e);
1242 }
1243 finally {
1244 closeSession(session);
1245 }
1246 }
1247
1248 public List findAll() throws SystemException {
1249 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1250 }
1251
1252 public List findAll(int begin, int end) throws SystemException {
1253 return findAll(begin, end, null);
1254 }
1255
1256 public List findAll(int begin, int end, OrderByComparator obc)
1257 throws SystemException {
1258 String finderClassName = WikiPage.class.getName();
1259 String finderMethodName = "findAll";
1260 String[] finderParams = new String[] {
1261 "java.lang.Integer", "java.lang.Integer",
1262 "com.liferay.portal.kernel.util.OrderByComparator"
1263 };
1264 Object[] finderArgs = new Object[] {
1265 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1266 };
1267 Object result = FinderCache.getResult(finderClassName,
1268 finderMethodName, finderParams, finderArgs, getSessionFactory());
1269
1270 if (result == null) {
1271 Session session = null;
1272
1273 try {
1274 session = openSession();
1275
1276 StringMaker query = new StringMaker();
1277 query.append("FROM com.liferay.portlet.wiki.model.WikiPage ");
1278
1279 if (obc != null) {
1280 query.append("ORDER BY ");
1281 query.append(obc.getOrderBy());
1282 }
1283 else {
1284 query.append("ORDER BY ");
1285 query.append("nodeId ASC").append(", ");
1286 query.append("title ASC").append(", ");
1287 query.append("version ASC");
1288 }
1289
1290 Query q = session.createQuery(query.toString());
1291 List list = QueryUtil.list(q, getDialect(), begin, end);
1292
1293 if (obc == null) {
1294 Collections.sort(list);
1295 }
1296
1297 FinderCache.putResult(finderClassName, finderMethodName,
1298 finderParams, finderArgs, list);
1299
1300 return list;
1301 }
1302 catch (Exception e) {
1303 throw HibernateUtil.processException(e);
1304 }
1305 finally {
1306 closeSession(session);
1307 }
1308 }
1309 else {
1310 return (List)result;
1311 }
1312 }
1313
1314 public void removeByNodeId(long nodeId) throws SystemException {
1315 Iterator itr = findByNodeId(nodeId).iterator();
1316
1317 while (itr.hasNext()) {
1318 WikiPage wikiPage = (WikiPage)itr.next();
1319 remove(wikiPage);
1320 }
1321 }
1322
1323 public void removeByN_T(long nodeId, String title)
1324 throws SystemException {
1325 Iterator itr = findByN_T(nodeId, title).iterator();
1326
1327 while (itr.hasNext()) {
1328 WikiPage wikiPage = (WikiPage)itr.next();
1329 remove(wikiPage);
1330 }
1331 }
1332
1333 public void removeByN_H(long nodeId, boolean head)
1334 throws SystemException {
1335 Iterator itr = findByN_H(nodeId, head).iterator();
1336
1337 while (itr.hasNext()) {
1338 WikiPage wikiPage = (WikiPage)itr.next();
1339 remove(wikiPage);
1340 }
1341 }
1342
1343 public void removeByN_T_V(long nodeId, String title, double version)
1344 throws NoSuchPageException, SystemException {
1345 WikiPage wikiPage = findByN_T_V(nodeId, title, version);
1346 remove(wikiPage);
1347 }
1348
1349 public void removeByN_T_H(long nodeId, String title, boolean head)
1350 throws SystemException {
1351 Iterator itr = findByN_T_H(nodeId, title, head).iterator();
1352
1353 while (itr.hasNext()) {
1354 WikiPage wikiPage = (WikiPage)itr.next();
1355 remove(wikiPage);
1356 }
1357 }
1358
1359 public void removeAll() throws SystemException {
1360 Iterator itr = findAll().iterator();
1361
1362 while (itr.hasNext()) {
1363 remove((WikiPage)itr.next());
1364 }
1365 }
1366
1367 public int countByNodeId(long nodeId) throws SystemException {
1368 String finderClassName = WikiPage.class.getName();
1369 String finderMethodName = "countByNodeId";
1370 String[] finderParams = new String[] { Long.class.getName() };
1371 Object[] finderArgs = new Object[] { new Long(nodeId) };
1372 Object result = FinderCache.getResult(finderClassName,
1373 finderMethodName, finderParams, finderArgs, getSessionFactory());
1374
1375 if (result == null) {
1376 Session session = null;
1377
1378 try {
1379 session = openSession();
1380
1381 StringMaker query = new StringMaker();
1382 query.append("SELECT COUNT(*) ");
1383 query.append(
1384 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1385 query.append("nodeId = ?");
1386 query.append(" ");
1387
1388 Query q = session.createQuery(query.toString());
1389 int queryPos = 0;
1390 q.setLong(queryPos++, nodeId);
1391
1392 Long count = null;
1393 Iterator itr = q.list().iterator();
1394
1395 if (itr.hasNext()) {
1396 count = (Long)itr.next();
1397 }
1398
1399 if (count == null) {
1400 count = new Long(0);
1401 }
1402
1403 FinderCache.putResult(finderClassName, finderMethodName,
1404 finderParams, finderArgs, count);
1405
1406 return count.intValue();
1407 }
1408 catch (Exception e) {
1409 throw HibernateUtil.processException(e);
1410 }
1411 finally {
1412 closeSession(session);
1413 }
1414 }
1415 else {
1416 return ((Long)result).intValue();
1417 }
1418 }
1419
1420 public int countByN_T(long nodeId, String title) throws SystemException {
1421 String finderClassName = WikiPage.class.getName();
1422 String finderMethodName = "countByN_T";
1423 String[] finderParams = new String[] {
1424 Long.class.getName(), String.class.getName()
1425 };
1426 Object[] finderArgs = new Object[] { new Long(nodeId), title };
1427 Object result = FinderCache.getResult(finderClassName,
1428 finderMethodName, finderParams, finderArgs, getSessionFactory());
1429
1430 if (result == null) {
1431 Session session = null;
1432
1433 try {
1434 session = openSession();
1435
1436 StringMaker query = new StringMaker();
1437 query.append("SELECT COUNT(*) ");
1438 query.append(
1439 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1440 query.append("nodeId = ?");
1441 query.append(" AND ");
1442
1443 if (title == null) {
1444 query.append("title IS NULL");
1445 }
1446 else {
1447 query.append("title = ?");
1448 }
1449
1450 query.append(" ");
1451
1452 Query q = session.createQuery(query.toString());
1453 int queryPos = 0;
1454 q.setLong(queryPos++, nodeId);
1455
1456 if (title != null) {
1457 q.setString(queryPos++, title);
1458 }
1459
1460 Long count = null;
1461 Iterator itr = q.list().iterator();
1462
1463 if (itr.hasNext()) {
1464 count = (Long)itr.next();
1465 }
1466
1467 if (count == null) {
1468 count = new Long(0);
1469 }
1470
1471 FinderCache.putResult(finderClassName, finderMethodName,
1472 finderParams, finderArgs, count);
1473
1474 return count.intValue();
1475 }
1476 catch (Exception e) {
1477 throw HibernateUtil.processException(e);
1478 }
1479 finally {
1480 closeSession(session);
1481 }
1482 }
1483 else {
1484 return ((Long)result).intValue();
1485 }
1486 }
1487
1488 public int countByN_H(long nodeId, boolean head) throws SystemException {
1489 String finderClassName = WikiPage.class.getName();
1490 String finderMethodName = "countByN_H";
1491 String[] finderParams = new String[] {
1492 Long.class.getName(), Boolean.class.getName()
1493 };
1494 Object[] finderArgs = new Object[] {
1495 new Long(nodeId), Boolean.valueOf(head)
1496 };
1497 Object result = FinderCache.getResult(finderClassName,
1498 finderMethodName, finderParams, finderArgs, getSessionFactory());
1499
1500 if (result == null) {
1501 Session session = null;
1502
1503 try {
1504 session = openSession();
1505
1506 StringMaker query = new StringMaker();
1507 query.append("SELECT COUNT(*) ");
1508 query.append(
1509 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1510 query.append("nodeId = ?");
1511 query.append(" AND ");
1512 query.append("head = ?");
1513 query.append(" ");
1514
1515 Query q = session.createQuery(query.toString());
1516 int queryPos = 0;
1517 q.setLong(queryPos++, nodeId);
1518 q.setBoolean(queryPos++, head);
1519
1520 Long count = null;
1521 Iterator itr = q.list().iterator();
1522
1523 if (itr.hasNext()) {
1524 count = (Long)itr.next();
1525 }
1526
1527 if (count == null) {
1528 count = new Long(0);
1529 }
1530
1531 FinderCache.putResult(finderClassName, finderMethodName,
1532 finderParams, finderArgs, count);
1533
1534 return count.intValue();
1535 }
1536 catch (Exception e) {
1537 throw HibernateUtil.processException(e);
1538 }
1539 finally {
1540 closeSession(session);
1541 }
1542 }
1543 else {
1544 return ((Long)result).intValue();
1545 }
1546 }
1547
1548 public int countByN_T_V(long nodeId, String title, double version)
1549 throws SystemException {
1550 String finderClassName = WikiPage.class.getName();
1551 String finderMethodName = "countByN_T_V";
1552 String[] finderParams = new String[] {
1553 Long.class.getName(), String.class.getName(),
1554 Double.class.getName()
1555 };
1556 Object[] finderArgs = new Object[] {
1557 new Long(nodeId), title, new Double(version)
1558 };
1559 Object result = FinderCache.getResult(finderClassName,
1560 finderMethodName, finderParams, finderArgs, getSessionFactory());
1561
1562 if (result == null) {
1563 Session session = null;
1564
1565 try {
1566 session = openSession();
1567
1568 StringMaker query = new StringMaker();
1569 query.append("SELECT COUNT(*) ");
1570 query.append(
1571 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1572 query.append("nodeId = ?");
1573 query.append(" AND ");
1574
1575 if (title == null) {
1576 query.append("title IS NULL");
1577 }
1578 else {
1579 query.append("title = ?");
1580 }
1581
1582 query.append(" AND ");
1583 query.append("version = ?");
1584 query.append(" ");
1585
1586 Query q = session.createQuery(query.toString());
1587 int queryPos = 0;
1588 q.setLong(queryPos++, nodeId);
1589
1590 if (title != null) {
1591 q.setString(queryPos++, title);
1592 }
1593
1594 q.setDouble(queryPos++, version);
1595
1596 Long count = null;
1597 Iterator itr = q.list().iterator();
1598
1599 if (itr.hasNext()) {
1600 count = (Long)itr.next();
1601 }
1602
1603 if (count == null) {
1604 count = new Long(0);
1605 }
1606
1607 FinderCache.putResult(finderClassName, finderMethodName,
1608 finderParams, finderArgs, count);
1609
1610 return count.intValue();
1611 }
1612 catch (Exception e) {
1613 throw HibernateUtil.processException(e);
1614 }
1615 finally {
1616 closeSession(session);
1617 }
1618 }
1619 else {
1620 return ((Long)result).intValue();
1621 }
1622 }
1623
1624 public int countByN_T_H(long nodeId, String title, boolean head)
1625 throws SystemException {
1626 String finderClassName = WikiPage.class.getName();
1627 String finderMethodName = "countByN_T_H";
1628 String[] finderParams = new String[] {
1629 Long.class.getName(), String.class.getName(),
1630 Boolean.class.getName()
1631 };
1632 Object[] finderArgs = new Object[] {
1633 new Long(nodeId), title, Boolean.valueOf(head)
1634 };
1635 Object result = FinderCache.getResult(finderClassName,
1636 finderMethodName, finderParams, finderArgs, getSessionFactory());
1637
1638 if (result == null) {
1639 Session session = null;
1640
1641 try {
1642 session = openSession();
1643
1644 StringMaker query = new StringMaker();
1645 query.append("SELECT COUNT(*) ");
1646 query.append(
1647 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1648 query.append("nodeId = ?");
1649 query.append(" AND ");
1650
1651 if (title == null) {
1652 query.append("title IS NULL");
1653 }
1654 else {
1655 query.append("title = ?");
1656 }
1657
1658 query.append(" AND ");
1659 query.append("head = ?");
1660 query.append(" ");
1661
1662 Query q = session.createQuery(query.toString());
1663 int queryPos = 0;
1664 q.setLong(queryPos++, nodeId);
1665
1666 if (title != null) {
1667 q.setString(queryPos++, title);
1668 }
1669
1670 q.setBoolean(queryPos++, head);
1671
1672 Long count = null;
1673 Iterator itr = q.list().iterator();
1674
1675 if (itr.hasNext()) {
1676 count = (Long)itr.next();
1677 }
1678
1679 if (count == null) {
1680 count = new Long(0);
1681 }
1682
1683 FinderCache.putResult(finderClassName, finderMethodName,
1684 finderParams, finderArgs, count);
1685
1686 return count.intValue();
1687 }
1688 catch (Exception e) {
1689 throw HibernateUtil.processException(e);
1690 }
1691 finally {
1692 closeSession(session);
1693 }
1694 }
1695 else {
1696 return ((Long)result).intValue();
1697 }
1698 }
1699
1700 public int countAll() throws SystemException {
1701 String finderClassName = WikiPage.class.getName();
1702 String finderMethodName = "countAll";
1703 String[] finderParams = new String[] { };
1704 Object[] finderArgs = new Object[] { };
1705 Object result = FinderCache.getResult(finderClassName,
1706 finderMethodName, finderParams, finderArgs, getSessionFactory());
1707
1708 if (result == null) {
1709 Session session = null;
1710
1711 try {
1712 session = openSession();
1713
1714 StringMaker query = new StringMaker();
1715 query.append("SELECT COUNT(*) ");
1716 query.append("FROM com.liferay.portlet.wiki.model.WikiPage");
1717
1718 Query q = session.createQuery(query.toString());
1719 Long count = null;
1720 Iterator itr = q.list().iterator();
1721
1722 if (itr.hasNext()) {
1723 count = (Long)itr.next();
1724 }
1725
1726 if (count == null) {
1727 count = new Long(0);
1728 }
1729
1730 FinderCache.putResult(finderClassName, finderMethodName,
1731 finderParams, finderArgs, count);
1732
1733 return count.intValue();
1734 }
1735 catch (Exception e) {
1736 throw HibernateUtil.processException(e);
1737 }
1738 finally {
1739 closeSession(session);
1740 }
1741 }
1742 else {
1743 return ((Long)result).intValue();
1744 }
1745 }
1746
1747 protected void initDao() {
1748 }
1749
1750 private static Log _log = LogFactory.getLog(WikiPagePersistenceImpl.class);
1751}