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