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.GetterUtil;
29 import com.liferay.portal.kernel.util.OrderByComparator;
30 import com.liferay.portal.kernel.util.StringMaker;
31 import com.liferay.portal.kernel.util.StringPool;
32 import com.liferay.portal.kernel.util.Validator;
33 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
34 import com.liferay.portal.model.ModelListener;
35 import com.liferay.portal.service.persistence.BasePersistence;
36 import com.liferay.portal.spring.hibernate.FinderCache;
37 import com.liferay.portal.spring.hibernate.HibernateUtil;
38 import com.liferay.portal.util.PropsUtil;
39
40 import com.liferay.portlet.wiki.NoSuchPageException;
41 import com.liferay.portlet.wiki.model.WikiPage;
42 import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
43 import com.liferay.portlet.wiki.model.impl.WikiPageModelImpl;
44
45 import com.liferay.util.dao.hibernate.QueryUtil;
46
47 import org.apache.commons.logging.Log;
48 import org.apache.commons.logging.LogFactory;
49
50 import org.hibernate.Query;
51 import org.hibernate.Session;
52
53 import java.util.Collections;
54 import java.util.Iterator;
55 import java.util.List;
56
57
63 public class WikiPagePersistenceImpl extends BasePersistence
64 implements WikiPagePersistence {
65 public WikiPage create(long pageId) {
66 WikiPage wikiPage = new WikiPageImpl();
67
68 wikiPage.setNew(true);
69 wikiPage.setPrimaryKey(pageId);
70
71 String uuid = PortalUUIDUtil.generate();
72
73 wikiPage.setUuid(uuid);
74
75 return wikiPage;
76 }
77
78 public WikiPage remove(long pageId)
79 throws NoSuchPageException, SystemException {
80 Session session = null;
81
82 try {
83 session = openSession();
84
85 WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
86 new Long(pageId));
87
88 if (wikiPage == null) {
89 if (_log.isWarnEnabled()) {
90 _log.warn("No WikiPage exists with the primary key " +
91 pageId);
92 }
93
94 throw new NoSuchPageException(
95 "No WikiPage exists with the primary key " + pageId);
96 }
97
98 return remove(wikiPage);
99 }
100 catch (NoSuchPageException nsee) {
101 throw nsee;
102 }
103 catch (Exception e) {
104 throw HibernateUtil.processException(e);
105 }
106 finally {
107 closeSession(session);
108 }
109 }
110
111 public WikiPage remove(WikiPage wikiPage) throws SystemException {
112 ModelListener listener = _getListener();
113
114 if (listener != null) {
115 listener.onBeforeRemove(wikiPage);
116 }
117
118 wikiPage = removeImpl(wikiPage);
119
120 if (listener != null) {
121 listener.onAfterRemove(wikiPage);
122 }
123
124 return wikiPage;
125 }
126
127 protected WikiPage removeImpl(WikiPage wikiPage) throws SystemException {
128 Session session = null;
129
130 try {
131 session = openSession();
132
133 session.delete(wikiPage);
134
135 session.flush();
136
137 return wikiPage;
138 }
139 catch (Exception e) {
140 throw HibernateUtil.processException(e);
141 }
142 finally {
143 closeSession(session);
144
145 FinderCache.clearCache(WikiPage.class.getName());
146 }
147 }
148
149 public WikiPage update(WikiPage wikiPage) throws SystemException {
150 return update(wikiPage, false);
151 }
152
153 public WikiPage update(WikiPage wikiPage, boolean merge)
154 throws SystemException {
155 ModelListener listener = _getListener();
156
157 boolean isNew = wikiPage.isNew();
158
159 if (listener != null) {
160 if (isNew) {
161 listener.onBeforeCreate(wikiPage);
162 }
163 else {
164 listener.onBeforeUpdate(wikiPage);
165 }
166 }
167
168 wikiPage = updateImpl(wikiPage, merge);
169
170 if (listener != null) {
171 if (isNew) {
172 listener.onAfterCreate(wikiPage);
173 }
174 else {
175 listener.onAfterUpdate(wikiPage);
176 }
177 }
178
179 return wikiPage;
180 }
181
182 public WikiPage updateImpl(
183 com.liferay.portlet.wiki.model.WikiPage wikiPage, boolean merge)
184 throws SystemException {
185 if (Validator.isNull(wikiPage.getUuid())) {
186 String uuid = PortalUUIDUtil.generate();
187
188 wikiPage.setUuid(uuid);
189 }
190
191 Session session = null;
192
193 try {
194 session = openSession();
195
196 if (merge) {
197 session.merge(wikiPage);
198 }
199 else {
200 if (wikiPage.isNew()) {
201 session.save(wikiPage);
202 }
203 }
204
205 session.flush();
206
207 wikiPage.setNew(false);
208
209 return wikiPage;
210 }
211 catch (Exception e) {
212 throw HibernateUtil.processException(e);
213 }
214 finally {
215 closeSession(session);
216
217 FinderCache.clearCache(WikiPage.class.getName());
218 }
219 }
220
221 public WikiPage findByPrimaryKey(long pageId)
222 throws NoSuchPageException, SystemException {
223 WikiPage wikiPage = fetchByPrimaryKey(pageId);
224
225 if (wikiPage == null) {
226 if (_log.isWarnEnabled()) {
227 _log.warn("No WikiPage exists with the primary key " + pageId);
228 }
229
230 throw new NoSuchPageException(
231 "No WikiPage exists with the primary key " + pageId);
232 }
233
234 return wikiPage;
235 }
236
237 public WikiPage fetchByPrimaryKey(long pageId) throws SystemException {
238 Session session = null;
239
240 try {
241 session = openSession();
242
243 return (WikiPage)session.get(WikiPageImpl.class, new Long(pageId));
244 }
245 catch (Exception e) {
246 throw HibernateUtil.processException(e);
247 }
248 finally {
249 closeSession(session);
250 }
251 }
252
253 public List findByUuid(String uuid) throws SystemException {
254 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
255 String finderClassName = WikiPage.class.getName();
256 String finderMethodName = "findByUuid";
257 String[] finderParams = new String[] { String.class.getName() };
258 Object[] finderArgs = new Object[] { uuid };
259
260 Object result = null;
261
262 if (finderClassNameCacheEnabled) {
263 result = FinderCache.getResult(finderClassName, finderMethodName,
264 finderParams, finderArgs, getSessionFactory());
265 }
266
267 if (result == null) {
268 Session session = null;
269
270 try {
271 session = openSession();
272
273 StringMaker query = new StringMaker();
274
275 query.append(
276 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
277
278 if (uuid == null) {
279 query.append("uuid_ IS NULL");
280 }
281 else {
282 query.append("uuid_ = ?");
283 }
284
285 query.append(" ");
286
287 query.append("ORDER BY ");
288
289 query.append("nodeId ASC, ");
290 query.append("title ASC, ");
291 query.append("version ASC");
292
293 Query q = session.createQuery(query.toString());
294
295 int queryPos = 0;
296
297 if (uuid != null) {
298 q.setString(queryPos++, uuid);
299 }
300
301 List list = q.list();
302
303 FinderCache.putResult(finderClassNameCacheEnabled,
304 finderClassName, finderMethodName, finderParams,
305 finderArgs, list);
306
307 return list;
308 }
309 catch (Exception e) {
310 throw HibernateUtil.processException(e);
311 }
312 finally {
313 closeSession(session);
314 }
315 }
316 else {
317 return (List)result;
318 }
319 }
320
321 public List findByUuid(String uuid, int begin, int end)
322 throws SystemException {
323 return findByUuid(uuid, begin, end, null);
324 }
325
326 public List findByUuid(String uuid, int begin, int end,
327 OrderByComparator obc) throws SystemException {
328 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
329 String finderClassName = WikiPage.class.getName();
330 String finderMethodName = "findByUuid";
331 String[] finderParams = new String[] {
332 String.class.getName(),
333
334 "java.lang.Integer", "java.lang.Integer",
335 "com.liferay.portal.kernel.util.OrderByComparator"
336 };
337 Object[] finderArgs = new Object[] {
338 uuid,
339
340 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
341 };
342
343 Object result = null;
344
345 if (finderClassNameCacheEnabled) {
346 result = FinderCache.getResult(finderClassName, finderMethodName,
347 finderParams, finderArgs, getSessionFactory());
348 }
349
350 if (result == null) {
351 Session session = null;
352
353 try {
354 session = openSession();
355
356 StringMaker query = new StringMaker();
357
358 query.append(
359 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
360
361 if (uuid == null) {
362 query.append("uuid_ IS NULL");
363 }
364 else {
365 query.append("uuid_ = ?");
366 }
367
368 query.append(" ");
369
370 if (obc != null) {
371 query.append("ORDER BY ");
372 query.append(obc.getOrderBy());
373 }
374
375 else {
376 query.append("ORDER BY ");
377
378 query.append("nodeId ASC, ");
379 query.append("title ASC, ");
380 query.append("version ASC");
381 }
382
383 Query q = session.createQuery(query.toString());
384
385 int queryPos = 0;
386
387 if (uuid != null) {
388 q.setString(queryPos++, uuid);
389 }
390
391 List list = QueryUtil.list(q, getDialect(), begin, end);
392
393 FinderCache.putResult(finderClassNameCacheEnabled,
394 finderClassName, finderMethodName, finderParams,
395 finderArgs, list);
396
397 return list;
398 }
399 catch (Exception e) {
400 throw HibernateUtil.processException(e);
401 }
402 finally {
403 closeSession(session);
404 }
405 }
406 else {
407 return (List)result;
408 }
409 }
410
411 public WikiPage findByUuid_First(String uuid, OrderByComparator obc)
412 throws NoSuchPageException, SystemException {
413 List list = findByUuid(uuid, 0, 1, obc);
414
415 if (list.size() == 0) {
416 StringMaker msg = new StringMaker();
417
418 msg.append("No WikiPage exists with the key {");
419
420 msg.append("uuid=" + uuid);
421
422 msg.append(StringPool.CLOSE_CURLY_BRACE);
423
424 throw new NoSuchPageException(msg.toString());
425 }
426 else {
427 return (WikiPage)list.get(0);
428 }
429 }
430
431 public WikiPage findByUuid_Last(String uuid, OrderByComparator obc)
432 throws NoSuchPageException, SystemException {
433 int count = countByUuid(uuid);
434
435 List list = findByUuid(uuid, count - 1, count, obc);
436
437 if (list.size() == 0) {
438 StringMaker msg = new StringMaker();
439
440 msg.append("No WikiPage exists with the key {");
441
442 msg.append("uuid=" + uuid);
443
444 msg.append(StringPool.CLOSE_CURLY_BRACE);
445
446 throw new NoSuchPageException(msg.toString());
447 }
448 else {
449 return (WikiPage)list.get(0);
450 }
451 }
452
453 public WikiPage[] findByUuid_PrevAndNext(long pageId, String uuid,
454 OrderByComparator obc) throws NoSuchPageException, SystemException {
455 WikiPage wikiPage = findByPrimaryKey(pageId);
456
457 int count = countByUuid(uuid);
458
459 Session session = null;
460
461 try {
462 session = openSession();
463
464 StringMaker query = new StringMaker();
465
466 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
467
468 if (uuid == null) {
469 query.append("uuid_ IS NULL");
470 }
471 else {
472 query.append("uuid_ = ?");
473 }
474
475 query.append(" ");
476
477 if (obc != null) {
478 query.append("ORDER BY ");
479 query.append(obc.getOrderBy());
480 }
481
482 else {
483 query.append("ORDER BY ");
484
485 query.append("nodeId ASC, ");
486 query.append("title ASC, ");
487 query.append("version ASC");
488 }
489
490 Query q = session.createQuery(query.toString());
491
492 int queryPos = 0;
493
494 if (uuid != null) {
495 q.setString(queryPos++, uuid);
496 }
497
498 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
499
500 WikiPage[] array = new WikiPageImpl[3];
501
502 array[0] = (WikiPage)objArray[0];
503 array[1] = (WikiPage)objArray[1];
504 array[2] = (WikiPage)objArray[2];
505
506 return array;
507 }
508 catch (Exception e) {
509 throw HibernateUtil.processException(e);
510 }
511 finally {
512 closeSession(session);
513 }
514 }
515
516 public List findByNodeId(long nodeId) throws SystemException {
517 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
518 String finderClassName = WikiPage.class.getName();
519 String finderMethodName = "findByNodeId";
520 String[] finderParams = new String[] { Long.class.getName() };
521 Object[] finderArgs = new Object[] { new Long(nodeId) };
522
523 Object result = null;
524
525 if (finderClassNameCacheEnabled) {
526 result = FinderCache.getResult(finderClassName, finderMethodName,
527 finderParams, finderArgs, getSessionFactory());
528 }
529
530 if (result == null) {
531 Session session = null;
532
533 try {
534 session = openSession();
535
536 StringMaker query = new StringMaker();
537
538 query.append(
539 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
540
541 query.append("nodeId = ?");
542
543 query.append(" ");
544
545 query.append("ORDER BY ");
546
547 query.append("nodeId ASC, ");
548 query.append("title ASC, ");
549 query.append("version ASC");
550
551 Query q = session.createQuery(query.toString());
552
553 int queryPos = 0;
554
555 q.setLong(queryPos++, nodeId);
556
557 List list = q.list();
558
559 FinderCache.putResult(finderClassNameCacheEnabled,
560 finderClassName, finderMethodName, finderParams,
561 finderArgs, list);
562
563 return list;
564 }
565 catch (Exception e) {
566 throw HibernateUtil.processException(e);
567 }
568 finally {
569 closeSession(session);
570 }
571 }
572 else {
573 return (List)result;
574 }
575 }
576
577 public List findByNodeId(long nodeId, int begin, int end)
578 throws SystemException {
579 return findByNodeId(nodeId, begin, end, null);
580 }
581
582 public List findByNodeId(long nodeId, int begin, int end,
583 OrderByComparator obc) throws SystemException {
584 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
585 String finderClassName = WikiPage.class.getName();
586 String finderMethodName = "findByNodeId";
587 String[] finderParams = new String[] {
588 Long.class.getName(),
589
590 "java.lang.Integer", "java.lang.Integer",
591 "com.liferay.portal.kernel.util.OrderByComparator"
592 };
593 Object[] finderArgs = new Object[] {
594 new Long(nodeId),
595
596 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
597 };
598
599 Object result = null;
600
601 if (finderClassNameCacheEnabled) {
602 result = FinderCache.getResult(finderClassName, finderMethodName,
603 finderParams, finderArgs, getSessionFactory());
604 }
605
606 if (result == null) {
607 Session session = null;
608
609 try {
610 session = openSession();
611
612 StringMaker query = new StringMaker();
613
614 query.append(
615 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
616
617 query.append("nodeId = ?");
618
619 query.append(" ");
620
621 if (obc != null) {
622 query.append("ORDER BY ");
623 query.append(obc.getOrderBy());
624 }
625
626 else {
627 query.append("ORDER BY ");
628
629 query.append("nodeId ASC, ");
630 query.append("title ASC, ");
631 query.append("version ASC");
632 }
633
634 Query q = session.createQuery(query.toString());
635
636 int queryPos = 0;
637
638 q.setLong(queryPos++, nodeId);
639
640 List list = QueryUtil.list(q, getDialect(), begin, end);
641
642 FinderCache.putResult(finderClassNameCacheEnabled,
643 finderClassName, finderMethodName, finderParams,
644 finderArgs, list);
645
646 return list;
647 }
648 catch (Exception e) {
649 throw HibernateUtil.processException(e);
650 }
651 finally {
652 closeSession(session);
653 }
654 }
655 else {
656 return (List)result;
657 }
658 }
659
660 public WikiPage findByNodeId_First(long nodeId, OrderByComparator obc)
661 throws NoSuchPageException, SystemException {
662 List list = findByNodeId(nodeId, 0, 1, obc);
663
664 if (list.size() == 0) {
665 StringMaker msg = new StringMaker();
666
667 msg.append("No WikiPage exists with the key {");
668
669 msg.append("nodeId=" + nodeId);
670
671 msg.append(StringPool.CLOSE_CURLY_BRACE);
672
673 throw new NoSuchPageException(msg.toString());
674 }
675 else {
676 return (WikiPage)list.get(0);
677 }
678 }
679
680 public WikiPage findByNodeId_Last(long nodeId, OrderByComparator obc)
681 throws NoSuchPageException, SystemException {
682 int count = countByNodeId(nodeId);
683
684 List list = findByNodeId(nodeId, count - 1, count, obc);
685
686 if (list.size() == 0) {
687 StringMaker msg = new StringMaker();
688
689 msg.append("No WikiPage exists with the key {");
690
691 msg.append("nodeId=" + nodeId);
692
693 msg.append(StringPool.CLOSE_CURLY_BRACE);
694
695 throw new NoSuchPageException(msg.toString());
696 }
697 else {
698 return (WikiPage)list.get(0);
699 }
700 }
701
702 public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
703 OrderByComparator obc) throws NoSuchPageException, SystemException {
704 WikiPage wikiPage = findByPrimaryKey(pageId);
705
706 int count = countByNodeId(nodeId);
707
708 Session session = null;
709
710 try {
711 session = openSession();
712
713 StringMaker query = new StringMaker();
714
715 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
716
717 query.append("nodeId = ?");
718
719 query.append(" ");
720
721 if (obc != null) {
722 query.append("ORDER BY ");
723 query.append(obc.getOrderBy());
724 }
725
726 else {
727 query.append("ORDER BY ");
728
729 query.append("nodeId ASC, ");
730 query.append("title ASC, ");
731 query.append("version ASC");
732 }
733
734 Query q = session.createQuery(query.toString());
735
736 int queryPos = 0;
737
738 q.setLong(queryPos++, nodeId);
739
740 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
741
742 WikiPage[] array = new WikiPageImpl[3];
743
744 array[0] = (WikiPage)objArray[0];
745 array[1] = (WikiPage)objArray[1];
746 array[2] = (WikiPage)objArray[2];
747
748 return array;
749 }
750 catch (Exception e) {
751 throw HibernateUtil.processException(e);
752 }
753 finally {
754 closeSession(session);
755 }
756 }
757
758 public List findByN_T(long nodeId, String title) throws SystemException {
759 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
760 String finderClassName = WikiPage.class.getName();
761 String finderMethodName = "findByN_T";
762 String[] finderParams = new String[] {
763 Long.class.getName(), String.class.getName()
764 };
765 Object[] finderArgs = new Object[] { new Long(nodeId), title };
766
767 Object result = null;
768
769 if (finderClassNameCacheEnabled) {
770 result = FinderCache.getResult(finderClassName, finderMethodName,
771 finderParams, finderArgs, getSessionFactory());
772 }
773
774 if (result == null) {
775 Session session = null;
776
777 try {
778 session = openSession();
779
780 StringMaker query = new StringMaker();
781
782 query.append(
783 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
784
785 query.append("nodeId = ?");
786
787 query.append(" AND ");
788
789 if (title == null) {
790 query.append("title IS NULL");
791 }
792 else {
793 query.append("title = ?");
794 }
795
796 query.append(" ");
797
798 query.append("ORDER BY ");
799
800 query.append("nodeId ASC, ");
801 query.append("title ASC, ");
802 query.append("version ASC");
803
804 Query q = session.createQuery(query.toString());
805
806 int queryPos = 0;
807
808 q.setLong(queryPos++, nodeId);
809
810 if (title != null) {
811 q.setString(queryPos++, title);
812 }
813
814 List list = q.list();
815
816 FinderCache.putResult(finderClassNameCacheEnabled,
817 finderClassName, finderMethodName, finderParams,
818 finderArgs, list);
819
820 return list;
821 }
822 catch (Exception e) {
823 throw HibernateUtil.processException(e);
824 }
825 finally {
826 closeSession(session);
827 }
828 }
829 else {
830 return (List)result;
831 }
832 }
833
834 public List findByN_T(long nodeId, String title, int begin, int end)
835 throws SystemException {
836 return findByN_T(nodeId, title, begin, end, null);
837 }
838
839 public List findByN_T(long nodeId, String title, int begin, int end,
840 OrderByComparator obc) throws SystemException {
841 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
842 String finderClassName = WikiPage.class.getName();
843 String finderMethodName = "findByN_T";
844 String[] finderParams = new String[] {
845 Long.class.getName(), String.class.getName(),
846
847 "java.lang.Integer", "java.lang.Integer",
848 "com.liferay.portal.kernel.util.OrderByComparator"
849 };
850 Object[] finderArgs = new Object[] {
851 new Long(nodeId),
852
853 title,
854
855 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
856 };
857
858 Object result = null;
859
860 if (finderClassNameCacheEnabled) {
861 result = FinderCache.getResult(finderClassName, finderMethodName,
862 finderParams, finderArgs, getSessionFactory());
863 }
864
865 if (result == null) {
866 Session session = null;
867
868 try {
869 session = openSession();
870
871 StringMaker query = new StringMaker();
872
873 query.append(
874 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
875
876 query.append("nodeId = ?");
877
878 query.append(" AND ");
879
880 if (title == null) {
881 query.append("title IS NULL");
882 }
883 else {
884 query.append("title = ?");
885 }
886
887 query.append(" ");
888
889 if (obc != null) {
890 query.append("ORDER BY ");
891 query.append(obc.getOrderBy());
892 }
893
894 else {
895 query.append("ORDER BY ");
896
897 query.append("nodeId ASC, ");
898 query.append("title ASC, ");
899 query.append("version ASC");
900 }
901
902 Query q = session.createQuery(query.toString());
903
904 int queryPos = 0;
905
906 q.setLong(queryPos++, nodeId);
907
908 if (title != null) {
909 q.setString(queryPos++, title);
910 }
911
912 List list = QueryUtil.list(q, getDialect(), begin, end);
913
914 FinderCache.putResult(finderClassNameCacheEnabled,
915 finderClassName, finderMethodName, finderParams,
916 finderArgs, list);
917
918 return list;
919 }
920 catch (Exception e) {
921 throw HibernateUtil.processException(e);
922 }
923 finally {
924 closeSession(session);
925 }
926 }
927 else {
928 return (List)result;
929 }
930 }
931
932 public WikiPage findByN_T_First(long nodeId, String title,
933 OrderByComparator obc) throws NoSuchPageException, SystemException {
934 List list = findByN_T(nodeId, title, 0, 1, obc);
935
936 if (list.size() == 0) {
937 StringMaker msg = new StringMaker();
938
939 msg.append("No WikiPage exists with the key {");
940
941 msg.append("nodeId=" + nodeId);
942
943 msg.append(", ");
944 msg.append("title=" + title);
945
946 msg.append(StringPool.CLOSE_CURLY_BRACE);
947
948 throw new NoSuchPageException(msg.toString());
949 }
950 else {
951 return (WikiPage)list.get(0);
952 }
953 }
954
955 public WikiPage findByN_T_Last(long nodeId, String title,
956 OrderByComparator obc) throws NoSuchPageException, SystemException {
957 int count = countByN_T(nodeId, title);
958
959 List list = findByN_T(nodeId, title, count - 1, count, obc);
960
961 if (list.size() == 0) {
962 StringMaker msg = new StringMaker();
963
964 msg.append("No WikiPage exists with the key {");
965
966 msg.append("nodeId=" + nodeId);
967
968 msg.append(", ");
969 msg.append("title=" + title);
970
971 msg.append(StringPool.CLOSE_CURLY_BRACE);
972
973 throw new NoSuchPageException(msg.toString());
974 }
975 else {
976 return (WikiPage)list.get(0);
977 }
978 }
979
980 public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
981 String title, OrderByComparator obc)
982 throws NoSuchPageException, SystemException {
983 WikiPage wikiPage = findByPrimaryKey(pageId);
984
985 int count = countByN_T(nodeId, title);
986
987 Session session = null;
988
989 try {
990 session = openSession();
991
992 StringMaker query = new StringMaker();
993
994 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
995
996 query.append("nodeId = ?");
997
998 query.append(" AND ");
999
1000 if (title == null) {
1001 query.append("title IS NULL");
1002 }
1003 else {
1004 query.append("title = ?");
1005 }
1006
1007 query.append(" ");
1008
1009 if (obc != null) {
1010 query.append("ORDER BY ");
1011 query.append(obc.getOrderBy());
1012 }
1013
1014 else {
1015 query.append("ORDER BY ");
1016
1017 query.append("nodeId ASC, ");
1018 query.append("title ASC, ");
1019 query.append("version ASC");
1020 }
1021
1022 Query q = session.createQuery(query.toString());
1023
1024 int queryPos = 0;
1025
1026 q.setLong(queryPos++, nodeId);
1027
1028 if (title != null) {
1029 q.setString(queryPos++, title);
1030 }
1031
1032 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1033
1034 WikiPage[] array = new WikiPageImpl[3];
1035
1036 array[0] = (WikiPage)objArray[0];
1037 array[1] = (WikiPage)objArray[1];
1038 array[2] = (WikiPage)objArray[2];
1039
1040 return array;
1041 }
1042 catch (Exception e) {
1043 throw HibernateUtil.processException(e);
1044 }
1045 finally {
1046 closeSession(session);
1047 }
1048 }
1049
1050 public List findByN_H(long nodeId, boolean head) throws SystemException {
1051 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1052 String finderClassName = WikiPage.class.getName();
1053 String finderMethodName = "findByN_H";
1054 String[] finderParams = new String[] {
1055 Long.class.getName(), Boolean.class.getName()
1056 };
1057 Object[] finderArgs = new Object[] {
1058 new Long(nodeId), Boolean.valueOf(head)
1059 };
1060
1061 Object result = null;
1062
1063 if (finderClassNameCacheEnabled) {
1064 result = FinderCache.getResult(finderClassName, finderMethodName,
1065 finderParams, finderArgs, getSessionFactory());
1066 }
1067
1068 if (result == null) {
1069 Session session = null;
1070
1071 try {
1072 session = openSession();
1073
1074 StringMaker query = new StringMaker();
1075
1076 query.append(
1077 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1078
1079 query.append("nodeId = ?");
1080
1081 query.append(" AND ");
1082
1083 query.append("head = ?");
1084
1085 query.append(" ");
1086
1087 query.append("ORDER BY ");
1088
1089 query.append("nodeId ASC, ");
1090 query.append("title ASC, ");
1091 query.append("version ASC");
1092
1093 Query q = session.createQuery(query.toString());
1094
1095 int queryPos = 0;
1096
1097 q.setLong(queryPos++, nodeId);
1098
1099 q.setBoolean(queryPos++, head);
1100
1101 List list = q.list();
1102
1103 FinderCache.putResult(finderClassNameCacheEnabled,
1104 finderClassName, finderMethodName, finderParams,
1105 finderArgs, list);
1106
1107 return list;
1108 }
1109 catch (Exception e) {
1110 throw HibernateUtil.processException(e);
1111 }
1112 finally {
1113 closeSession(session);
1114 }
1115 }
1116 else {
1117 return (List)result;
1118 }
1119 }
1120
1121 public List findByN_H(long nodeId, boolean head, int begin, int end)
1122 throws SystemException {
1123 return findByN_H(nodeId, head, begin, end, null);
1124 }
1125
1126 public List findByN_H(long nodeId, boolean head, int begin, int end,
1127 OrderByComparator obc) throws SystemException {
1128 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1129 String finderClassName = WikiPage.class.getName();
1130 String finderMethodName = "findByN_H";
1131 String[] finderParams = new String[] {
1132 Long.class.getName(), Boolean.class.getName(),
1133
1134 "java.lang.Integer", "java.lang.Integer",
1135 "com.liferay.portal.kernel.util.OrderByComparator"
1136 };
1137 Object[] finderArgs = new Object[] {
1138 new Long(nodeId), Boolean.valueOf(head),
1139
1140 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1141 };
1142
1143 Object result = null;
1144
1145 if (finderClassNameCacheEnabled) {
1146 result = FinderCache.getResult(finderClassName, finderMethodName,
1147 finderParams, finderArgs, getSessionFactory());
1148 }
1149
1150 if (result == null) {
1151 Session session = null;
1152
1153 try {
1154 session = openSession();
1155
1156 StringMaker query = new StringMaker();
1157
1158 query.append(
1159 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1160
1161 query.append("nodeId = ?");
1162
1163 query.append(" AND ");
1164
1165 query.append("head = ?");
1166
1167 query.append(" ");
1168
1169 if (obc != null) {
1170 query.append("ORDER BY ");
1171 query.append(obc.getOrderBy());
1172 }
1173
1174 else {
1175 query.append("ORDER BY ");
1176
1177 query.append("nodeId ASC, ");
1178 query.append("title ASC, ");
1179 query.append("version ASC");
1180 }
1181
1182 Query q = session.createQuery(query.toString());
1183
1184 int queryPos = 0;
1185
1186 q.setLong(queryPos++, nodeId);
1187
1188 q.setBoolean(queryPos++, head);
1189
1190 List list = QueryUtil.list(q, getDialect(), begin, end);
1191
1192 FinderCache.putResult(finderClassNameCacheEnabled,
1193 finderClassName, finderMethodName, finderParams,
1194 finderArgs, list);
1195
1196 return list;
1197 }
1198 catch (Exception e) {
1199 throw HibernateUtil.processException(e);
1200 }
1201 finally {
1202 closeSession(session);
1203 }
1204 }
1205 else {
1206 return (List)result;
1207 }
1208 }
1209
1210 public WikiPage findByN_H_First(long nodeId, boolean head,
1211 OrderByComparator obc) throws NoSuchPageException, SystemException {
1212 List list = findByN_H(nodeId, head, 0, 1, obc);
1213
1214 if (list.size() == 0) {
1215 StringMaker msg = new StringMaker();
1216
1217 msg.append("No WikiPage exists with the key {");
1218
1219 msg.append("nodeId=" + nodeId);
1220
1221 msg.append(", ");
1222 msg.append("head=" + head);
1223
1224 msg.append(StringPool.CLOSE_CURLY_BRACE);
1225
1226 throw new NoSuchPageException(msg.toString());
1227 }
1228 else {
1229 return (WikiPage)list.get(0);
1230 }
1231 }
1232
1233 public WikiPage findByN_H_Last(long nodeId, boolean head,
1234 OrderByComparator obc) throws NoSuchPageException, SystemException {
1235 int count = countByN_H(nodeId, head);
1236
1237 List list = findByN_H(nodeId, head, count - 1, count, obc);
1238
1239 if (list.size() == 0) {
1240 StringMaker msg = new StringMaker();
1241
1242 msg.append("No WikiPage exists with the key {");
1243
1244 msg.append("nodeId=" + nodeId);
1245
1246 msg.append(", ");
1247 msg.append("head=" + head);
1248
1249 msg.append(StringPool.CLOSE_CURLY_BRACE);
1250
1251 throw new NoSuchPageException(msg.toString());
1252 }
1253 else {
1254 return (WikiPage)list.get(0);
1255 }
1256 }
1257
1258 public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
1259 boolean head, OrderByComparator obc)
1260 throws NoSuchPageException, SystemException {
1261 WikiPage wikiPage = findByPrimaryKey(pageId);
1262
1263 int count = countByN_H(nodeId, head);
1264
1265 Session session = null;
1266
1267 try {
1268 session = openSession();
1269
1270 StringMaker query = new StringMaker();
1271
1272 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1273
1274 query.append("nodeId = ?");
1275
1276 query.append(" AND ");
1277
1278 query.append("head = ?");
1279
1280 query.append(" ");
1281
1282 if (obc != null) {
1283 query.append("ORDER BY ");
1284 query.append(obc.getOrderBy());
1285 }
1286
1287 else {
1288 query.append("ORDER BY ");
1289
1290 query.append("nodeId ASC, ");
1291 query.append("title ASC, ");
1292 query.append("version ASC");
1293 }
1294
1295 Query q = session.createQuery(query.toString());
1296
1297 int queryPos = 0;
1298
1299 q.setLong(queryPos++, nodeId);
1300
1301 q.setBoolean(queryPos++, head);
1302
1303 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1304
1305 WikiPage[] array = new WikiPageImpl[3];
1306
1307 array[0] = (WikiPage)objArray[0];
1308 array[1] = (WikiPage)objArray[1];
1309 array[2] = (WikiPage)objArray[2];
1310
1311 return array;
1312 }
1313 catch (Exception e) {
1314 throw HibernateUtil.processException(e);
1315 }
1316 finally {
1317 closeSession(session);
1318 }
1319 }
1320
1321 public WikiPage findByN_T_V(long nodeId, String title, double version)
1322 throws NoSuchPageException, SystemException {
1323 WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
1324
1325 if (wikiPage == null) {
1326 StringMaker msg = new StringMaker();
1327
1328 msg.append("No WikiPage exists with the key {");
1329
1330 msg.append("nodeId=" + nodeId);
1331
1332 msg.append(", ");
1333 msg.append("title=" + title);
1334
1335 msg.append(", ");
1336 msg.append("version=" + version);
1337
1338 msg.append(StringPool.CLOSE_CURLY_BRACE);
1339
1340 if (_log.isWarnEnabled()) {
1341 _log.warn(msg.toString());
1342 }
1343
1344 throw new NoSuchPageException(msg.toString());
1345 }
1346
1347 return wikiPage;
1348 }
1349
1350 public WikiPage fetchByN_T_V(long nodeId, String title, double version)
1351 throws SystemException {
1352 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1353 String finderClassName = WikiPage.class.getName();
1354 String finderMethodName = "fetchByN_T_V";
1355 String[] finderParams = new String[] {
1356 Long.class.getName(), String.class.getName(),
1357 Double.class.getName()
1358 };
1359 Object[] finderArgs = new Object[] {
1360 new Long(nodeId),
1361
1362 title, new Double(version)
1363 };
1364
1365 Object result = null;
1366
1367 if (finderClassNameCacheEnabled) {
1368 result = FinderCache.getResult(finderClassName, finderMethodName,
1369 finderParams, finderArgs, getSessionFactory());
1370 }
1371
1372 if (result == null) {
1373 Session session = null;
1374
1375 try {
1376 session = openSession();
1377
1378 StringMaker query = new StringMaker();
1379
1380 query.append(
1381 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1382
1383 query.append("nodeId = ?");
1384
1385 query.append(" AND ");
1386
1387 if (title == null) {
1388 query.append("title IS NULL");
1389 }
1390 else {
1391 query.append("title = ?");
1392 }
1393
1394 query.append(" AND ");
1395
1396 query.append("version = ?");
1397
1398 query.append(" ");
1399
1400 query.append("ORDER BY ");
1401
1402 query.append("nodeId ASC, ");
1403 query.append("title ASC, ");
1404 query.append("version ASC");
1405
1406 Query q = session.createQuery(query.toString());
1407
1408 int queryPos = 0;
1409
1410 q.setLong(queryPos++, nodeId);
1411
1412 if (title != null) {
1413 q.setString(queryPos++, title);
1414 }
1415
1416 q.setDouble(queryPos++, version);
1417
1418 List list = q.list();
1419
1420 FinderCache.putResult(finderClassNameCacheEnabled,
1421 finderClassName, finderMethodName, finderParams,
1422 finderArgs, list);
1423
1424 if (list.size() == 0) {
1425 return null;
1426 }
1427 else {
1428 return (WikiPage)list.get(0);
1429 }
1430 }
1431 catch (Exception e) {
1432 throw HibernateUtil.processException(e);
1433 }
1434 finally {
1435 closeSession(session);
1436 }
1437 }
1438 else {
1439 List list = (List)result;
1440
1441 if (list.size() == 0) {
1442 return null;
1443 }
1444 else {
1445 return (WikiPage)list.get(0);
1446 }
1447 }
1448 }
1449
1450 public List findByN_T_H(long nodeId, String title, boolean head)
1451 throws SystemException {
1452 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1453 String finderClassName = WikiPage.class.getName();
1454 String finderMethodName = "findByN_T_H";
1455 String[] finderParams = new String[] {
1456 Long.class.getName(), String.class.getName(),
1457 Boolean.class.getName()
1458 };
1459 Object[] finderArgs = new Object[] {
1460 new Long(nodeId),
1461
1462 title, Boolean.valueOf(head)
1463 };
1464
1465 Object result = null;
1466
1467 if (finderClassNameCacheEnabled) {
1468 result = FinderCache.getResult(finderClassName, finderMethodName,
1469 finderParams, finderArgs, getSessionFactory());
1470 }
1471
1472 if (result == null) {
1473 Session session = null;
1474
1475 try {
1476 session = openSession();
1477
1478 StringMaker query = new StringMaker();
1479
1480 query.append(
1481 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1482
1483 query.append("nodeId = ?");
1484
1485 query.append(" AND ");
1486
1487 if (title == null) {
1488 query.append("title IS NULL");
1489 }
1490 else {
1491 query.append("title = ?");
1492 }
1493
1494 query.append(" AND ");
1495
1496 query.append("head = ?");
1497
1498 query.append(" ");
1499
1500 query.append("ORDER BY ");
1501
1502 query.append("nodeId ASC, ");
1503 query.append("title ASC, ");
1504 query.append("version ASC");
1505
1506 Query q = session.createQuery(query.toString());
1507
1508 int queryPos = 0;
1509
1510 q.setLong(queryPos++, nodeId);
1511
1512 if (title != null) {
1513 q.setString(queryPos++, title);
1514 }
1515
1516 q.setBoolean(queryPos++, head);
1517
1518 List list = q.list();
1519
1520 FinderCache.putResult(finderClassNameCacheEnabled,
1521 finderClassName, finderMethodName, finderParams,
1522 finderArgs, list);
1523
1524 return list;
1525 }
1526 catch (Exception e) {
1527 throw HibernateUtil.processException(e);
1528 }
1529 finally {
1530 closeSession(session);
1531 }
1532 }
1533 else {
1534 return (List)result;
1535 }
1536 }
1537
1538 public List findByN_T_H(long nodeId, String title, boolean head, int begin,
1539 int end) throws SystemException {
1540 return findByN_T_H(nodeId, title, head, begin, end, null);
1541 }
1542
1543 public List findByN_T_H(long nodeId, String title, boolean head, int begin,
1544 int end, OrderByComparator obc) throws SystemException {
1545 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1546 String finderClassName = WikiPage.class.getName();
1547 String finderMethodName = "findByN_T_H";
1548 String[] finderParams = new String[] {
1549 Long.class.getName(), String.class.getName(),
1550 Boolean.class.getName(),
1551
1552 "java.lang.Integer", "java.lang.Integer",
1553 "com.liferay.portal.kernel.util.OrderByComparator"
1554 };
1555 Object[] finderArgs = new Object[] {
1556 new Long(nodeId),
1557
1558 title, Boolean.valueOf(head),
1559
1560 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1561 };
1562
1563 Object result = null;
1564
1565 if (finderClassNameCacheEnabled) {
1566 result = FinderCache.getResult(finderClassName, finderMethodName,
1567 finderParams, finderArgs, getSessionFactory());
1568 }
1569
1570 if (result == null) {
1571 Session session = null;
1572
1573 try {
1574 session = openSession();
1575
1576 StringMaker query = new StringMaker();
1577
1578 query.append(
1579 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1580
1581 query.append("nodeId = ?");
1582
1583 query.append(" AND ");
1584
1585 if (title == null) {
1586 query.append("title IS NULL");
1587 }
1588 else {
1589 query.append("title = ?");
1590 }
1591
1592 query.append(" AND ");
1593
1594 query.append("head = ?");
1595
1596 query.append(" ");
1597
1598 if (obc != null) {
1599 query.append("ORDER BY ");
1600 query.append(obc.getOrderBy());
1601 }
1602
1603 else {
1604 query.append("ORDER BY ");
1605
1606 query.append("nodeId ASC, ");
1607 query.append("title ASC, ");
1608 query.append("version ASC");
1609 }
1610
1611 Query q = session.createQuery(query.toString());
1612
1613 int queryPos = 0;
1614
1615 q.setLong(queryPos++, nodeId);
1616
1617 if (title != null) {
1618 q.setString(queryPos++, title);
1619 }
1620
1621 q.setBoolean(queryPos++, head);
1622
1623 List list = QueryUtil.list(q, getDialect(), begin, end);
1624
1625 FinderCache.putResult(finderClassNameCacheEnabled,
1626 finderClassName, finderMethodName, finderParams,
1627 finderArgs, list);
1628
1629 return list;
1630 }
1631 catch (Exception e) {
1632 throw HibernateUtil.processException(e);
1633 }
1634 finally {
1635 closeSession(session);
1636 }
1637 }
1638 else {
1639 return (List)result;
1640 }
1641 }
1642
1643 public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
1644 OrderByComparator obc) throws NoSuchPageException, SystemException {
1645 List list = findByN_T_H(nodeId, title, head, 0, 1, obc);
1646
1647 if (list.size() == 0) {
1648 StringMaker msg = new StringMaker();
1649
1650 msg.append("No WikiPage exists with the key {");
1651
1652 msg.append("nodeId=" + nodeId);
1653
1654 msg.append(", ");
1655 msg.append("title=" + title);
1656
1657 msg.append(", ");
1658 msg.append("head=" + head);
1659
1660 msg.append(StringPool.CLOSE_CURLY_BRACE);
1661
1662 throw new NoSuchPageException(msg.toString());
1663 }
1664 else {
1665 return (WikiPage)list.get(0);
1666 }
1667 }
1668
1669 public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
1670 OrderByComparator obc) throws NoSuchPageException, SystemException {
1671 int count = countByN_T_H(nodeId, title, head);
1672
1673 List list = findByN_T_H(nodeId, title, head, count - 1, count, obc);
1674
1675 if (list.size() == 0) {
1676 StringMaker msg = new StringMaker();
1677
1678 msg.append("No WikiPage exists with the key {");
1679
1680 msg.append("nodeId=" + nodeId);
1681
1682 msg.append(", ");
1683 msg.append("title=" + title);
1684
1685 msg.append(", ");
1686 msg.append("head=" + head);
1687
1688 msg.append(StringPool.CLOSE_CURLY_BRACE);
1689
1690 throw new NoSuchPageException(msg.toString());
1691 }
1692 else {
1693 return (WikiPage)list.get(0);
1694 }
1695 }
1696
1697 public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
1698 String title, boolean head, OrderByComparator obc)
1699 throws NoSuchPageException, SystemException {
1700 WikiPage wikiPage = findByPrimaryKey(pageId);
1701
1702 int count = countByN_T_H(nodeId, title, head);
1703
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 StringMaker query = new StringMaker();
1710
1711 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1712
1713 query.append("nodeId = ?");
1714
1715 query.append(" AND ");
1716
1717 if (title == null) {
1718 query.append("title IS NULL");
1719 }
1720 else {
1721 query.append("title = ?");
1722 }
1723
1724 query.append(" AND ");
1725
1726 query.append("head = ?");
1727
1728 query.append(" ");
1729
1730 if (obc != null) {
1731 query.append("ORDER BY ");
1732 query.append(obc.getOrderBy());
1733 }
1734
1735 else {
1736 query.append("ORDER BY ");
1737
1738 query.append("nodeId ASC, ");
1739 query.append("title ASC, ");
1740 query.append("version ASC");
1741 }
1742
1743 Query q = session.createQuery(query.toString());
1744
1745 int queryPos = 0;
1746
1747 q.setLong(queryPos++, nodeId);
1748
1749 if (title != null) {
1750 q.setString(queryPos++, title);
1751 }
1752
1753 q.setBoolean(queryPos++, head);
1754
1755 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1756
1757 WikiPage[] array = new WikiPageImpl[3];
1758
1759 array[0] = (WikiPage)objArray[0];
1760 array[1] = (WikiPage)objArray[1];
1761 array[2] = (WikiPage)objArray[2];
1762
1763 return array;
1764 }
1765 catch (Exception e) {
1766 throw HibernateUtil.processException(e);
1767 }
1768 finally {
1769 closeSession(session);
1770 }
1771 }
1772
1773 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
1774 throws SystemException {
1775 Session session = null;
1776
1777 try {
1778 session = openSession();
1779
1780 DynamicQuery query = queryInitializer.initialize(session);
1781
1782 return query.list();
1783 }
1784 catch (Exception e) {
1785 throw HibernateUtil.processException(e);
1786 }
1787 finally {
1788 closeSession(session);
1789 }
1790 }
1791
1792 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
1793 int begin, int end) throws SystemException {
1794 Session session = null;
1795
1796 try {
1797 session = openSession();
1798
1799 DynamicQuery query = queryInitializer.initialize(session);
1800
1801 query.setLimit(begin, end);
1802
1803 return query.list();
1804 }
1805 catch (Exception e) {
1806 throw HibernateUtil.processException(e);
1807 }
1808 finally {
1809 closeSession(session);
1810 }
1811 }
1812
1813 public List findAll() throws SystemException {
1814 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1815 }
1816
1817 public List findAll(int begin, int end) throws SystemException {
1818 return findAll(begin, end, null);
1819 }
1820
1821 public List findAll(int begin, int end, OrderByComparator obc)
1822 throws SystemException {
1823 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1824 String finderClassName = WikiPage.class.getName();
1825 String finderMethodName = "findAll";
1826 String[] finderParams = new String[] {
1827 "java.lang.Integer", "java.lang.Integer",
1828 "com.liferay.portal.kernel.util.OrderByComparator"
1829 };
1830 Object[] finderArgs = new Object[] {
1831 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1832 };
1833
1834 Object result = null;
1835
1836 if (finderClassNameCacheEnabled) {
1837 result = FinderCache.getResult(finderClassName, finderMethodName,
1838 finderParams, finderArgs, getSessionFactory());
1839 }
1840
1841 if (result == null) {
1842 Session session = null;
1843
1844 try {
1845 session = openSession();
1846
1847 StringMaker query = new StringMaker();
1848
1849 query.append("FROM com.liferay.portlet.wiki.model.WikiPage ");
1850
1851 if (obc != null) {
1852 query.append("ORDER BY ");
1853 query.append(obc.getOrderBy());
1854 }
1855
1856 else {
1857 query.append("ORDER BY ");
1858
1859 query.append("nodeId ASC, ");
1860 query.append("title ASC, ");
1861 query.append("version ASC");
1862 }
1863
1864 Query q = session.createQuery(query.toString());
1865
1866 List list = QueryUtil.list(q, getDialect(), begin, end);
1867
1868 if (obc == null) {
1869 Collections.sort(list);
1870 }
1871
1872 FinderCache.putResult(finderClassNameCacheEnabled,
1873 finderClassName, finderMethodName, finderParams,
1874 finderArgs, list);
1875
1876 return list;
1877 }
1878 catch (Exception e) {
1879 throw HibernateUtil.processException(e);
1880 }
1881 finally {
1882 closeSession(session);
1883 }
1884 }
1885 else {
1886 return (List)result;
1887 }
1888 }
1889
1890 public void removeByUuid(String uuid) throws SystemException {
1891 Iterator itr = findByUuid(uuid).iterator();
1892
1893 while (itr.hasNext()) {
1894 WikiPage wikiPage = (WikiPage)itr.next();
1895
1896 remove(wikiPage);
1897 }
1898 }
1899
1900 public void removeByNodeId(long nodeId) throws SystemException {
1901 Iterator itr = findByNodeId(nodeId).iterator();
1902
1903 while (itr.hasNext()) {
1904 WikiPage wikiPage = (WikiPage)itr.next();
1905
1906 remove(wikiPage);
1907 }
1908 }
1909
1910 public void removeByN_T(long nodeId, String title)
1911 throws SystemException {
1912 Iterator itr = findByN_T(nodeId, title).iterator();
1913
1914 while (itr.hasNext()) {
1915 WikiPage wikiPage = (WikiPage)itr.next();
1916
1917 remove(wikiPage);
1918 }
1919 }
1920
1921 public void removeByN_H(long nodeId, boolean head)
1922 throws SystemException {
1923 Iterator itr = findByN_H(nodeId, head).iterator();
1924
1925 while (itr.hasNext()) {
1926 WikiPage wikiPage = (WikiPage)itr.next();
1927
1928 remove(wikiPage);
1929 }
1930 }
1931
1932 public void removeByN_T_V(long nodeId, String title, double version)
1933 throws NoSuchPageException, SystemException {
1934 WikiPage wikiPage = findByN_T_V(nodeId, title, version);
1935
1936 remove(wikiPage);
1937 }
1938
1939 public void removeByN_T_H(long nodeId, String title, boolean head)
1940 throws SystemException {
1941 Iterator itr = findByN_T_H(nodeId, title, head).iterator();
1942
1943 while (itr.hasNext()) {
1944 WikiPage wikiPage = (WikiPage)itr.next();
1945
1946 remove(wikiPage);
1947 }
1948 }
1949
1950 public void removeAll() throws SystemException {
1951 Iterator itr = findAll().iterator();
1952
1953 while (itr.hasNext()) {
1954 remove((WikiPage)itr.next());
1955 }
1956 }
1957
1958 public int countByUuid(String uuid) throws SystemException {
1959 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1960 String finderClassName = WikiPage.class.getName();
1961 String finderMethodName = "countByUuid";
1962 String[] finderParams = new String[] { String.class.getName() };
1963 Object[] finderArgs = new Object[] { uuid };
1964
1965 Object result = null;
1966
1967 if (finderClassNameCacheEnabled) {
1968 result = FinderCache.getResult(finderClassName, finderMethodName,
1969 finderParams, finderArgs, getSessionFactory());
1970 }
1971
1972 if (result == null) {
1973 Session session = null;
1974
1975 try {
1976 session = openSession();
1977
1978 StringMaker query = new StringMaker();
1979
1980 query.append("SELECT COUNT(*) ");
1981 query.append(
1982 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1983
1984 if (uuid == null) {
1985 query.append("uuid_ IS NULL");
1986 }
1987 else {
1988 query.append("uuid_ = ?");
1989 }
1990
1991 query.append(" ");
1992
1993 Query q = session.createQuery(query.toString());
1994
1995 int queryPos = 0;
1996
1997 if (uuid != null) {
1998 q.setString(queryPos++, uuid);
1999 }
2000
2001 Long count = null;
2002
2003 Iterator itr = q.list().iterator();
2004
2005 if (itr.hasNext()) {
2006 count = (Long)itr.next();
2007 }
2008
2009 if (count == null) {
2010 count = new Long(0);
2011 }
2012
2013 FinderCache.putResult(finderClassNameCacheEnabled,
2014 finderClassName, finderMethodName, finderParams,
2015 finderArgs, count);
2016
2017 return count.intValue();
2018 }
2019 catch (Exception e) {
2020 throw HibernateUtil.processException(e);
2021 }
2022 finally {
2023 closeSession(session);
2024 }
2025 }
2026 else {
2027 return ((Long)result).intValue();
2028 }
2029 }
2030
2031 public int countByNodeId(long nodeId) throws SystemException {
2032 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2033 String finderClassName = WikiPage.class.getName();
2034 String finderMethodName = "countByNodeId";
2035 String[] finderParams = new String[] { Long.class.getName() };
2036 Object[] finderArgs = new Object[] { new Long(nodeId) };
2037
2038 Object result = null;
2039
2040 if (finderClassNameCacheEnabled) {
2041 result = FinderCache.getResult(finderClassName, finderMethodName,
2042 finderParams, finderArgs, getSessionFactory());
2043 }
2044
2045 if (result == null) {
2046 Session session = null;
2047
2048 try {
2049 session = openSession();
2050
2051 StringMaker query = new StringMaker();
2052
2053 query.append("SELECT COUNT(*) ");
2054 query.append(
2055 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2056
2057 query.append("nodeId = ?");
2058
2059 query.append(" ");
2060
2061 Query q = session.createQuery(query.toString());
2062
2063 int queryPos = 0;
2064
2065 q.setLong(queryPos++, nodeId);
2066
2067 Long count = null;
2068
2069 Iterator itr = q.list().iterator();
2070
2071 if (itr.hasNext()) {
2072 count = (Long)itr.next();
2073 }
2074
2075 if (count == null) {
2076 count = new Long(0);
2077 }
2078
2079 FinderCache.putResult(finderClassNameCacheEnabled,
2080 finderClassName, finderMethodName, finderParams,
2081 finderArgs, count);
2082
2083 return count.intValue();
2084 }
2085 catch (Exception e) {
2086 throw HibernateUtil.processException(e);
2087 }
2088 finally {
2089 closeSession(session);
2090 }
2091 }
2092 else {
2093 return ((Long)result).intValue();
2094 }
2095 }
2096
2097 public int countByN_T(long nodeId, String title) throws SystemException {
2098 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2099 String finderClassName = WikiPage.class.getName();
2100 String finderMethodName = "countByN_T";
2101 String[] finderParams = new String[] {
2102 Long.class.getName(), String.class.getName()
2103 };
2104 Object[] finderArgs = new Object[] { new Long(nodeId), title };
2105
2106 Object result = null;
2107
2108 if (finderClassNameCacheEnabled) {
2109 result = FinderCache.getResult(finderClassName, finderMethodName,
2110 finderParams, finderArgs, getSessionFactory());
2111 }
2112
2113 if (result == null) {
2114 Session session = null;
2115
2116 try {
2117 session = openSession();
2118
2119 StringMaker query = new StringMaker();
2120
2121 query.append("SELECT COUNT(*) ");
2122 query.append(
2123 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2124
2125 query.append("nodeId = ?");
2126
2127 query.append(" AND ");
2128
2129 if (title == null) {
2130 query.append("title IS NULL");
2131 }
2132 else {
2133 query.append("title = ?");
2134 }
2135
2136 query.append(" ");
2137
2138 Query q = session.createQuery(query.toString());
2139
2140 int queryPos = 0;
2141
2142 q.setLong(queryPos++, nodeId);
2143
2144 if (title != null) {
2145 q.setString(queryPos++, title);
2146 }
2147
2148 Long count = null;
2149
2150 Iterator itr = q.list().iterator();
2151
2152 if (itr.hasNext()) {
2153 count = (Long)itr.next();
2154 }
2155
2156 if (count == null) {
2157 count = new Long(0);
2158 }
2159
2160 FinderCache.putResult(finderClassNameCacheEnabled,
2161 finderClassName, finderMethodName, finderParams,
2162 finderArgs, count);
2163
2164 return count.intValue();
2165 }
2166 catch (Exception e) {
2167 throw HibernateUtil.processException(e);
2168 }
2169 finally {
2170 closeSession(session);
2171 }
2172 }
2173 else {
2174 return ((Long)result).intValue();
2175 }
2176 }
2177
2178 public int countByN_H(long nodeId, boolean head) throws SystemException {
2179 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2180 String finderClassName = WikiPage.class.getName();
2181 String finderMethodName = "countByN_H";
2182 String[] finderParams = new String[] {
2183 Long.class.getName(), Boolean.class.getName()
2184 };
2185 Object[] finderArgs = new Object[] {
2186 new Long(nodeId), Boolean.valueOf(head)
2187 };
2188
2189 Object result = null;
2190
2191 if (finderClassNameCacheEnabled) {
2192 result = FinderCache.getResult(finderClassName, finderMethodName,
2193 finderParams, finderArgs, getSessionFactory());
2194 }
2195
2196 if (result == null) {
2197 Session session = null;
2198
2199 try {
2200 session = openSession();
2201
2202 StringMaker query = new StringMaker();
2203
2204 query.append("SELECT COUNT(*) ");
2205 query.append(
2206 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2207
2208 query.append("nodeId = ?");
2209
2210 query.append(" AND ");
2211
2212 query.append("head = ?");
2213
2214 query.append(" ");
2215
2216 Query q = session.createQuery(query.toString());
2217
2218 int queryPos = 0;
2219
2220 q.setLong(queryPos++, nodeId);
2221
2222 q.setBoolean(queryPos++, head);
2223
2224 Long count = null;
2225
2226 Iterator itr = q.list().iterator();
2227
2228 if (itr.hasNext()) {
2229 count = (Long)itr.next();
2230 }
2231
2232 if (count == null) {
2233 count = new Long(0);
2234 }
2235
2236 FinderCache.putResult(finderClassNameCacheEnabled,
2237 finderClassName, finderMethodName, finderParams,
2238 finderArgs, count);
2239
2240 return count.intValue();
2241 }
2242 catch (Exception e) {
2243 throw HibernateUtil.processException(e);
2244 }
2245 finally {
2246 closeSession(session);
2247 }
2248 }
2249 else {
2250 return ((Long)result).intValue();
2251 }
2252 }
2253
2254 public int countByN_T_V(long nodeId, String title, double version)
2255 throws SystemException {
2256 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2257 String finderClassName = WikiPage.class.getName();
2258 String finderMethodName = "countByN_T_V";
2259 String[] finderParams = new String[] {
2260 Long.class.getName(), String.class.getName(),
2261 Double.class.getName()
2262 };
2263 Object[] finderArgs = new Object[] {
2264 new Long(nodeId),
2265
2266 title, new Double(version)
2267 };
2268
2269 Object result = null;
2270
2271 if (finderClassNameCacheEnabled) {
2272 result = FinderCache.getResult(finderClassName, finderMethodName,
2273 finderParams, finderArgs, getSessionFactory());
2274 }
2275
2276 if (result == null) {
2277 Session session = null;
2278
2279 try {
2280 session = openSession();
2281
2282 StringMaker query = new StringMaker();
2283
2284 query.append("SELECT COUNT(*) ");
2285 query.append(
2286 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2287
2288 query.append("nodeId = ?");
2289
2290 query.append(" AND ");
2291
2292 if (title == null) {
2293 query.append("title IS NULL");
2294 }
2295 else {
2296 query.append("title = ?");
2297 }
2298
2299 query.append(" AND ");
2300
2301 query.append("version = ?");
2302
2303 query.append(" ");
2304
2305 Query q = session.createQuery(query.toString());
2306
2307 int queryPos = 0;
2308
2309 q.setLong(queryPos++, nodeId);
2310
2311 if (title != null) {
2312 q.setString(queryPos++, title);
2313 }
2314
2315 q.setDouble(queryPos++, version);
2316
2317 Long count = null;
2318
2319 Iterator itr = q.list().iterator();
2320
2321 if (itr.hasNext()) {
2322 count = (Long)itr.next();
2323 }
2324
2325 if (count == null) {
2326 count = new Long(0);
2327 }
2328
2329 FinderCache.putResult(finderClassNameCacheEnabled,
2330 finderClassName, finderMethodName, finderParams,
2331 finderArgs, count);
2332
2333 return count.intValue();
2334 }
2335 catch (Exception e) {
2336 throw HibernateUtil.processException(e);
2337 }
2338 finally {
2339 closeSession(session);
2340 }
2341 }
2342 else {
2343 return ((Long)result).intValue();
2344 }
2345 }
2346
2347 public int countByN_T_H(long nodeId, String title, boolean head)
2348 throws SystemException {
2349 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2350 String finderClassName = WikiPage.class.getName();
2351 String finderMethodName = "countByN_T_H";
2352 String[] finderParams = new String[] {
2353 Long.class.getName(), String.class.getName(),
2354 Boolean.class.getName()
2355 };
2356 Object[] finderArgs = new Object[] {
2357 new Long(nodeId),
2358
2359 title, Boolean.valueOf(head)
2360 };
2361
2362 Object result = null;
2363
2364 if (finderClassNameCacheEnabled) {
2365 result = FinderCache.getResult(finderClassName, finderMethodName,
2366 finderParams, finderArgs, getSessionFactory());
2367 }
2368
2369 if (result == null) {
2370 Session session = null;
2371
2372 try {
2373 session = openSession();
2374
2375 StringMaker query = new StringMaker();
2376
2377 query.append("SELECT COUNT(*) ");
2378 query.append(
2379 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2380
2381 query.append("nodeId = ?");
2382
2383 query.append(" AND ");
2384
2385 if (title == null) {
2386 query.append("title IS NULL");
2387 }
2388 else {
2389 query.append("title = ?");
2390 }
2391
2392 query.append(" AND ");
2393
2394 query.append("head = ?");
2395
2396 query.append(" ");
2397
2398 Query q = session.createQuery(query.toString());
2399
2400 int queryPos = 0;
2401
2402 q.setLong(queryPos++, nodeId);
2403
2404 if (title != null) {
2405 q.setString(queryPos++, title);
2406 }
2407
2408 q.setBoolean(queryPos++, head);
2409
2410 Long count = null;
2411
2412 Iterator itr = q.list().iterator();
2413
2414 if (itr.hasNext()) {
2415 count = (Long)itr.next();
2416 }
2417
2418 if (count == null) {
2419 count = new Long(0);
2420 }
2421
2422 FinderCache.putResult(finderClassNameCacheEnabled,
2423 finderClassName, finderMethodName, finderParams,
2424 finderArgs, count);
2425
2426 return count.intValue();
2427 }
2428 catch (Exception e) {
2429 throw HibernateUtil.processException(e);
2430 }
2431 finally {
2432 closeSession(session);
2433 }
2434 }
2435 else {
2436 return ((Long)result).intValue();
2437 }
2438 }
2439
2440 public int countAll() throws SystemException {
2441 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2442 String finderClassName = WikiPage.class.getName();
2443 String finderMethodName = "countAll";
2444 String[] finderParams = new String[] { };
2445 Object[] finderArgs = new Object[] { };
2446
2447 Object result = null;
2448
2449 if (finderClassNameCacheEnabled) {
2450 result = FinderCache.getResult(finderClassName, finderMethodName,
2451 finderParams, finderArgs, getSessionFactory());
2452 }
2453
2454 if (result == null) {
2455 Session session = null;
2456
2457 try {
2458 session = openSession();
2459
2460 Query q = session.createQuery(
2461 "SELECT COUNT(*) FROM com.liferay.portlet.wiki.model.WikiPage");
2462
2463 Long count = null;
2464
2465 Iterator itr = q.list().iterator();
2466
2467 if (itr.hasNext()) {
2468 count = (Long)itr.next();
2469 }
2470
2471 if (count == null) {
2472 count = new Long(0);
2473 }
2474
2475 FinderCache.putResult(finderClassNameCacheEnabled,
2476 finderClassName, finderMethodName, finderParams,
2477 finderArgs, count);
2478
2479 return count.intValue();
2480 }
2481 catch (Exception e) {
2482 throw HibernateUtil.processException(e);
2483 }
2484 finally {
2485 closeSession(session);
2486 }
2487 }
2488 else {
2489 return ((Long)result).intValue();
2490 }
2491 }
2492
2493 protected void initDao() {
2494 }
2495
2496 private static ModelListener _getListener() {
2497 if (Validator.isNotNull(_LISTENER)) {
2498 try {
2499 return (ModelListener)Class.forName(_LISTENER).newInstance();
2500 }
2501 catch (Exception e) {
2502 _log.error(e);
2503 }
2504 }
2505
2506 return null;
2507 }
2508
2509 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
2510 "value.object.listener.com.liferay.portlet.wiki.model.WikiPage"));
2511 private static Log _log = LogFactory.getLog(WikiPagePersistenceImpl.class);
2512}