1
22
23 package com.liferay.portlet.wiki.service.persistence;
24
25 import com.liferay.portal.NoSuchModelException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringBundler;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.kernel.util.Validator;
45 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
46 import com.liferay.portal.model.ModelListener;
47 import com.liferay.portal.service.persistence.BatchSessionUtil;
48 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
49
50 import com.liferay.portlet.wiki.NoSuchNodeException;
51 import com.liferay.portlet.wiki.model.WikiNode;
52 import com.liferay.portlet.wiki.model.impl.WikiNodeImpl;
53 import com.liferay.portlet.wiki.model.impl.WikiNodeModelImpl;
54
55 import java.io.Serializable;
56
57 import java.util.ArrayList;
58 import java.util.Collections;
59 import java.util.List;
60
61
74 public class WikiNodePersistenceImpl extends BasePersistenceImpl<WikiNode>
75 implements WikiNodePersistence {
76 public static final String FINDER_CLASS_NAME_ENTITY = WikiNodeImpl.class.getName();
77 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
78 ".List";
79 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
80 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81 "findByUuid", new String[] { String.class.getName() });
82 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
83 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84 "findByUuid",
85 new String[] {
86 String.class.getName(),
87
88 "java.lang.Integer", "java.lang.Integer",
89 "com.liferay.portal.kernel.util.OrderByComparator"
90 });
91 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
92 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
93 "countByUuid", new String[] { String.class.getName() });
94 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
95 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
96 "fetchByUUID_G",
97 new String[] { String.class.getName(), Long.class.getName() });
98 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
99 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "countByUUID_G",
101 new String[] { String.class.getName(), Long.class.getName() });
102 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
103 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104 "findByGroupId", new String[] { Long.class.getName() });
105 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
106 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
107 "findByGroupId",
108 new String[] {
109 Long.class.getName(),
110
111 "java.lang.Integer", "java.lang.Integer",
112 "com.liferay.portal.kernel.util.OrderByComparator"
113 });
114 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
115 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116 "countByGroupId", new String[] { Long.class.getName() });
117 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
118 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119 "findByCompanyId", new String[] { Long.class.getName() });
120 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
121 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
122 "findByCompanyId",
123 new String[] {
124 Long.class.getName(),
125
126 "java.lang.Integer", "java.lang.Integer",
127 "com.liferay.portal.kernel.util.OrderByComparator"
128 });
129 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
130 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131 "countByCompanyId", new String[] { Long.class.getName() });
132 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
133 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
134 "fetchByG_N",
135 new String[] { Long.class.getName(), String.class.getName() });
136 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
137 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
138 "countByG_N",
139 new String[] { Long.class.getName(), String.class.getName() });
140 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
141 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
142 "findAll", new String[0]);
143 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
144 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
145 "countAll", new String[0]);
146
147 public void cacheResult(WikiNode wikiNode) {
148 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
149 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
150
151 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
152 new Object[] { wikiNode.getUuid(), new Long(wikiNode.getGroupId()) },
153 wikiNode);
154
155 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
156 new Object[] { new Long(wikiNode.getGroupId()), wikiNode.getName() },
157 wikiNode);
158 }
159
160 public void cacheResult(List<WikiNode> wikiNodes) {
161 for (WikiNode wikiNode : wikiNodes) {
162 if (EntityCacheUtil.getResult(
163 WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
164 WikiNodeImpl.class, wikiNode.getPrimaryKey(), this) == null) {
165 cacheResult(wikiNode);
166 }
167 }
168 }
169
170 public void clearCache() {
171 CacheRegistry.clear(WikiNodeImpl.class.getName());
172 EntityCacheUtil.clearCache(WikiNodeImpl.class.getName());
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
174 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
175 }
176
177 public WikiNode create(long nodeId) {
178 WikiNode wikiNode = new WikiNodeImpl();
179
180 wikiNode.setNew(true);
181 wikiNode.setPrimaryKey(nodeId);
182
183 String uuid = PortalUUIDUtil.generate();
184
185 wikiNode.setUuid(uuid);
186
187 return wikiNode;
188 }
189
190 public WikiNode remove(Serializable primaryKey)
191 throws NoSuchModelException, SystemException {
192 return remove(((Long)primaryKey).longValue());
193 }
194
195 public WikiNode remove(long nodeId)
196 throws NoSuchNodeException, SystemException {
197 Session session = null;
198
199 try {
200 session = openSession();
201
202 WikiNode wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
203 new Long(nodeId));
204
205 if (wikiNode == null) {
206 if (_log.isWarnEnabled()) {
207 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + nodeId);
208 }
209
210 throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
211 nodeId);
212 }
213
214 return remove(wikiNode);
215 }
216 catch (NoSuchNodeException nsee) {
217 throw nsee;
218 }
219 catch (Exception e) {
220 throw processException(e);
221 }
222 finally {
223 closeSession(session);
224 }
225 }
226
227 public WikiNode remove(WikiNode wikiNode) throws SystemException {
228 for (ModelListener<WikiNode> listener : listeners) {
229 listener.onBeforeRemove(wikiNode);
230 }
231
232 wikiNode = removeImpl(wikiNode);
233
234 for (ModelListener<WikiNode> listener : listeners) {
235 listener.onAfterRemove(wikiNode);
236 }
237
238 return wikiNode;
239 }
240
241 protected WikiNode removeImpl(WikiNode wikiNode) throws SystemException {
242 wikiNode = toUnwrappedModel(wikiNode);
243
244 Session session = null;
245
246 try {
247 session = openSession();
248
249 if (wikiNode.isCachedModel() || BatchSessionUtil.isEnabled()) {
250 Object staleObject = session.get(WikiNodeImpl.class,
251 wikiNode.getPrimaryKeyObj());
252
253 if (staleObject != null) {
254 session.evict(staleObject);
255 }
256 }
257
258 session.delete(wikiNode);
259
260 session.flush();
261 }
262 catch (Exception e) {
263 throw processException(e);
264 }
265 finally {
266 closeSession(session);
267 }
268
269 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
270
271 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
272
273 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
274 new Object[] {
275 wikiNodeModelImpl.getOriginalUuid(),
276 new Long(wikiNodeModelImpl.getOriginalGroupId())
277 });
278
279 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
280 new Object[] {
281 new Long(wikiNodeModelImpl.getOriginalGroupId()),
282
283 wikiNodeModelImpl.getOriginalName()
284 });
285
286 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
287 WikiNodeImpl.class, wikiNode.getPrimaryKey());
288
289 return wikiNode;
290 }
291
292
295 public WikiNode update(WikiNode wikiNode) throws SystemException {
296 if (_log.isWarnEnabled()) {
297 _log.warn(
298 "Using the deprecated update(WikiNode wikiNode) method. Use update(WikiNode wikiNode, boolean merge) instead.");
299 }
300
301 return update(wikiNode, false);
302 }
303
304 public WikiNode updateImpl(
305 com.liferay.portlet.wiki.model.WikiNode wikiNode, boolean merge)
306 throws SystemException {
307 wikiNode = toUnwrappedModel(wikiNode);
308
309 boolean isNew = wikiNode.isNew();
310
311 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
312
313 if (Validator.isNull(wikiNode.getUuid())) {
314 String uuid = PortalUUIDUtil.generate();
315
316 wikiNode.setUuid(uuid);
317 }
318
319 Session session = null;
320
321 try {
322 session = openSession();
323
324 BatchSessionUtil.update(session, wikiNode, merge);
325
326 wikiNode.setNew(false);
327 }
328 catch (Exception e) {
329 throw processException(e);
330 }
331 finally {
332 closeSession(session);
333 }
334
335 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
336
337 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
338 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
339
340 if (!isNew &&
341 (!Validator.equals(wikiNode.getUuid(),
342 wikiNodeModelImpl.getOriginalUuid()) ||
343 (wikiNode.getGroupId() != wikiNodeModelImpl.getOriginalGroupId()))) {
344 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
345 new Object[] {
346 wikiNodeModelImpl.getOriginalUuid(),
347 new Long(wikiNodeModelImpl.getOriginalGroupId())
348 });
349 }
350
351 if (isNew ||
352 (!Validator.equals(wikiNode.getUuid(),
353 wikiNodeModelImpl.getOriginalUuid()) ||
354 (wikiNode.getGroupId() != wikiNodeModelImpl.getOriginalGroupId()))) {
355 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
356 new Object[] { wikiNode.getUuid(), new Long(
357 wikiNode.getGroupId()) }, wikiNode);
358 }
359
360 if (!isNew &&
361 ((wikiNode.getGroupId() != wikiNodeModelImpl.getOriginalGroupId()) ||
362 !Validator.equals(wikiNode.getName(),
363 wikiNodeModelImpl.getOriginalName()))) {
364 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
365 new Object[] {
366 new Long(wikiNodeModelImpl.getOriginalGroupId()),
367
368 wikiNodeModelImpl.getOriginalName()
369 });
370 }
371
372 if (isNew ||
373 ((wikiNode.getGroupId() != wikiNodeModelImpl.getOriginalGroupId()) ||
374 !Validator.equals(wikiNode.getName(),
375 wikiNodeModelImpl.getOriginalName()))) {
376 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
377 new Object[] { new Long(wikiNode.getGroupId()), wikiNode.getName() },
378 wikiNode);
379 }
380
381 return wikiNode;
382 }
383
384 protected WikiNode toUnwrappedModel(WikiNode wikiNode) {
385 if (wikiNode instanceof WikiNodeImpl) {
386 return wikiNode;
387 }
388
389 WikiNodeImpl wikiNodeImpl = new WikiNodeImpl();
390
391 wikiNodeImpl.setNew(wikiNode.isNew());
392 wikiNodeImpl.setPrimaryKey(wikiNode.getPrimaryKey());
393
394 wikiNodeImpl.setUuid(wikiNode.getUuid());
395 wikiNodeImpl.setNodeId(wikiNode.getNodeId());
396 wikiNodeImpl.setGroupId(wikiNode.getGroupId());
397 wikiNodeImpl.setCompanyId(wikiNode.getCompanyId());
398 wikiNodeImpl.setUserId(wikiNode.getUserId());
399 wikiNodeImpl.setUserName(wikiNode.getUserName());
400 wikiNodeImpl.setCreateDate(wikiNode.getCreateDate());
401 wikiNodeImpl.setModifiedDate(wikiNode.getModifiedDate());
402 wikiNodeImpl.setName(wikiNode.getName());
403 wikiNodeImpl.setDescription(wikiNode.getDescription());
404 wikiNodeImpl.setLastPostDate(wikiNode.getLastPostDate());
405
406 return wikiNodeImpl;
407 }
408
409 public WikiNode findByPrimaryKey(Serializable primaryKey)
410 throws NoSuchModelException, SystemException {
411 return findByPrimaryKey(((Long)primaryKey).longValue());
412 }
413
414 public WikiNode findByPrimaryKey(long nodeId)
415 throws NoSuchNodeException, SystemException {
416 WikiNode wikiNode = fetchByPrimaryKey(nodeId);
417
418 if (wikiNode == null) {
419 if (_log.isWarnEnabled()) {
420 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + nodeId);
421 }
422
423 throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
424 nodeId);
425 }
426
427 return wikiNode;
428 }
429
430 public WikiNode fetchByPrimaryKey(Serializable primaryKey)
431 throws SystemException {
432 return fetchByPrimaryKey(((Long)primaryKey).longValue());
433 }
434
435 public WikiNode fetchByPrimaryKey(long nodeId) throws SystemException {
436 WikiNode wikiNode = (WikiNode)EntityCacheUtil.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
437 WikiNodeImpl.class, nodeId, this);
438
439 if (wikiNode == null) {
440 Session session = null;
441
442 try {
443 session = openSession();
444
445 wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
446 new Long(nodeId));
447 }
448 catch (Exception e) {
449 throw processException(e);
450 }
451 finally {
452 if (wikiNode != null) {
453 cacheResult(wikiNode);
454 }
455
456 closeSession(session);
457 }
458 }
459
460 return wikiNode;
461 }
462
463 public List<WikiNode> findByUuid(String uuid) throws SystemException {
464 Object[] finderArgs = new Object[] { uuid };
465
466 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
467 finderArgs, this);
468
469 if (list == null) {
470 Session session = null;
471
472 try {
473 session = openSession();
474
475 StringBundler query = new StringBundler(3);
476
477 query.append(_SQL_SELECT_WIKINODE_WHERE);
478
479 if (uuid == null) {
480 query.append(_FINDER_COLUMN_UUID_UUID_1);
481 }
482 else {
483 if (uuid.equals(StringPool.BLANK)) {
484 query.append(_FINDER_COLUMN_UUID_UUID_3);
485 }
486 else {
487 query.append(_FINDER_COLUMN_UUID_UUID_2);
488 }
489 }
490
491 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
492
493 String sql = query.toString();
494
495 Query q = session.createQuery(sql);
496
497 QueryPos qPos = QueryPos.getInstance(q);
498
499 if (uuid != null) {
500 qPos.add(uuid);
501 }
502
503 list = q.list();
504 }
505 catch (Exception e) {
506 throw processException(e);
507 }
508 finally {
509 if (list == null) {
510 list = new ArrayList<WikiNode>();
511 }
512
513 cacheResult(list);
514
515 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
516 list);
517
518 closeSession(session);
519 }
520 }
521
522 return list;
523 }
524
525 public List<WikiNode> findByUuid(String uuid, int start, int end)
526 throws SystemException {
527 return findByUuid(uuid, start, end, null);
528 }
529
530 public List<WikiNode> findByUuid(String uuid, int start, int end,
531 OrderByComparator obc) throws SystemException {
532 Object[] finderArgs = new Object[] {
533 uuid,
534
535 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
536 };
537
538 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
539 finderArgs, this);
540
541 if (list == null) {
542 Session session = null;
543
544 try {
545 session = openSession();
546
547 StringBundler query = null;
548
549 if (obc != null) {
550 query = new StringBundler(3 +
551 (obc.getOrderByFields().length * 3));
552 }
553 else {
554 query = new StringBundler(3);
555 }
556
557 query.append(_SQL_SELECT_WIKINODE_WHERE);
558
559 if (uuid == null) {
560 query.append(_FINDER_COLUMN_UUID_UUID_1);
561 }
562 else {
563 if (uuid.equals(StringPool.BLANK)) {
564 query.append(_FINDER_COLUMN_UUID_UUID_3);
565 }
566 else {
567 query.append(_FINDER_COLUMN_UUID_UUID_2);
568 }
569 }
570
571 if (obc != null) {
572 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
573 }
574
575 else {
576 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
577 }
578
579 String sql = query.toString();
580
581 Query q = session.createQuery(sql);
582
583 QueryPos qPos = QueryPos.getInstance(q);
584
585 if (uuid != null) {
586 qPos.add(uuid);
587 }
588
589 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
590 end);
591 }
592 catch (Exception e) {
593 throw processException(e);
594 }
595 finally {
596 if (list == null) {
597 list = new ArrayList<WikiNode>();
598 }
599
600 cacheResult(list);
601
602 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
603 finderArgs, list);
604
605 closeSession(session);
606 }
607 }
608
609 return list;
610 }
611
612 public WikiNode findByUuid_First(String uuid, OrderByComparator obc)
613 throws NoSuchNodeException, SystemException {
614 List<WikiNode> list = findByUuid(uuid, 0, 1, obc);
615
616 if (list.isEmpty()) {
617 StringBundler msg = new StringBundler(4);
618
619 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
620
621 msg.append("uuid=");
622 msg.append(uuid);
623
624 msg.append(StringPool.CLOSE_CURLY_BRACE);
625
626 throw new NoSuchNodeException(msg.toString());
627 }
628 else {
629 return list.get(0);
630 }
631 }
632
633 public WikiNode findByUuid_Last(String uuid, OrderByComparator obc)
634 throws NoSuchNodeException, SystemException {
635 int count = countByUuid(uuid);
636
637 List<WikiNode> list = findByUuid(uuid, count - 1, count, obc);
638
639 if (list.isEmpty()) {
640 StringBundler msg = new StringBundler(4);
641
642 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
643
644 msg.append("uuid=");
645 msg.append(uuid);
646
647 msg.append(StringPool.CLOSE_CURLY_BRACE);
648
649 throw new NoSuchNodeException(msg.toString());
650 }
651 else {
652 return list.get(0);
653 }
654 }
655
656 public WikiNode[] findByUuid_PrevAndNext(long nodeId, String uuid,
657 OrderByComparator obc) throws NoSuchNodeException, SystemException {
658 WikiNode wikiNode = findByPrimaryKey(nodeId);
659
660 int count = countByUuid(uuid);
661
662 Session session = null;
663
664 try {
665 session = openSession();
666
667 StringBundler query = null;
668
669 if (obc != null) {
670 query = new StringBundler(3 +
671 (obc.getOrderByFields().length * 3));
672 }
673 else {
674 query = new StringBundler(3);
675 }
676
677 query.append(_SQL_SELECT_WIKINODE_WHERE);
678
679 if (uuid == null) {
680 query.append(_FINDER_COLUMN_UUID_UUID_1);
681 }
682 else {
683 if (uuid.equals(StringPool.BLANK)) {
684 query.append(_FINDER_COLUMN_UUID_UUID_3);
685 }
686 else {
687 query.append(_FINDER_COLUMN_UUID_UUID_2);
688 }
689 }
690
691 if (obc != null) {
692 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
693 }
694
695 else {
696 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
697 }
698
699 String sql = query.toString();
700
701 Query q = session.createQuery(sql);
702
703 QueryPos qPos = QueryPos.getInstance(q);
704
705 if (uuid != null) {
706 qPos.add(uuid);
707 }
708
709 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiNode);
710
711 WikiNode[] array = new WikiNodeImpl[3];
712
713 array[0] = (WikiNode)objArray[0];
714 array[1] = (WikiNode)objArray[1];
715 array[2] = (WikiNode)objArray[2];
716
717 return array;
718 }
719 catch (Exception e) {
720 throw processException(e);
721 }
722 finally {
723 closeSession(session);
724 }
725 }
726
727 public WikiNode findByUUID_G(String uuid, long groupId)
728 throws NoSuchNodeException, SystemException {
729 WikiNode wikiNode = fetchByUUID_G(uuid, groupId);
730
731 if (wikiNode == null) {
732 StringBundler msg = new StringBundler(6);
733
734 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
735
736 msg.append("uuid=");
737 msg.append(uuid);
738
739 msg.append(", groupId=");
740 msg.append(groupId);
741
742 msg.append(StringPool.CLOSE_CURLY_BRACE);
743
744 if (_log.isWarnEnabled()) {
745 _log.warn(msg.toString());
746 }
747
748 throw new NoSuchNodeException(msg.toString());
749 }
750
751 return wikiNode;
752 }
753
754 public WikiNode fetchByUUID_G(String uuid, long groupId)
755 throws SystemException {
756 return fetchByUUID_G(uuid, groupId, true);
757 }
758
759 public WikiNode fetchByUUID_G(String uuid, long groupId,
760 boolean retrieveFromCache) throws SystemException {
761 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
762
763 Object result = null;
764
765 if (retrieveFromCache) {
766 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
767 finderArgs, this);
768 }
769
770 if (result == null) {
771 Session session = null;
772
773 try {
774 session = openSession();
775
776 StringBundler query = new StringBundler(4);
777
778 query.append(_SQL_SELECT_WIKINODE_WHERE);
779
780 if (uuid == null) {
781 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
782 }
783 else {
784 if (uuid.equals(StringPool.BLANK)) {
785 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
786 }
787 else {
788 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
789 }
790 }
791
792 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
793
794 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
795
796 String sql = query.toString();
797
798 Query q = session.createQuery(sql);
799
800 QueryPos qPos = QueryPos.getInstance(q);
801
802 if (uuid != null) {
803 qPos.add(uuid);
804 }
805
806 qPos.add(groupId);
807
808 List<WikiNode> list = q.list();
809
810 result = list;
811
812 WikiNode wikiNode = null;
813
814 if (list.isEmpty()) {
815 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
816 finderArgs, list);
817 }
818 else {
819 wikiNode = list.get(0);
820
821 cacheResult(wikiNode);
822
823 if ((wikiNode.getUuid() == null) ||
824 !wikiNode.getUuid().equals(uuid) ||
825 (wikiNode.getGroupId() != groupId)) {
826 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
827 finderArgs, wikiNode);
828 }
829 }
830
831 return wikiNode;
832 }
833 catch (Exception e) {
834 throw processException(e);
835 }
836 finally {
837 if (result == null) {
838 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
839 finderArgs, new ArrayList<WikiNode>());
840 }
841
842 closeSession(session);
843 }
844 }
845 else {
846 if (result instanceof List<?>) {
847 return null;
848 }
849 else {
850 return (WikiNode)result;
851 }
852 }
853 }
854
855 public List<WikiNode> findByGroupId(long groupId) throws SystemException {
856 Object[] finderArgs = new Object[] { new Long(groupId) };
857
858 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
859 finderArgs, this);
860
861 if (list == null) {
862 Session session = null;
863
864 try {
865 session = openSession();
866
867 StringBundler query = new StringBundler(3);
868
869 query.append(_SQL_SELECT_WIKINODE_WHERE);
870
871 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
872
873 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
874
875 String sql = query.toString();
876
877 Query q = session.createQuery(sql);
878
879 QueryPos qPos = QueryPos.getInstance(q);
880
881 qPos.add(groupId);
882
883 list = q.list();
884 }
885 catch (Exception e) {
886 throw processException(e);
887 }
888 finally {
889 if (list == null) {
890 list = new ArrayList<WikiNode>();
891 }
892
893 cacheResult(list);
894
895 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
896 finderArgs, list);
897
898 closeSession(session);
899 }
900 }
901
902 return list;
903 }
904
905 public List<WikiNode> findByGroupId(long groupId, int start, int end)
906 throws SystemException {
907 return findByGroupId(groupId, start, end, null);
908 }
909
910 public List<WikiNode> findByGroupId(long groupId, int start, int end,
911 OrderByComparator obc) throws SystemException {
912 Object[] finderArgs = new Object[] {
913 new Long(groupId),
914
915 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
916 };
917
918 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
919 finderArgs, this);
920
921 if (list == null) {
922 Session session = null;
923
924 try {
925 session = openSession();
926
927 StringBundler query = null;
928
929 if (obc != null) {
930 query = new StringBundler(3 +
931 (obc.getOrderByFields().length * 3));
932 }
933 else {
934 query = new StringBundler(3);
935 }
936
937 query.append(_SQL_SELECT_WIKINODE_WHERE);
938
939 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
940
941 if (obc != null) {
942 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
943 }
944
945 else {
946 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
947 }
948
949 String sql = query.toString();
950
951 Query q = session.createQuery(sql);
952
953 QueryPos qPos = QueryPos.getInstance(q);
954
955 qPos.add(groupId);
956
957 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
958 end);
959 }
960 catch (Exception e) {
961 throw processException(e);
962 }
963 finally {
964 if (list == null) {
965 list = new ArrayList<WikiNode>();
966 }
967
968 cacheResult(list);
969
970 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
971 finderArgs, list);
972
973 closeSession(session);
974 }
975 }
976
977 return list;
978 }
979
980 public WikiNode findByGroupId_First(long groupId, OrderByComparator obc)
981 throws NoSuchNodeException, SystemException {
982 List<WikiNode> list = findByGroupId(groupId, 0, 1, obc);
983
984 if (list.isEmpty()) {
985 StringBundler msg = new StringBundler(4);
986
987 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
988
989 msg.append("groupId=");
990 msg.append(groupId);
991
992 msg.append(StringPool.CLOSE_CURLY_BRACE);
993
994 throw new NoSuchNodeException(msg.toString());
995 }
996 else {
997 return list.get(0);
998 }
999 }
1000
1001 public WikiNode findByGroupId_Last(long groupId, OrderByComparator obc)
1002 throws NoSuchNodeException, SystemException {
1003 int count = countByGroupId(groupId);
1004
1005 List<WikiNode> list = findByGroupId(groupId, count - 1, count, obc);
1006
1007 if (list.isEmpty()) {
1008 StringBundler msg = new StringBundler(4);
1009
1010 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1011
1012 msg.append("groupId=");
1013 msg.append(groupId);
1014
1015 msg.append(StringPool.CLOSE_CURLY_BRACE);
1016
1017 throw new NoSuchNodeException(msg.toString());
1018 }
1019 else {
1020 return list.get(0);
1021 }
1022 }
1023
1024 public WikiNode[] findByGroupId_PrevAndNext(long nodeId, long groupId,
1025 OrderByComparator obc) throws NoSuchNodeException, SystemException {
1026 WikiNode wikiNode = findByPrimaryKey(nodeId);
1027
1028 int count = countByGroupId(groupId);
1029
1030 Session session = null;
1031
1032 try {
1033 session = openSession();
1034
1035 StringBundler query = null;
1036
1037 if (obc != null) {
1038 query = new StringBundler(3 +
1039 (obc.getOrderByFields().length * 3));
1040 }
1041 else {
1042 query = new StringBundler(3);
1043 }
1044
1045 query.append(_SQL_SELECT_WIKINODE_WHERE);
1046
1047 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1048
1049 if (obc != null) {
1050 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1051 }
1052
1053 else {
1054 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1055 }
1056
1057 String sql = query.toString();
1058
1059 Query q = session.createQuery(sql);
1060
1061 QueryPos qPos = QueryPos.getInstance(q);
1062
1063 qPos.add(groupId);
1064
1065 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiNode);
1066
1067 WikiNode[] array = new WikiNodeImpl[3];
1068
1069 array[0] = (WikiNode)objArray[0];
1070 array[1] = (WikiNode)objArray[1];
1071 array[2] = (WikiNode)objArray[2];
1072
1073 return array;
1074 }
1075 catch (Exception e) {
1076 throw processException(e);
1077 }
1078 finally {
1079 closeSession(session);
1080 }
1081 }
1082
1083 public List<WikiNode> findByCompanyId(long companyId)
1084 throws SystemException {
1085 Object[] finderArgs = new Object[] { new Long(companyId) };
1086
1087 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1088 finderArgs, this);
1089
1090 if (list == null) {
1091 Session session = null;
1092
1093 try {
1094 session = openSession();
1095
1096 StringBundler query = new StringBundler(3);
1097
1098 query.append(_SQL_SELECT_WIKINODE_WHERE);
1099
1100 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1101
1102 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1103
1104 String sql = query.toString();
1105
1106 Query q = session.createQuery(sql);
1107
1108 QueryPos qPos = QueryPos.getInstance(q);
1109
1110 qPos.add(companyId);
1111
1112 list = q.list();
1113 }
1114 catch (Exception e) {
1115 throw processException(e);
1116 }
1117 finally {
1118 if (list == null) {
1119 list = new ArrayList<WikiNode>();
1120 }
1121
1122 cacheResult(list);
1123
1124 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1125 finderArgs, list);
1126
1127 closeSession(session);
1128 }
1129 }
1130
1131 return list;
1132 }
1133
1134 public List<WikiNode> findByCompanyId(long companyId, int start, int end)
1135 throws SystemException {
1136 return findByCompanyId(companyId, start, end, null);
1137 }
1138
1139 public List<WikiNode> findByCompanyId(long companyId, int start, int end,
1140 OrderByComparator obc) throws SystemException {
1141 Object[] finderArgs = new Object[] {
1142 new Long(companyId),
1143
1144 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1145 };
1146
1147 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1148 finderArgs, this);
1149
1150 if (list == null) {
1151 Session session = null;
1152
1153 try {
1154 session = openSession();
1155
1156 StringBundler query = null;
1157
1158 if (obc != null) {
1159 query = new StringBundler(3 +
1160 (obc.getOrderByFields().length * 3));
1161 }
1162 else {
1163 query = new StringBundler(3);
1164 }
1165
1166 query.append(_SQL_SELECT_WIKINODE_WHERE);
1167
1168 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1169
1170 if (obc != null) {
1171 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1172 }
1173
1174 else {
1175 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1176 }
1177
1178 String sql = query.toString();
1179
1180 Query q = session.createQuery(sql);
1181
1182 QueryPos qPos = QueryPos.getInstance(q);
1183
1184 qPos.add(companyId);
1185
1186 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
1187 end);
1188 }
1189 catch (Exception e) {
1190 throw processException(e);
1191 }
1192 finally {
1193 if (list == null) {
1194 list = new ArrayList<WikiNode>();
1195 }
1196
1197 cacheResult(list);
1198
1199 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1200 finderArgs, list);
1201
1202 closeSession(session);
1203 }
1204 }
1205
1206 return list;
1207 }
1208
1209 public WikiNode findByCompanyId_First(long companyId, OrderByComparator obc)
1210 throws NoSuchNodeException, SystemException {
1211 List<WikiNode> list = findByCompanyId(companyId, 0, 1, obc);
1212
1213 if (list.isEmpty()) {
1214 StringBundler msg = new StringBundler(4);
1215
1216 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1217
1218 msg.append("companyId=");
1219 msg.append(companyId);
1220
1221 msg.append(StringPool.CLOSE_CURLY_BRACE);
1222
1223 throw new NoSuchNodeException(msg.toString());
1224 }
1225 else {
1226 return list.get(0);
1227 }
1228 }
1229
1230 public WikiNode findByCompanyId_Last(long companyId, OrderByComparator obc)
1231 throws NoSuchNodeException, SystemException {
1232 int count = countByCompanyId(companyId);
1233
1234 List<WikiNode> list = findByCompanyId(companyId, count - 1, count, obc);
1235
1236 if (list.isEmpty()) {
1237 StringBundler msg = new StringBundler(4);
1238
1239 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1240
1241 msg.append("companyId=");
1242 msg.append(companyId);
1243
1244 msg.append(StringPool.CLOSE_CURLY_BRACE);
1245
1246 throw new NoSuchNodeException(msg.toString());
1247 }
1248 else {
1249 return list.get(0);
1250 }
1251 }
1252
1253 public WikiNode[] findByCompanyId_PrevAndNext(long nodeId, long companyId,
1254 OrderByComparator obc) throws NoSuchNodeException, SystemException {
1255 WikiNode wikiNode = findByPrimaryKey(nodeId);
1256
1257 int count = countByCompanyId(companyId);
1258
1259 Session session = null;
1260
1261 try {
1262 session = openSession();
1263
1264 StringBundler query = null;
1265
1266 if (obc != null) {
1267 query = new StringBundler(3 +
1268 (obc.getOrderByFields().length * 3));
1269 }
1270 else {
1271 query = new StringBundler(3);
1272 }
1273
1274 query.append(_SQL_SELECT_WIKINODE_WHERE);
1275
1276 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1277
1278 if (obc != null) {
1279 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1280 }
1281
1282 else {
1283 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1284 }
1285
1286 String sql = query.toString();
1287
1288 Query q = session.createQuery(sql);
1289
1290 QueryPos qPos = QueryPos.getInstance(q);
1291
1292 qPos.add(companyId);
1293
1294 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiNode);
1295
1296 WikiNode[] array = new WikiNodeImpl[3];
1297
1298 array[0] = (WikiNode)objArray[0];
1299 array[1] = (WikiNode)objArray[1];
1300 array[2] = (WikiNode)objArray[2];
1301
1302 return array;
1303 }
1304 catch (Exception e) {
1305 throw processException(e);
1306 }
1307 finally {
1308 closeSession(session);
1309 }
1310 }
1311
1312 public WikiNode findByG_N(long groupId, String name)
1313 throws NoSuchNodeException, SystemException {
1314 WikiNode wikiNode = fetchByG_N(groupId, name);
1315
1316 if (wikiNode == null) {
1317 StringBundler msg = new StringBundler(6);
1318
1319 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1320
1321 msg.append("groupId=");
1322 msg.append(groupId);
1323
1324 msg.append(", name=");
1325 msg.append(name);
1326
1327 msg.append(StringPool.CLOSE_CURLY_BRACE);
1328
1329 if (_log.isWarnEnabled()) {
1330 _log.warn(msg.toString());
1331 }
1332
1333 throw new NoSuchNodeException(msg.toString());
1334 }
1335
1336 return wikiNode;
1337 }
1338
1339 public WikiNode fetchByG_N(long groupId, String name)
1340 throws SystemException {
1341 return fetchByG_N(groupId, name, true);
1342 }
1343
1344 public WikiNode fetchByG_N(long groupId, String name,
1345 boolean retrieveFromCache) throws SystemException {
1346 Object[] finderArgs = new Object[] { new Long(groupId), name };
1347
1348 Object result = null;
1349
1350 if (retrieveFromCache) {
1351 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1352 finderArgs, this);
1353 }
1354
1355 if (result == null) {
1356 Session session = null;
1357
1358 try {
1359 session = openSession();
1360
1361 StringBundler query = new StringBundler(4);
1362
1363 query.append(_SQL_SELECT_WIKINODE_WHERE);
1364
1365 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1366
1367 if (name == null) {
1368 query.append(_FINDER_COLUMN_G_N_NAME_1);
1369 }
1370 else {
1371 if (name.equals(StringPool.BLANK)) {
1372 query.append(_FINDER_COLUMN_G_N_NAME_3);
1373 }
1374 else {
1375 query.append(_FINDER_COLUMN_G_N_NAME_2);
1376 }
1377 }
1378
1379 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1380
1381 String sql = query.toString();
1382
1383 Query q = session.createQuery(sql);
1384
1385 QueryPos qPos = QueryPos.getInstance(q);
1386
1387 qPos.add(groupId);
1388
1389 if (name != null) {
1390 qPos.add(name);
1391 }
1392
1393 List<WikiNode> list = q.list();
1394
1395 result = list;
1396
1397 WikiNode wikiNode = null;
1398
1399 if (list.isEmpty()) {
1400 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1401 finderArgs, list);
1402 }
1403 else {
1404 wikiNode = list.get(0);
1405
1406 cacheResult(wikiNode);
1407
1408 if ((wikiNode.getGroupId() != groupId) ||
1409 (wikiNode.getName() == null) ||
1410 !wikiNode.getName().equals(name)) {
1411 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1412 finderArgs, wikiNode);
1413 }
1414 }
1415
1416 return wikiNode;
1417 }
1418 catch (Exception e) {
1419 throw processException(e);
1420 }
1421 finally {
1422 if (result == null) {
1423 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1424 finderArgs, new ArrayList<WikiNode>());
1425 }
1426
1427 closeSession(session);
1428 }
1429 }
1430 else {
1431 if (result instanceof List<?>) {
1432 return null;
1433 }
1434 else {
1435 return (WikiNode)result;
1436 }
1437 }
1438 }
1439
1440 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1441 throws SystemException {
1442 Session session = null;
1443
1444 try {
1445 session = openSession();
1446
1447 dynamicQuery.compile(session);
1448
1449 return dynamicQuery.list();
1450 }
1451 catch (Exception e) {
1452 throw processException(e);
1453 }
1454 finally {
1455 closeSession(session);
1456 }
1457 }
1458
1459 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1460 int start, int end) throws SystemException {
1461 Session session = null;
1462
1463 try {
1464 session = openSession();
1465
1466 dynamicQuery.setLimit(start, end);
1467
1468 dynamicQuery.compile(session);
1469
1470 return dynamicQuery.list();
1471 }
1472 catch (Exception e) {
1473 throw processException(e);
1474 }
1475 finally {
1476 closeSession(session);
1477 }
1478 }
1479
1480 public List<WikiNode> findAll() throws SystemException {
1481 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1482 }
1483
1484 public List<WikiNode> findAll(int start, int end) throws SystemException {
1485 return findAll(start, end, null);
1486 }
1487
1488 public List<WikiNode> findAll(int start, int end, OrderByComparator obc)
1489 throws SystemException {
1490 Object[] finderArgs = new Object[] {
1491 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1492 };
1493
1494 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1495 finderArgs, this);
1496
1497 if (list == null) {
1498 Session session = null;
1499
1500 try {
1501 session = openSession();
1502
1503 StringBundler query = null;
1504 String sql = null;
1505
1506 if (obc != null) {
1507 query = new StringBundler(2 +
1508 (obc.getOrderByFields().length * 3));
1509
1510 query.append(_SQL_SELECT_WIKINODE);
1511
1512 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1513
1514 sql = query.toString();
1515 }
1516
1517 else {
1518 sql = _SQL_SELECT_WIKINODE.concat(WikiNodeModelImpl.ORDER_BY_JPQL);
1519 }
1520
1521 Query q = session.createQuery(sql);
1522
1523 if (obc == null) {
1524 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1525 start, end, false);
1526
1527 Collections.sort(list);
1528 }
1529 else {
1530 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1531 start, end);
1532 }
1533 }
1534 catch (Exception e) {
1535 throw processException(e);
1536 }
1537 finally {
1538 if (list == null) {
1539 list = new ArrayList<WikiNode>();
1540 }
1541
1542 cacheResult(list);
1543
1544 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1545
1546 closeSession(session);
1547 }
1548 }
1549
1550 return list;
1551 }
1552
1553 public void removeByUuid(String uuid) throws SystemException {
1554 for (WikiNode wikiNode : findByUuid(uuid)) {
1555 remove(wikiNode);
1556 }
1557 }
1558
1559 public void removeByUUID_G(String uuid, long groupId)
1560 throws NoSuchNodeException, SystemException {
1561 WikiNode wikiNode = findByUUID_G(uuid, groupId);
1562
1563 remove(wikiNode);
1564 }
1565
1566 public void removeByGroupId(long groupId) throws SystemException {
1567 for (WikiNode wikiNode : findByGroupId(groupId)) {
1568 remove(wikiNode);
1569 }
1570 }
1571
1572 public void removeByCompanyId(long companyId) throws SystemException {
1573 for (WikiNode wikiNode : findByCompanyId(companyId)) {
1574 remove(wikiNode);
1575 }
1576 }
1577
1578 public void removeByG_N(long groupId, String name)
1579 throws NoSuchNodeException, SystemException {
1580 WikiNode wikiNode = findByG_N(groupId, name);
1581
1582 remove(wikiNode);
1583 }
1584
1585 public void removeAll() throws SystemException {
1586 for (WikiNode wikiNode : findAll()) {
1587 remove(wikiNode);
1588 }
1589 }
1590
1591 public int countByUuid(String uuid) throws SystemException {
1592 Object[] finderArgs = new Object[] { uuid };
1593
1594 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1595 finderArgs, this);
1596
1597 if (count == null) {
1598 Session session = null;
1599
1600 try {
1601 session = openSession();
1602
1603 StringBundler query = new StringBundler(2);
1604
1605 query.append(_SQL_COUNT_WIKINODE_WHERE);
1606
1607 if (uuid == null) {
1608 query.append(_FINDER_COLUMN_UUID_UUID_1);
1609 }
1610 else {
1611 if (uuid.equals(StringPool.BLANK)) {
1612 query.append(_FINDER_COLUMN_UUID_UUID_3);
1613 }
1614 else {
1615 query.append(_FINDER_COLUMN_UUID_UUID_2);
1616 }
1617 }
1618
1619 String sql = query.toString();
1620
1621 Query q = session.createQuery(sql);
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 if (uuid != null) {
1626 qPos.add(uuid);
1627 }
1628
1629 count = (Long)q.uniqueResult();
1630 }
1631 catch (Exception e) {
1632 throw processException(e);
1633 }
1634 finally {
1635 if (count == null) {
1636 count = Long.valueOf(0);
1637 }
1638
1639 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1640 finderArgs, count);
1641
1642 closeSession(session);
1643 }
1644 }
1645
1646 return count.intValue();
1647 }
1648
1649 public int countByUUID_G(String uuid, long groupId)
1650 throws SystemException {
1651 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1652
1653 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1654 finderArgs, this);
1655
1656 if (count == null) {
1657 Session session = null;
1658
1659 try {
1660 session = openSession();
1661
1662 StringBundler query = new StringBundler(3);
1663
1664 query.append(_SQL_COUNT_WIKINODE_WHERE);
1665
1666 if (uuid == null) {
1667 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1668 }
1669 else {
1670 if (uuid.equals(StringPool.BLANK)) {
1671 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1672 }
1673 else {
1674 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1675 }
1676 }
1677
1678 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1679
1680 String sql = query.toString();
1681
1682 Query q = session.createQuery(sql);
1683
1684 QueryPos qPos = QueryPos.getInstance(q);
1685
1686 if (uuid != null) {
1687 qPos.add(uuid);
1688 }
1689
1690 qPos.add(groupId);
1691
1692 count = (Long)q.uniqueResult();
1693 }
1694 catch (Exception e) {
1695 throw processException(e);
1696 }
1697 finally {
1698 if (count == null) {
1699 count = Long.valueOf(0);
1700 }
1701
1702 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1703 finderArgs, count);
1704
1705 closeSession(session);
1706 }
1707 }
1708
1709 return count.intValue();
1710 }
1711
1712 public int countByGroupId(long groupId) throws SystemException {
1713 Object[] finderArgs = new Object[] { new Long(groupId) };
1714
1715 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1716 finderArgs, this);
1717
1718 if (count == null) {
1719 Session session = null;
1720
1721 try {
1722 session = openSession();
1723
1724 StringBundler query = new StringBundler(2);
1725
1726 query.append(_SQL_COUNT_WIKINODE_WHERE);
1727
1728 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1729
1730 String sql = query.toString();
1731
1732 Query q = session.createQuery(sql);
1733
1734 QueryPos qPos = QueryPos.getInstance(q);
1735
1736 qPos.add(groupId);
1737
1738 count = (Long)q.uniqueResult();
1739 }
1740 catch (Exception e) {
1741 throw processException(e);
1742 }
1743 finally {
1744 if (count == null) {
1745 count = Long.valueOf(0);
1746 }
1747
1748 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1749 finderArgs, count);
1750
1751 closeSession(session);
1752 }
1753 }
1754
1755 return count.intValue();
1756 }
1757
1758 public int countByCompanyId(long companyId) throws SystemException {
1759 Object[] finderArgs = new Object[] { new Long(companyId) };
1760
1761 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1762 finderArgs, this);
1763
1764 if (count == null) {
1765 Session session = null;
1766
1767 try {
1768 session = openSession();
1769
1770 StringBundler query = new StringBundler(2);
1771
1772 query.append(_SQL_COUNT_WIKINODE_WHERE);
1773
1774 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1775
1776 String sql = query.toString();
1777
1778 Query q = session.createQuery(sql);
1779
1780 QueryPos qPos = QueryPos.getInstance(q);
1781
1782 qPos.add(companyId);
1783
1784 count = (Long)q.uniqueResult();
1785 }
1786 catch (Exception e) {
1787 throw processException(e);
1788 }
1789 finally {
1790 if (count == null) {
1791 count = Long.valueOf(0);
1792 }
1793
1794 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1795 finderArgs, count);
1796
1797 closeSession(session);
1798 }
1799 }
1800
1801 return count.intValue();
1802 }
1803
1804 public int countByG_N(long groupId, String name) throws SystemException {
1805 Object[] finderArgs = new Object[] { new Long(groupId), name };
1806
1807 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1808 finderArgs, this);
1809
1810 if (count == null) {
1811 Session session = null;
1812
1813 try {
1814 session = openSession();
1815
1816 StringBundler query = new StringBundler(3);
1817
1818 query.append(_SQL_COUNT_WIKINODE_WHERE);
1819
1820 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1821
1822 if (name == null) {
1823 query.append(_FINDER_COLUMN_G_N_NAME_1);
1824 }
1825 else {
1826 if (name.equals(StringPool.BLANK)) {
1827 query.append(_FINDER_COLUMN_G_N_NAME_3);
1828 }
1829 else {
1830 query.append(_FINDER_COLUMN_G_N_NAME_2);
1831 }
1832 }
1833
1834 String sql = query.toString();
1835
1836 Query q = session.createQuery(sql);
1837
1838 QueryPos qPos = QueryPos.getInstance(q);
1839
1840 qPos.add(groupId);
1841
1842 if (name != null) {
1843 qPos.add(name);
1844 }
1845
1846 count = (Long)q.uniqueResult();
1847 }
1848 catch (Exception e) {
1849 throw processException(e);
1850 }
1851 finally {
1852 if (count == null) {
1853 count = Long.valueOf(0);
1854 }
1855
1856 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1857 count);
1858
1859 closeSession(session);
1860 }
1861 }
1862
1863 return count.intValue();
1864 }
1865
1866 public int countAll() throws SystemException {
1867 Object[] finderArgs = new Object[0];
1868
1869 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1870 finderArgs, this);
1871
1872 if (count == null) {
1873 Session session = null;
1874
1875 try {
1876 session = openSession();
1877
1878 Query q = session.createQuery(_SQL_COUNT_WIKINODE);
1879
1880 count = (Long)q.uniqueResult();
1881 }
1882 catch (Exception e) {
1883 throw processException(e);
1884 }
1885 finally {
1886 if (count == null) {
1887 count = Long.valueOf(0);
1888 }
1889
1890 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1891 count);
1892
1893 closeSession(session);
1894 }
1895 }
1896
1897 return count.intValue();
1898 }
1899
1900 public void afterPropertiesSet() {
1901 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1902 com.liferay.portal.util.PropsUtil.get(
1903 "value.object.listener.com.liferay.portlet.wiki.model.WikiNode")));
1904
1905 if (listenerClassNames.length > 0) {
1906 try {
1907 List<ModelListener<WikiNode>> listenersList = new ArrayList<ModelListener<WikiNode>>();
1908
1909 for (String listenerClassName : listenerClassNames) {
1910 listenersList.add((ModelListener<WikiNode>)Class.forName(
1911 listenerClassName).newInstance());
1912 }
1913
1914 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1915 }
1916 catch (Exception e) {
1917 _log.error(e);
1918 }
1919 }
1920 }
1921
1922 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiNodePersistence")
1923 protected com.liferay.portlet.wiki.service.persistence.WikiNodePersistence wikiNodePersistence;
1924 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPagePersistence")
1925 protected com.liferay.portlet.wiki.service.persistence.WikiPagePersistence wikiPagePersistence;
1926 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence")
1927 protected com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence wikiPageResourcePersistence;
1928 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
1929 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1930 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1931 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1932 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
1933 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1934 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1935 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1936 private static final String _SQL_SELECT_WIKINODE = "SELECT wikiNode FROM WikiNode wikiNode";
1937 private static final String _SQL_SELECT_WIKINODE_WHERE = "SELECT wikiNode FROM WikiNode wikiNode WHERE ";
1938 private static final String _SQL_COUNT_WIKINODE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode";
1939 private static final String _SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode WHERE ";
1940 private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiNode.uuid IS NULL";
1941 private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiNode.uuid = ?";
1942 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?)";
1943 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiNode.uuid IS NULL AND ";
1944 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiNode.uuid = ? AND ";
1945 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?) AND ";
1946 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiNode.groupId = ?";
1947 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "wikiNode.groupId = ?";
1948 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "wikiNode.companyId = ?";
1949 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "wikiNode.groupId = ? AND ";
1950 private static final String _FINDER_COLUMN_G_N_NAME_1 = "wikiNode.name IS NULL";
1951 private static final String _FINDER_COLUMN_G_N_NAME_2 = "wikiNode.name = ?";
1952 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(wikiNode.name IS NULL OR wikiNode.name = ?)";
1953 private static final String _ORDER_BY_ENTITY_ALIAS = "wikiNode.";
1954 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiNode exists with the primary key ";
1955 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiNode exists with the key {";
1956 private static Log _log = LogFactoryUtil.getLog(WikiNodePersistenceImpl.class);
1957}