001
014
015 package com.liferay.portlet.wiki.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042 import com.liferay.portal.service.persistence.BatchSessionUtil;
043 import com.liferay.portal.service.persistence.GroupPersistence;
044 import com.liferay.portal.service.persistence.ResourcePersistence;
045 import com.liferay.portal.service.persistence.SubscriptionPersistence;
046 import com.liferay.portal.service.persistence.UserPersistence;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048
049 import com.liferay.portlet.wiki.NoSuchNodeException;
050 import com.liferay.portlet.wiki.model.WikiNode;
051 import com.liferay.portlet.wiki.model.impl.WikiNodeImpl;
052 import com.liferay.portlet.wiki.model.impl.WikiNodeModelImpl;
053
054 import java.io.Serializable;
055
056 import java.util.ArrayList;
057 import java.util.Collections;
058 import java.util.List;
059
060
072 public class WikiNodePersistenceImpl extends BasePersistenceImpl<WikiNode>
073 implements WikiNodePersistence {
074
079 public static final String FINDER_CLASS_NAME_ENTITY = WikiNodeImpl.class.getName();
080 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List1";
082 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083 ".List2";
084 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
085 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
086 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
087 new String[] {
088 String.class.getName(),
089
090 "java.lang.Integer", "java.lang.Integer",
091 "com.liferay.portal.kernel.util.OrderByComparator"
092 });
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
094 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
096 new String[] { String.class.getName() },
097 WikiNodeModelImpl.UUID_COLUMN_BITMASK);
098 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
099 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
101 new String[] { String.class.getName() });
102 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
103 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
104 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
105 new String[] { String.class.getName(), Long.class.getName() },
106 WikiNodeModelImpl.UUID_COLUMN_BITMASK |
107 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
109 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
111 new String[] { String.class.getName(), Long.class.getName() });
112 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
113 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
114 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
115 new String[] {
116 Long.class.getName(),
117
118 "java.lang.Integer", "java.lang.Integer",
119 "com.liferay.portal.kernel.util.OrderByComparator"
120 });
121 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
122 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
123 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
124 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
125 new String[] { Long.class.getName() },
126 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK);
127 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
128 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
129 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
130 new String[] { Long.class.getName() });
131 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
132 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
133 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
134 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
135 new String[] {
136 Long.class.getName(),
137
138 "java.lang.Integer", "java.lang.Integer",
139 "com.liferay.portal.kernel.util.OrderByComparator"
140 });
141 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
142 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
143 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
144 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
145 new String[] { Long.class.getName() },
146 WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK);
147 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
148 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
149 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
150 new String[] { Long.class.getName() });
151 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
152 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
153 FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
154 new String[] { Long.class.getName(), String.class.getName() },
155 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
156 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
157 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
158 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
159 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
160 new String[] { Long.class.getName(), String.class.getName() });
161 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
162 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
163 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
164 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
165 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
166 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
167 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
168 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
169 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
170
171
176 public void cacheResult(WikiNode wikiNode) {
177 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
178 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
179
180 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
181 new Object[] { wikiNode.getUuid(), Long.valueOf(
182 wikiNode.getGroupId()) }, wikiNode);
183
184 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
185 new Object[] { Long.valueOf(wikiNode.getGroupId()), wikiNode.getName() },
186 wikiNode);
187
188 wikiNode.resetOriginalValues();
189 }
190
191
196 public void cacheResult(List<WikiNode> wikiNodes) {
197 for (WikiNode wikiNode : wikiNodes) {
198 if (EntityCacheUtil.getResult(
199 WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
200 WikiNodeImpl.class, wikiNode.getPrimaryKey()) == null) {
201 cacheResult(wikiNode);
202 }
203 else {
204 wikiNode.resetOriginalValues();
205 }
206 }
207 }
208
209
216 @Override
217 public void clearCache() {
218 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
219 CacheRegistryUtil.clear(WikiNodeImpl.class.getName());
220 }
221
222 EntityCacheUtil.clearCache(WikiNodeImpl.class.getName());
223
224 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
225 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
226 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
227 }
228
229
236 @Override
237 public void clearCache(WikiNode wikiNode) {
238 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
239 WikiNodeImpl.class, wikiNode.getPrimaryKey());
240
241 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
242 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
243
244 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
245 new Object[] { wikiNode.getUuid(), Long.valueOf(
246 wikiNode.getGroupId()) });
247
248 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
249 new Object[] { Long.valueOf(wikiNode.getGroupId()), wikiNode.getName() });
250 }
251
252
258 public WikiNode create(long nodeId) {
259 WikiNode wikiNode = new WikiNodeImpl();
260
261 wikiNode.setNew(true);
262 wikiNode.setPrimaryKey(nodeId);
263
264 String uuid = PortalUUIDUtil.generate();
265
266 wikiNode.setUuid(uuid);
267
268 return wikiNode;
269 }
270
271
279 @Override
280 public WikiNode remove(Serializable primaryKey)
281 throws NoSuchModelException, SystemException {
282 return remove(((Long)primaryKey).longValue());
283 }
284
285
293 public WikiNode remove(long nodeId)
294 throws NoSuchNodeException, SystemException {
295 Session session = null;
296
297 try {
298 session = openSession();
299
300 WikiNode wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
301 Long.valueOf(nodeId));
302
303 if (wikiNode == null) {
304 if (_log.isWarnEnabled()) {
305 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + nodeId);
306 }
307
308 throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
309 nodeId);
310 }
311
312 return wikiNodePersistence.remove(wikiNode);
313 }
314 catch (NoSuchNodeException nsee) {
315 throw nsee;
316 }
317 catch (Exception e) {
318 throw processException(e);
319 }
320 finally {
321 closeSession(session);
322 }
323 }
324
325
332 @Override
333 public WikiNode remove(WikiNode wikiNode) throws SystemException {
334 return super.remove(wikiNode);
335 }
336
337 @Override
338 protected WikiNode removeImpl(WikiNode wikiNode) throws SystemException {
339 wikiNode = toUnwrappedModel(wikiNode);
340
341 Session session = null;
342
343 try {
344 session = openSession();
345
346 BatchSessionUtil.delete(session, wikiNode);
347 }
348 catch (Exception e) {
349 throw processException(e);
350 }
351 finally {
352 closeSession(session);
353 }
354
355 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
356 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
357
358 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
359
360 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
361 new Object[] {
362 wikiNodeModelImpl.getUuid(),
363 Long.valueOf(wikiNodeModelImpl.getGroupId())
364 });
365
366 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
367 new Object[] {
368 Long.valueOf(wikiNodeModelImpl.getGroupId()),
369
370 wikiNodeModelImpl.getName()
371 });
372
373 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
374 WikiNodeImpl.class, wikiNode.getPrimaryKey());
375
376 return wikiNode;
377 }
378
379 @Override
380 public WikiNode updateImpl(
381 com.liferay.portlet.wiki.model.WikiNode wikiNode, boolean merge)
382 throws SystemException {
383 wikiNode = toUnwrappedModel(wikiNode);
384
385 boolean isNew = wikiNode.isNew();
386
387 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
388
389 if (Validator.isNull(wikiNode.getUuid())) {
390 String uuid = PortalUUIDUtil.generate();
391
392 wikiNode.setUuid(uuid);
393 }
394
395 Session session = null;
396
397 try {
398 session = openSession();
399
400 BatchSessionUtil.update(session, wikiNode, merge);
401
402 wikiNode.setNew(false);
403 }
404 catch (Exception e) {
405 throw processException(e);
406 }
407 finally {
408 closeSession(session);
409 }
410
411 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
412
413 if (isNew || !WikiNodeModelImpl.COLUMN_BITMASK_ENABLED) {
414 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
415 }
416
417 else {
418 if ((wikiNodeModelImpl.getColumnBitmask() &
419 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
420 Object[] args = new Object[] { wikiNodeModelImpl.getOriginalUuid() };
421
422 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
423 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
424 args);
425
426 args = new Object[] { wikiNodeModelImpl.getUuid() };
427
428 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
429 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
430 args);
431 }
432
433 if ((wikiNodeModelImpl.getColumnBitmask() &
434 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
435 Object[] args = new Object[] {
436 Long.valueOf(wikiNodeModelImpl.getOriginalGroupId())
437 };
438
439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
440 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
441 args);
442
443 args = new Object[] { Long.valueOf(wikiNodeModelImpl.getGroupId()) };
444
445 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
446 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
447 args);
448 }
449
450 if ((wikiNodeModelImpl.getColumnBitmask() &
451 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
452 Object[] args = new Object[] {
453 Long.valueOf(wikiNodeModelImpl.getOriginalCompanyId())
454 };
455
456 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
457 args);
458 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
459 args);
460
461 args = new Object[] {
462 Long.valueOf(wikiNodeModelImpl.getCompanyId())
463 };
464
465 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
466 args);
467 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
468 args);
469 }
470 }
471
472 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
473 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
474
475 if (isNew) {
476 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
477 new Object[] {
478 wikiNode.getUuid(), Long.valueOf(wikiNode.getGroupId())
479 }, wikiNode);
480
481 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
482 new Object[] {
483 Long.valueOf(wikiNode.getGroupId()),
484
485 wikiNode.getName()
486 }, wikiNode);
487 }
488 else {
489 if ((wikiNodeModelImpl.getColumnBitmask() &
490 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
491 Object[] args = new Object[] {
492 wikiNodeModelImpl.getOriginalUuid(),
493 Long.valueOf(wikiNodeModelImpl.getOriginalGroupId())
494 };
495
496 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
497 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
498
499 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
500 new Object[] {
501 wikiNode.getUuid(), Long.valueOf(wikiNode.getGroupId())
502 }, wikiNode);
503 }
504
505 if ((wikiNodeModelImpl.getColumnBitmask() &
506 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
507 Object[] args = new Object[] {
508 Long.valueOf(wikiNodeModelImpl.getOriginalGroupId()),
509
510 wikiNodeModelImpl.getOriginalName()
511 };
512
513 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
514 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
515
516 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
517 new Object[] {
518 Long.valueOf(wikiNode.getGroupId()),
519
520 wikiNode.getName()
521 }, wikiNode);
522 }
523 }
524
525 return wikiNode;
526 }
527
528 protected WikiNode toUnwrappedModel(WikiNode wikiNode) {
529 if (wikiNode instanceof WikiNodeImpl) {
530 return wikiNode;
531 }
532
533 WikiNodeImpl wikiNodeImpl = new WikiNodeImpl();
534
535 wikiNodeImpl.setNew(wikiNode.isNew());
536 wikiNodeImpl.setPrimaryKey(wikiNode.getPrimaryKey());
537
538 wikiNodeImpl.setUuid(wikiNode.getUuid());
539 wikiNodeImpl.setNodeId(wikiNode.getNodeId());
540 wikiNodeImpl.setGroupId(wikiNode.getGroupId());
541 wikiNodeImpl.setCompanyId(wikiNode.getCompanyId());
542 wikiNodeImpl.setUserId(wikiNode.getUserId());
543 wikiNodeImpl.setUserName(wikiNode.getUserName());
544 wikiNodeImpl.setCreateDate(wikiNode.getCreateDate());
545 wikiNodeImpl.setModifiedDate(wikiNode.getModifiedDate());
546 wikiNodeImpl.setName(wikiNode.getName());
547 wikiNodeImpl.setDescription(wikiNode.getDescription());
548 wikiNodeImpl.setLastPostDate(wikiNode.getLastPostDate());
549
550 return wikiNodeImpl;
551 }
552
553
561 @Override
562 public WikiNode findByPrimaryKey(Serializable primaryKey)
563 throws NoSuchModelException, SystemException {
564 return findByPrimaryKey(((Long)primaryKey).longValue());
565 }
566
567
575 public WikiNode findByPrimaryKey(long nodeId)
576 throws NoSuchNodeException, SystemException {
577 WikiNode wikiNode = fetchByPrimaryKey(nodeId);
578
579 if (wikiNode == null) {
580 if (_log.isWarnEnabled()) {
581 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + nodeId);
582 }
583
584 throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
585 nodeId);
586 }
587
588 return wikiNode;
589 }
590
591
598 @Override
599 public WikiNode fetchByPrimaryKey(Serializable primaryKey)
600 throws SystemException {
601 return fetchByPrimaryKey(((Long)primaryKey).longValue());
602 }
603
604
611 public WikiNode fetchByPrimaryKey(long nodeId) throws SystemException {
612 WikiNode wikiNode = (WikiNode)EntityCacheUtil.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
613 WikiNodeImpl.class, nodeId);
614
615 if (wikiNode == _nullWikiNode) {
616 return null;
617 }
618
619 if (wikiNode == null) {
620 Session session = null;
621
622 boolean hasException = false;
623
624 try {
625 session = openSession();
626
627 wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
628 Long.valueOf(nodeId));
629 }
630 catch (Exception e) {
631 hasException = true;
632
633 throw processException(e);
634 }
635 finally {
636 if (wikiNode != null) {
637 cacheResult(wikiNode);
638 }
639 else if (!hasException) {
640 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
641 WikiNodeImpl.class, nodeId, _nullWikiNode);
642 }
643
644 closeSession(session);
645 }
646 }
647
648 return wikiNode;
649 }
650
651
658 public List<WikiNode> findByUuid(String uuid) throws SystemException {
659 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
660 }
661
662
675 public List<WikiNode> findByUuid(String uuid, int start, int end)
676 throws SystemException {
677 return findByUuid(uuid, start, end, null);
678 }
679
680
694 public List<WikiNode> findByUuid(String uuid, int start, int end,
695 OrderByComparator orderByComparator) throws SystemException {
696 FinderPath finderPath = null;
697 Object[] finderArgs = null;
698
699 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
700 (orderByComparator == null)) {
701 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
702 finderArgs = new Object[] { uuid };
703 }
704 else {
705 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
706 finderArgs = new Object[] { uuid, start, end, orderByComparator };
707 }
708
709 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
710 finderArgs, this);
711
712 if (list == null) {
713 StringBundler query = null;
714
715 if (orderByComparator != null) {
716 query = new StringBundler(3 +
717 (orderByComparator.getOrderByFields().length * 3));
718 }
719 else {
720 query = new StringBundler(3);
721 }
722
723 query.append(_SQL_SELECT_WIKINODE_WHERE);
724
725 if (uuid == null) {
726 query.append(_FINDER_COLUMN_UUID_UUID_1);
727 }
728 else {
729 if (uuid.equals(StringPool.BLANK)) {
730 query.append(_FINDER_COLUMN_UUID_UUID_3);
731 }
732 else {
733 query.append(_FINDER_COLUMN_UUID_UUID_2);
734 }
735 }
736
737 if (orderByComparator != null) {
738 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
739 orderByComparator);
740 }
741
742 else {
743 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
744 }
745
746 String sql = query.toString();
747
748 Session session = null;
749
750 try {
751 session = openSession();
752
753 Query q = session.createQuery(sql);
754
755 QueryPos qPos = QueryPos.getInstance(q);
756
757 if (uuid != null) {
758 qPos.add(uuid);
759 }
760
761 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
762 end);
763 }
764 catch (Exception e) {
765 throw processException(e);
766 }
767 finally {
768 if (list == null) {
769 FinderCacheUtil.removeResult(finderPath, finderArgs);
770 }
771 else {
772 cacheResult(list);
773
774 FinderCacheUtil.putResult(finderPath, finderArgs, list);
775 }
776
777 closeSession(session);
778 }
779 }
780
781 return list;
782 }
783
784
797 public WikiNode findByUuid_First(String uuid,
798 OrderByComparator orderByComparator)
799 throws NoSuchNodeException, SystemException {
800 List<WikiNode> list = findByUuid(uuid, 0, 1, orderByComparator);
801
802 if (list.isEmpty()) {
803 StringBundler msg = new StringBundler(4);
804
805 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
806
807 msg.append("uuid=");
808 msg.append(uuid);
809
810 msg.append(StringPool.CLOSE_CURLY_BRACE);
811
812 throw new NoSuchNodeException(msg.toString());
813 }
814 else {
815 return list.get(0);
816 }
817 }
818
819
832 public WikiNode findByUuid_Last(String uuid,
833 OrderByComparator orderByComparator)
834 throws NoSuchNodeException, SystemException {
835 int count = countByUuid(uuid);
836
837 List<WikiNode> list = findByUuid(uuid, count - 1, count,
838 orderByComparator);
839
840 if (list.isEmpty()) {
841 StringBundler msg = new StringBundler(4);
842
843 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
844
845 msg.append("uuid=");
846 msg.append(uuid);
847
848 msg.append(StringPool.CLOSE_CURLY_BRACE);
849
850 throw new NoSuchNodeException(msg.toString());
851 }
852 else {
853 return list.get(0);
854 }
855 }
856
857
871 public WikiNode[] findByUuid_PrevAndNext(long nodeId, String uuid,
872 OrderByComparator orderByComparator)
873 throws NoSuchNodeException, SystemException {
874 WikiNode wikiNode = findByPrimaryKey(nodeId);
875
876 Session session = null;
877
878 try {
879 session = openSession();
880
881 WikiNode[] array = new WikiNodeImpl[3];
882
883 array[0] = getByUuid_PrevAndNext(session, wikiNode, uuid,
884 orderByComparator, true);
885
886 array[1] = wikiNode;
887
888 array[2] = getByUuid_PrevAndNext(session, wikiNode, uuid,
889 orderByComparator, false);
890
891 return array;
892 }
893 catch (Exception e) {
894 throw processException(e);
895 }
896 finally {
897 closeSession(session);
898 }
899 }
900
901 protected WikiNode getByUuid_PrevAndNext(Session session,
902 WikiNode wikiNode, String uuid, OrderByComparator orderByComparator,
903 boolean previous) {
904 StringBundler query = null;
905
906 if (orderByComparator != null) {
907 query = new StringBundler(6 +
908 (orderByComparator.getOrderByFields().length * 6));
909 }
910 else {
911 query = new StringBundler(3);
912 }
913
914 query.append(_SQL_SELECT_WIKINODE_WHERE);
915
916 if (uuid == null) {
917 query.append(_FINDER_COLUMN_UUID_UUID_1);
918 }
919 else {
920 if (uuid.equals(StringPool.BLANK)) {
921 query.append(_FINDER_COLUMN_UUID_UUID_3);
922 }
923 else {
924 query.append(_FINDER_COLUMN_UUID_UUID_2);
925 }
926 }
927
928 if (orderByComparator != null) {
929 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
930
931 if (orderByConditionFields.length > 0) {
932 query.append(WHERE_AND);
933 }
934
935 for (int i = 0; i < orderByConditionFields.length; i++) {
936 query.append(_ORDER_BY_ENTITY_ALIAS);
937 query.append(orderByConditionFields[i]);
938
939 if ((i + 1) < orderByConditionFields.length) {
940 if (orderByComparator.isAscending() ^ previous) {
941 query.append(WHERE_GREATER_THAN_HAS_NEXT);
942 }
943 else {
944 query.append(WHERE_LESSER_THAN_HAS_NEXT);
945 }
946 }
947 else {
948 if (orderByComparator.isAscending() ^ previous) {
949 query.append(WHERE_GREATER_THAN);
950 }
951 else {
952 query.append(WHERE_LESSER_THAN);
953 }
954 }
955 }
956
957 query.append(ORDER_BY_CLAUSE);
958
959 String[] orderByFields = orderByComparator.getOrderByFields();
960
961 for (int i = 0; i < orderByFields.length; i++) {
962 query.append(_ORDER_BY_ENTITY_ALIAS);
963 query.append(orderByFields[i]);
964
965 if ((i + 1) < orderByFields.length) {
966 if (orderByComparator.isAscending() ^ previous) {
967 query.append(ORDER_BY_ASC_HAS_NEXT);
968 }
969 else {
970 query.append(ORDER_BY_DESC_HAS_NEXT);
971 }
972 }
973 else {
974 if (orderByComparator.isAscending() ^ previous) {
975 query.append(ORDER_BY_ASC);
976 }
977 else {
978 query.append(ORDER_BY_DESC);
979 }
980 }
981 }
982 }
983
984 else {
985 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
986 }
987
988 String sql = query.toString();
989
990 Query q = session.createQuery(sql);
991
992 q.setFirstResult(0);
993 q.setMaxResults(2);
994
995 QueryPos qPos = QueryPos.getInstance(q);
996
997 if (uuid != null) {
998 qPos.add(uuid);
999 }
1000
1001 if (orderByComparator != null) {
1002 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1003
1004 for (Object value : values) {
1005 qPos.add(value);
1006 }
1007 }
1008
1009 List<WikiNode> list = q.list();
1010
1011 if (list.size() == 2) {
1012 return list.get(1);
1013 }
1014 else {
1015 return null;
1016 }
1017 }
1018
1019
1028 public WikiNode findByUUID_G(String uuid, long groupId)
1029 throws NoSuchNodeException, SystemException {
1030 WikiNode wikiNode = fetchByUUID_G(uuid, groupId);
1031
1032 if (wikiNode == null) {
1033 StringBundler msg = new StringBundler(6);
1034
1035 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1036
1037 msg.append("uuid=");
1038 msg.append(uuid);
1039
1040 msg.append(", groupId=");
1041 msg.append(groupId);
1042
1043 msg.append(StringPool.CLOSE_CURLY_BRACE);
1044
1045 if (_log.isWarnEnabled()) {
1046 _log.warn(msg.toString());
1047 }
1048
1049 throw new NoSuchNodeException(msg.toString());
1050 }
1051
1052 return wikiNode;
1053 }
1054
1055
1063 public WikiNode fetchByUUID_G(String uuid, long groupId)
1064 throws SystemException {
1065 return fetchByUUID_G(uuid, groupId, true);
1066 }
1067
1068
1077 public WikiNode fetchByUUID_G(String uuid, long groupId,
1078 boolean retrieveFromCache) throws SystemException {
1079 Object[] finderArgs = new Object[] { uuid, groupId };
1080
1081 Object result = null;
1082
1083 if (retrieveFromCache) {
1084 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1085 finderArgs, this);
1086 }
1087
1088 if (result == null) {
1089 StringBundler query = new StringBundler(4);
1090
1091 query.append(_SQL_SELECT_WIKINODE_WHERE);
1092
1093 if (uuid == null) {
1094 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1095 }
1096 else {
1097 if (uuid.equals(StringPool.BLANK)) {
1098 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1099 }
1100 else {
1101 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1102 }
1103 }
1104
1105 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1106
1107 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1108
1109 String sql = query.toString();
1110
1111 Session session = null;
1112
1113 try {
1114 session = openSession();
1115
1116 Query q = session.createQuery(sql);
1117
1118 QueryPos qPos = QueryPos.getInstance(q);
1119
1120 if (uuid != null) {
1121 qPos.add(uuid);
1122 }
1123
1124 qPos.add(groupId);
1125
1126 List<WikiNode> list = q.list();
1127
1128 result = list;
1129
1130 WikiNode wikiNode = null;
1131
1132 if (list.isEmpty()) {
1133 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1134 finderArgs, list);
1135 }
1136 else {
1137 wikiNode = list.get(0);
1138
1139 cacheResult(wikiNode);
1140
1141 if ((wikiNode.getUuid() == null) ||
1142 !wikiNode.getUuid().equals(uuid) ||
1143 (wikiNode.getGroupId() != groupId)) {
1144 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1145 finderArgs, wikiNode);
1146 }
1147 }
1148
1149 return wikiNode;
1150 }
1151 catch (Exception e) {
1152 throw processException(e);
1153 }
1154 finally {
1155 if (result == null) {
1156 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1157 finderArgs);
1158 }
1159
1160 closeSession(session);
1161 }
1162 }
1163 else {
1164 if (result instanceof List<?>) {
1165 return null;
1166 }
1167 else {
1168 return (WikiNode)result;
1169 }
1170 }
1171 }
1172
1173
1180 public List<WikiNode> findByGroupId(long groupId) throws SystemException {
1181 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1182 }
1183
1184
1197 public List<WikiNode> findByGroupId(long groupId, int start, int end)
1198 throws SystemException {
1199 return findByGroupId(groupId, start, end, null);
1200 }
1201
1202
1216 public List<WikiNode> findByGroupId(long groupId, int start, int end,
1217 OrderByComparator orderByComparator) throws SystemException {
1218 FinderPath finderPath = null;
1219 Object[] finderArgs = null;
1220
1221 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1222 (orderByComparator == null)) {
1223 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1224 finderArgs = new Object[] { groupId };
1225 }
1226 else {
1227 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1228 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1229 }
1230
1231 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
1232 finderArgs, this);
1233
1234 if (list == null) {
1235 StringBundler query = null;
1236
1237 if (orderByComparator != null) {
1238 query = new StringBundler(3 +
1239 (orderByComparator.getOrderByFields().length * 3));
1240 }
1241 else {
1242 query = new StringBundler(3);
1243 }
1244
1245 query.append(_SQL_SELECT_WIKINODE_WHERE);
1246
1247 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1248
1249 if (orderByComparator != null) {
1250 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1251 orderByComparator);
1252 }
1253
1254 else {
1255 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1256 }
1257
1258 String sql = query.toString();
1259
1260 Session session = null;
1261
1262 try {
1263 session = openSession();
1264
1265 Query q = session.createQuery(sql);
1266
1267 QueryPos qPos = QueryPos.getInstance(q);
1268
1269 qPos.add(groupId);
1270
1271 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
1272 end);
1273 }
1274 catch (Exception e) {
1275 throw processException(e);
1276 }
1277 finally {
1278 if (list == null) {
1279 FinderCacheUtil.removeResult(finderPath, finderArgs);
1280 }
1281 else {
1282 cacheResult(list);
1283
1284 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1285 }
1286
1287 closeSession(session);
1288 }
1289 }
1290
1291 return list;
1292 }
1293
1294
1307 public WikiNode findByGroupId_First(long groupId,
1308 OrderByComparator orderByComparator)
1309 throws NoSuchNodeException, SystemException {
1310 List<WikiNode> list = findByGroupId(groupId, 0, 1, orderByComparator);
1311
1312 if (list.isEmpty()) {
1313 StringBundler msg = new StringBundler(4);
1314
1315 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1316
1317 msg.append("groupId=");
1318 msg.append(groupId);
1319
1320 msg.append(StringPool.CLOSE_CURLY_BRACE);
1321
1322 throw new NoSuchNodeException(msg.toString());
1323 }
1324 else {
1325 return list.get(0);
1326 }
1327 }
1328
1329
1342 public WikiNode findByGroupId_Last(long groupId,
1343 OrderByComparator orderByComparator)
1344 throws NoSuchNodeException, SystemException {
1345 int count = countByGroupId(groupId);
1346
1347 List<WikiNode> list = findByGroupId(groupId, count - 1, count,
1348 orderByComparator);
1349
1350 if (list.isEmpty()) {
1351 StringBundler msg = new StringBundler(4);
1352
1353 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1354
1355 msg.append("groupId=");
1356 msg.append(groupId);
1357
1358 msg.append(StringPool.CLOSE_CURLY_BRACE);
1359
1360 throw new NoSuchNodeException(msg.toString());
1361 }
1362 else {
1363 return list.get(0);
1364 }
1365 }
1366
1367
1381 public WikiNode[] findByGroupId_PrevAndNext(long nodeId, long groupId,
1382 OrderByComparator orderByComparator)
1383 throws NoSuchNodeException, SystemException {
1384 WikiNode wikiNode = findByPrimaryKey(nodeId);
1385
1386 Session session = null;
1387
1388 try {
1389 session = openSession();
1390
1391 WikiNode[] array = new WikiNodeImpl[3];
1392
1393 array[0] = getByGroupId_PrevAndNext(session, wikiNode, groupId,
1394 orderByComparator, true);
1395
1396 array[1] = wikiNode;
1397
1398 array[2] = getByGroupId_PrevAndNext(session, wikiNode, groupId,
1399 orderByComparator, false);
1400
1401 return array;
1402 }
1403 catch (Exception e) {
1404 throw processException(e);
1405 }
1406 finally {
1407 closeSession(session);
1408 }
1409 }
1410
1411 protected WikiNode getByGroupId_PrevAndNext(Session session,
1412 WikiNode wikiNode, long groupId, OrderByComparator orderByComparator,
1413 boolean previous) {
1414 StringBundler query = null;
1415
1416 if (orderByComparator != null) {
1417 query = new StringBundler(6 +
1418 (orderByComparator.getOrderByFields().length * 6));
1419 }
1420 else {
1421 query = new StringBundler(3);
1422 }
1423
1424 query.append(_SQL_SELECT_WIKINODE_WHERE);
1425
1426 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1427
1428 if (orderByComparator != null) {
1429 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1430
1431 if (orderByConditionFields.length > 0) {
1432 query.append(WHERE_AND);
1433 }
1434
1435 for (int i = 0; i < orderByConditionFields.length; i++) {
1436 query.append(_ORDER_BY_ENTITY_ALIAS);
1437 query.append(orderByConditionFields[i]);
1438
1439 if ((i + 1) < orderByConditionFields.length) {
1440 if (orderByComparator.isAscending() ^ previous) {
1441 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1442 }
1443 else {
1444 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1445 }
1446 }
1447 else {
1448 if (orderByComparator.isAscending() ^ previous) {
1449 query.append(WHERE_GREATER_THAN);
1450 }
1451 else {
1452 query.append(WHERE_LESSER_THAN);
1453 }
1454 }
1455 }
1456
1457 query.append(ORDER_BY_CLAUSE);
1458
1459 String[] orderByFields = orderByComparator.getOrderByFields();
1460
1461 for (int i = 0; i < orderByFields.length; i++) {
1462 query.append(_ORDER_BY_ENTITY_ALIAS);
1463 query.append(orderByFields[i]);
1464
1465 if ((i + 1) < orderByFields.length) {
1466 if (orderByComparator.isAscending() ^ previous) {
1467 query.append(ORDER_BY_ASC_HAS_NEXT);
1468 }
1469 else {
1470 query.append(ORDER_BY_DESC_HAS_NEXT);
1471 }
1472 }
1473 else {
1474 if (orderByComparator.isAscending() ^ previous) {
1475 query.append(ORDER_BY_ASC);
1476 }
1477 else {
1478 query.append(ORDER_BY_DESC);
1479 }
1480 }
1481 }
1482 }
1483
1484 else {
1485 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1486 }
1487
1488 String sql = query.toString();
1489
1490 Query q = session.createQuery(sql);
1491
1492 q.setFirstResult(0);
1493 q.setMaxResults(2);
1494
1495 QueryPos qPos = QueryPos.getInstance(q);
1496
1497 qPos.add(groupId);
1498
1499 if (orderByComparator != null) {
1500 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1501
1502 for (Object value : values) {
1503 qPos.add(value);
1504 }
1505 }
1506
1507 List<WikiNode> list = q.list();
1508
1509 if (list.size() == 2) {
1510 return list.get(1);
1511 }
1512 else {
1513 return null;
1514 }
1515 }
1516
1517
1524 public List<WikiNode> filterFindByGroupId(long groupId)
1525 throws SystemException {
1526 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1527 QueryUtil.ALL_POS, null);
1528 }
1529
1530
1543 public List<WikiNode> filterFindByGroupId(long groupId, int start, int end)
1544 throws SystemException {
1545 return filterFindByGroupId(groupId, start, end, null);
1546 }
1547
1548
1562 public List<WikiNode> filterFindByGroupId(long groupId, int start, int end,
1563 OrderByComparator orderByComparator) throws SystemException {
1564 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1565 return findByGroupId(groupId, start, end, orderByComparator);
1566 }
1567
1568 StringBundler query = null;
1569
1570 if (orderByComparator != null) {
1571 query = new StringBundler(3 +
1572 (orderByComparator.getOrderByFields().length * 3));
1573 }
1574 else {
1575 query = new StringBundler(3);
1576 }
1577
1578 if (getDB().isSupportsInlineDistinct()) {
1579 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
1580 }
1581 else {
1582 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
1583 }
1584
1585 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1586
1587 if (!getDB().isSupportsInlineDistinct()) {
1588 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
1589 }
1590
1591 if (orderByComparator != null) {
1592 if (getDB().isSupportsInlineDistinct()) {
1593 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1594 orderByComparator);
1595 }
1596 else {
1597 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1598 orderByComparator);
1599 }
1600 }
1601
1602 else {
1603 if (getDB().isSupportsInlineDistinct()) {
1604 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1605 }
1606 else {
1607 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
1608 }
1609 }
1610
1611 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1612 WikiNode.class.getName(),
1613 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1614
1615 Session session = null;
1616
1617 try {
1618 session = openSession();
1619
1620 SQLQuery q = session.createSQLQuery(sql);
1621
1622 if (getDB().isSupportsInlineDistinct()) {
1623 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
1624 }
1625 else {
1626 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
1627 }
1628
1629 QueryPos qPos = QueryPos.getInstance(q);
1630
1631 qPos.add(groupId);
1632
1633 return (List<WikiNode>)QueryUtil.list(q, getDialect(), start, end);
1634 }
1635 catch (Exception e) {
1636 throw processException(e);
1637 }
1638 finally {
1639 closeSession(session);
1640 }
1641 }
1642
1643
1653 public WikiNode[] filterFindByGroupId_PrevAndNext(long nodeId,
1654 long groupId, OrderByComparator orderByComparator)
1655 throws NoSuchNodeException, SystemException {
1656 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1657 return findByGroupId_PrevAndNext(nodeId, groupId, orderByComparator);
1658 }
1659
1660 WikiNode wikiNode = findByPrimaryKey(nodeId);
1661
1662 Session session = null;
1663
1664 try {
1665 session = openSession();
1666
1667 WikiNode[] array = new WikiNodeImpl[3];
1668
1669 array[0] = filterGetByGroupId_PrevAndNext(session, wikiNode,
1670 groupId, orderByComparator, true);
1671
1672 array[1] = wikiNode;
1673
1674 array[2] = filterGetByGroupId_PrevAndNext(session, wikiNode,
1675 groupId, orderByComparator, false);
1676
1677 return array;
1678 }
1679 catch (Exception e) {
1680 throw processException(e);
1681 }
1682 finally {
1683 closeSession(session);
1684 }
1685 }
1686
1687 protected WikiNode filterGetByGroupId_PrevAndNext(Session session,
1688 WikiNode wikiNode, long groupId, OrderByComparator orderByComparator,
1689 boolean previous) {
1690 StringBundler query = null;
1691
1692 if (orderByComparator != null) {
1693 query = new StringBundler(6 +
1694 (orderByComparator.getOrderByFields().length * 6));
1695 }
1696 else {
1697 query = new StringBundler(3);
1698 }
1699
1700 if (getDB().isSupportsInlineDistinct()) {
1701 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
1702 }
1703 else {
1704 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
1705 }
1706
1707 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1708
1709 if (!getDB().isSupportsInlineDistinct()) {
1710 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
1711 }
1712
1713 if (orderByComparator != null) {
1714 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1715
1716 if (orderByConditionFields.length > 0) {
1717 query.append(WHERE_AND);
1718 }
1719
1720 for (int i = 0; i < orderByConditionFields.length; i++) {
1721 if (getDB().isSupportsInlineDistinct()) {
1722 query.append(_ORDER_BY_ENTITY_ALIAS);
1723 }
1724 else {
1725 query.append(_ORDER_BY_ENTITY_TABLE);
1726 }
1727
1728 query.append(orderByConditionFields[i]);
1729
1730 if ((i + 1) < orderByConditionFields.length) {
1731 if (orderByComparator.isAscending() ^ previous) {
1732 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1733 }
1734 else {
1735 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1736 }
1737 }
1738 else {
1739 if (orderByComparator.isAscending() ^ previous) {
1740 query.append(WHERE_GREATER_THAN);
1741 }
1742 else {
1743 query.append(WHERE_LESSER_THAN);
1744 }
1745 }
1746 }
1747
1748 query.append(ORDER_BY_CLAUSE);
1749
1750 String[] orderByFields = orderByComparator.getOrderByFields();
1751
1752 for (int i = 0; i < orderByFields.length; i++) {
1753 if (getDB().isSupportsInlineDistinct()) {
1754 query.append(_ORDER_BY_ENTITY_ALIAS);
1755 }
1756 else {
1757 query.append(_ORDER_BY_ENTITY_TABLE);
1758 }
1759
1760 query.append(orderByFields[i]);
1761
1762 if ((i + 1) < orderByFields.length) {
1763 if (orderByComparator.isAscending() ^ previous) {
1764 query.append(ORDER_BY_ASC_HAS_NEXT);
1765 }
1766 else {
1767 query.append(ORDER_BY_DESC_HAS_NEXT);
1768 }
1769 }
1770 else {
1771 if (orderByComparator.isAscending() ^ previous) {
1772 query.append(ORDER_BY_ASC);
1773 }
1774 else {
1775 query.append(ORDER_BY_DESC);
1776 }
1777 }
1778 }
1779 }
1780
1781 else {
1782 if (getDB().isSupportsInlineDistinct()) {
1783 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1784 }
1785 else {
1786 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
1787 }
1788 }
1789
1790 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1791 WikiNode.class.getName(),
1792 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1793
1794 SQLQuery q = session.createSQLQuery(sql);
1795
1796 q.setFirstResult(0);
1797 q.setMaxResults(2);
1798
1799 if (getDB().isSupportsInlineDistinct()) {
1800 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
1801 }
1802 else {
1803 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
1804 }
1805
1806 QueryPos qPos = QueryPos.getInstance(q);
1807
1808 qPos.add(groupId);
1809
1810 if (orderByComparator != null) {
1811 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1812
1813 for (Object value : values) {
1814 qPos.add(value);
1815 }
1816 }
1817
1818 List<WikiNode> list = q.list();
1819
1820 if (list.size() == 2) {
1821 return list.get(1);
1822 }
1823 else {
1824 return null;
1825 }
1826 }
1827
1828
1835 public List<WikiNode> findByCompanyId(long companyId)
1836 throws SystemException {
1837 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1838 null);
1839 }
1840
1841
1854 public List<WikiNode> findByCompanyId(long companyId, int start, int end)
1855 throws SystemException {
1856 return findByCompanyId(companyId, start, end, null);
1857 }
1858
1859
1873 public List<WikiNode> findByCompanyId(long companyId, int start, int end,
1874 OrderByComparator orderByComparator) throws SystemException {
1875 FinderPath finderPath = null;
1876 Object[] finderArgs = null;
1877
1878 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1879 (orderByComparator == null)) {
1880 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1881 finderArgs = new Object[] { companyId };
1882 }
1883 else {
1884 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1885 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1886 }
1887
1888 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
1889 finderArgs, this);
1890
1891 if (list == null) {
1892 StringBundler query = null;
1893
1894 if (orderByComparator != null) {
1895 query = new StringBundler(3 +
1896 (orderByComparator.getOrderByFields().length * 3));
1897 }
1898 else {
1899 query = new StringBundler(3);
1900 }
1901
1902 query.append(_SQL_SELECT_WIKINODE_WHERE);
1903
1904 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1905
1906 if (orderByComparator != null) {
1907 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1908 orderByComparator);
1909 }
1910
1911 else {
1912 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1913 }
1914
1915 String sql = query.toString();
1916
1917 Session session = null;
1918
1919 try {
1920 session = openSession();
1921
1922 Query q = session.createQuery(sql);
1923
1924 QueryPos qPos = QueryPos.getInstance(q);
1925
1926 qPos.add(companyId);
1927
1928 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
1929 end);
1930 }
1931 catch (Exception e) {
1932 throw processException(e);
1933 }
1934 finally {
1935 if (list == null) {
1936 FinderCacheUtil.removeResult(finderPath, finderArgs);
1937 }
1938 else {
1939 cacheResult(list);
1940
1941 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1942 }
1943
1944 closeSession(session);
1945 }
1946 }
1947
1948 return list;
1949 }
1950
1951
1964 public WikiNode findByCompanyId_First(long companyId,
1965 OrderByComparator orderByComparator)
1966 throws NoSuchNodeException, SystemException {
1967 List<WikiNode> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1968
1969 if (list.isEmpty()) {
1970 StringBundler msg = new StringBundler(4);
1971
1972 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1973
1974 msg.append("companyId=");
1975 msg.append(companyId);
1976
1977 msg.append(StringPool.CLOSE_CURLY_BRACE);
1978
1979 throw new NoSuchNodeException(msg.toString());
1980 }
1981 else {
1982 return list.get(0);
1983 }
1984 }
1985
1986
1999 public WikiNode findByCompanyId_Last(long companyId,
2000 OrderByComparator orderByComparator)
2001 throws NoSuchNodeException, SystemException {
2002 int count = countByCompanyId(companyId);
2003
2004 List<WikiNode> list = findByCompanyId(companyId, count - 1, count,
2005 orderByComparator);
2006
2007 if (list.isEmpty()) {
2008 StringBundler msg = new StringBundler(4);
2009
2010 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2011
2012 msg.append("companyId=");
2013 msg.append(companyId);
2014
2015 msg.append(StringPool.CLOSE_CURLY_BRACE);
2016
2017 throw new NoSuchNodeException(msg.toString());
2018 }
2019 else {
2020 return list.get(0);
2021 }
2022 }
2023
2024
2038 public WikiNode[] findByCompanyId_PrevAndNext(long nodeId, long companyId,
2039 OrderByComparator orderByComparator)
2040 throws NoSuchNodeException, SystemException {
2041 WikiNode wikiNode = findByPrimaryKey(nodeId);
2042
2043 Session session = null;
2044
2045 try {
2046 session = openSession();
2047
2048 WikiNode[] array = new WikiNodeImpl[3];
2049
2050 array[0] = getByCompanyId_PrevAndNext(session, wikiNode, companyId,
2051 orderByComparator, true);
2052
2053 array[1] = wikiNode;
2054
2055 array[2] = getByCompanyId_PrevAndNext(session, wikiNode, companyId,
2056 orderByComparator, false);
2057
2058 return array;
2059 }
2060 catch (Exception e) {
2061 throw processException(e);
2062 }
2063 finally {
2064 closeSession(session);
2065 }
2066 }
2067
2068 protected WikiNode getByCompanyId_PrevAndNext(Session session,
2069 WikiNode wikiNode, long companyId, OrderByComparator orderByComparator,
2070 boolean previous) {
2071 StringBundler query = null;
2072
2073 if (orderByComparator != null) {
2074 query = new StringBundler(6 +
2075 (orderByComparator.getOrderByFields().length * 6));
2076 }
2077 else {
2078 query = new StringBundler(3);
2079 }
2080
2081 query.append(_SQL_SELECT_WIKINODE_WHERE);
2082
2083 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2084
2085 if (orderByComparator != null) {
2086 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2087
2088 if (orderByConditionFields.length > 0) {
2089 query.append(WHERE_AND);
2090 }
2091
2092 for (int i = 0; i < orderByConditionFields.length; i++) {
2093 query.append(_ORDER_BY_ENTITY_ALIAS);
2094 query.append(orderByConditionFields[i]);
2095
2096 if ((i + 1) < orderByConditionFields.length) {
2097 if (orderByComparator.isAscending() ^ previous) {
2098 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2099 }
2100 else {
2101 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2102 }
2103 }
2104 else {
2105 if (orderByComparator.isAscending() ^ previous) {
2106 query.append(WHERE_GREATER_THAN);
2107 }
2108 else {
2109 query.append(WHERE_LESSER_THAN);
2110 }
2111 }
2112 }
2113
2114 query.append(ORDER_BY_CLAUSE);
2115
2116 String[] orderByFields = orderByComparator.getOrderByFields();
2117
2118 for (int i = 0; i < orderByFields.length; i++) {
2119 query.append(_ORDER_BY_ENTITY_ALIAS);
2120 query.append(orderByFields[i]);
2121
2122 if ((i + 1) < orderByFields.length) {
2123 if (orderByComparator.isAscending() ^ previous) {
2124 query.append(ORDER_BY_ASC_HAS_NEXT);
2125 }
2126 else {
2127 query.append(ORDER_BY_DESC_HAS_NEXT);
2128 }
2129 }
2130 else {
2131 if (orderByComparator.isAscending() ^ previous) {
2132 query.append(ORDER_BY_ASC);
2133 }
2134 else {
2135 query.append(ORDER_BY_DESC);
2136 }
2137 }
2138 }
2139 }
2140
2141 else {
2142 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2143 }
2144
2145 String sql = query.toString();
2146
2147 Query q = session.createQuery(sql);
2148
2149 q.setFirstResult(0);
2150 q.setMaxResults(2);
2151
2152 QueryPos qPos = QueryPos.getInstance(q);
2153
2154 qPos.add(companyId);
2155
2156 if (orderByComparator != null) {
2157 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
2158
2159 for (Object value : values) {
2160 qPos.add(value);
2161 }
2162 }
2163
2164 List<WikiNode> list = q.list();
2165
2166 if (list.size() == 2) {
2167 return list.get(1);
2168 }
2169 else {
2170 return null;
2171 }
2172 }
2173
2174
2183 public WikiNode findByG_N(long groupId, String name)
2184 throws NoSuchNodeException, SystemException {
2185 WikiNode wikiNode = fetchByG_N(groupId, name);
2186
2187 if (wikiNode == null) {
2188 StringBundler msg = new StringBundler(6);
2189
2190 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2191
2192 msg.append("groupId=");
2193 msg.append(groupId);
2194
2195 msg.append(", name=");
2196 msg.append(name);
2197
2198 msg.append(StringPool.CLOSE_CURLY_BRACE);
2199
2200 if (_log.isWarnEnabled()) {
2201 _log.warn(msg.toString());
2202 }
2203
2204 throw new NoSuchNodeException(msg.toString());
2205 }
2206
2207 return wikiNode;
2208 }
2209
2210
2218 public WikiNode fetchByG_N(long groupId, String name)
2219 throws SystemException {
2220 return fetchByG_N(groupId, name, true);
2221 }
2222
2223
2232 public WikiNode fetchByG_N(long groupId, String name,
2233 boolean retrieveFromCache) throws SystemException {
2234 Object[] finderArgs = new Object[] { groupId, name };
2235
2236 Object result = null;
2237
2238 if (retrieveFromCache) {
2239 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2240 finderArgs, this);
2241 }
2242
2243 if (result == null) {
2244 StringBundler query = new StringBundler(4);
2245
2246 query.append(_SQL_SELECT_WIKINODE_WHERE);
2247
2248 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2249
2250 if (name == null) {
2251 query.append(_FINDER_COLUMN_G_N_NAME_1);
2252 }
2253 else {
2254 if (name.equals(StringPool.BLANK)) {
2255 query.append(_FINDER_COLUMN_G_N_NAME_3);
2256 }
2257 else {
2258 query.append(_FINDER_COLUMN_G_N_NAME_2);
2259 }
2260 }
2261
2262 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2263
2264 String sql = query.toString();
2265
2266 Session session = null;
2267
2268 try {
2269 session = openSession();
2270
2271 Query q = session.createQuery(sql);
2272
2273 QueryPos qPos = QueryPos.getInstance(q);
2274
2275 qPos.add(groupId);
2276
2277 if (name != null) {
2278 qPos.add(name);
2279 }
2280
2281 List<WikiNode> list = q.list();
2282
2283 result = list;
2284
2285 WikiNode wikiNode = null;
2286
2287 if (list.isEmpty()) {
2288 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2289 finderArgs, list);
2290 }
2291 else {
2292 wikiNode = list.get(0);
2293
2294 cacheResult(wikiNode);
2295
2296 if ((wikiNode.getGroupId() != groupId) ||
2297 (wikiNode.getName() == null) ||
2298 !wikiNode.getName().equals(name)) {
2299 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2300 finderArgs, wikiNode);
2301 }
2302 }
2303
2304 return wikiNode;
2305 }
2306 catch (Exception e) {
2307 throw processException(e);
2308 }
2309 finally {
2310 if (result == null) {
2311 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2312 finderArgs);
2313 }
2314
2315 closeSession(session);
2316 }
2317 }
2318 else {
2319 if (result instanceof List<?>) {
2320 return null;
2321 }
2322 else {
2323 return (WikiNode)result;
2324 }
2325 }
2326 }
2327
2328
2334 public List<WikiNode> findAll() throws SystemException {
2335 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2336 }
2337
2338
2350 public List<WikiNode> findAll(int start, int end) throws SystemException {
2351 return findAll(start, end, null);
2352 }
2353
2354
2367 public List<WikiNode> findAll(int start, int end,
2368 OrderByComparator orderByComparator) throws SystemException {
2369 FinderPath finderPath = null;
2370 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2371
2372 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2373 (orderByComparator == null)) {
2374 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2375 finderArgs = FINDER_ARGS_EMPTY;
2376 }
2377 else {
2378 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2379 finderArgs = new Object[] { start, end, orderByComparator };
2380 }
2381
2382 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
2383 finderArgs, this);
2384
2385 if (list == null) {
2386 StringBundler query = null;
2387 String sql = null;
2388
2389 if (orderByComparator != null) {
2390 query = new StringBundler(2 +
2391 (orderByComparator.getOrderByFields().length * 3));
2392
2393 query.append(_SQL_SELECT_WIKINODE);
2394
2395 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2396 orderByComparator);
2397
2398 sql = query.toString();
2399 }
2400 else {
2401 sql = _SQL_SELECT_WIKINODE.concat(WikiNodeModelImpl.ORDER_BY_JPQL);
2402 }
2403
2404 Session session = null;
2405
2406 try {
2407 session = openSession();
2408
2409 Query q = session.createQuery(sql);
2410
2411 if (orderByComparator == null) {
2412 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
2413 start, end, false);
2414
2415 Collections.sort(list);
2416 }
2417 else {
2418 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
2419 start, end);
2420 }
2421 }
2422 catch (Exception e) {
2423 throw processException(e);
2424 }
2425 finally {
2426 if (list == null) {
2427 FinderCacheUtil.removeResult(finderPath, finderArgs);
2428 }
2429 else {
2430 cacheResult(list);
2431
2432 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2433 }
2434
2435 closeSession(session);
2436 }
2437 }
2438
2439 return list;
2440 }
2441
2442
2448 public void removeByUuid(String uuid) throws SystemException {
2449 for (WikiNode wikiNode : findByUuid(uuid)) {
2450 wikiNodePersistence.remove(wikiNode);
2451 }
2452 }
2453
2454
2461 public void removeByUUID_G(String uuid, long groupId)
2462 throws NoSuchNodeException, SystemException {
2463 WikiNode wikiNode = findByUUID_G(uuid, groupId);
2464
2465 wikiNodePersistence.remove(wikiNode);
2466 }
2467
2468
2474 public void removeByGroupId(long groupId) throws SystemException {
2475 for (WikiNode wikiNode : findByGroupId(groupId)) {
2476 wikiNodePersistence.remove(wikiNode);
2477 }
2478 }
2479
2480
2486 public void removeByCompanyId(long companyId) throws SystemException {
2487 for (WikiNode wikiNode : findByCompanyId(companyId)) {
2488 wikiNodePersistence.remove(wikiNode);
2489 }
2490 }
2491
2492
2499 public void removeByG_N(long groupId, String name)
2500 throws NoSuchNodeException, SystemException {
2501 WikiNode wikiNode = findByG_N(groupId, name);
2502
2503 wikiNodePersistence.remove(wikiNode);
2504 }
2505
2506
2511 public void removeAll() throws SystemException {
2512 for (WikiNode wikiNode : findAll()) {
2513 wikiNodePersistence.remove(wikiNode);
2514 }
2515 }
2516
2517
2524 public int countByUuid(String uuid) throws SystemException {
2525 Object[] finderArgs = new Object[] { uuid };
2526
2527 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2528 finderArgs, this);
2529
2530 if (count == null) {
2531 StringBundler query = new StringBundler(2);
2532
2533 query.append(_SQL_COUNT_WIKINODE_WHERE);
2534
2535 if (uuid == null) {
2536 query.append(_FINDER_COLUMN_UUID_UUID_1);
2537 }
2538 else {
2539 if (uuid.equals(StringPool.BLANK)) {
2540 query.append(_FINDER_COLUMN_UUID_UUID_3);
2541 }
2542 else {
2543 query.append(_FINDER_COLUMN_UUID_UUID_2);
2544 }
2545 }
2546
2547 String sql = query.toString();
2548
2549 Session session = null;
2550
2551 try {
2552 session = openSession();
2553
2554 Query q = session.createQuery(sql);
2555
2556 QueryPos qPos = QueryPos.getInstance(q);
2557
2558 if (uuid != null) {
2559 qPos.add(uuid);
2560 }
2561
2562 count = (Long)q.uniqueResult();
2563 }
2564 catch (Exception e) {
2565 throw processException(e);
2566 }
2567 finally {
2568 if (count == null) {
2569 count = Long.valueOf(0);
2570 }
2571
2572 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2573 finderArgs, count);
2574
2575 closeSession(session);
2576 }
2577 }
2578
2579 return count.intValue();
2580 }
2581
2582
2590 public int countByUUID_G(String uuid, long groupId)
2591 throws SystemException {
2592 Object[] finderArgs = new Object[] { uuid, groupId };
2593
2594 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2595 finderArgs, this);
2596
2597 if (count == null) {
2598 StringBundler query = new StringBundler(3);
2599
2600 query.append(_SQL_COUNT_WIKINODE_WHERE);
2601
2602 if (uuid == null) {
2603 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2604 }
2605 else {
2606 if (uuid.equals(StringPool.BLANK)) {
2607 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2608 }
2609 else {
2610 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2611 }
2612 }
2613
2614 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2615
2616 String sql = query.toString();
2617
2618 Session session = null;
2619
2620 try {
2621 session = openSession();
2622
2623 Query q = session.createQuery(sql);
2624
2625 QueryPos qPos = QueryPos.getInstance(q);
2626
2627 if (uuid != null) {
2628 qPos.add(uuid);
2629 }
2630
2631 qPos.add(groupId);
2632
2633 count = (Long)q.uniqueResult();
2634 }
2635 catch (Exception e) {
2636 throw processException(e);
2637 }
2638 finally {
2639 if (count == null) {
2640 count = Long.valueOf(0);
2641 }
2642
2643 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2644 finderArgs, count);
2645
2646 closeSession(session);
2647 }
2648 }
2649
2650 return count.intValue();
2651 }
2652
2653
2660 public int countByGroupId(long groupId) throws SystemException {
2661 Object[] finderArgs = new Object[] { groupId };
2662
2663 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2664 finderArgs, this);
2665
2666 if (count == null) {
2667 StringBundler query = new StringBundler(2);
2668
2669 query.append(_SQL_COUNT_WIKINODE_WHERE);
2670
2671 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2672
2673 String sql = query.toString();
2674
2675 Session session = null;
2676
2677 try {
2678 session = openSession();
2679
2680 Query q = session.createQuery(sql);
2681
2682 QueryPos qPos = QueryPos.getInstance(q);
2683
2684 qPos.add(groupId);
2685
2686 count = (Long)q.uniqueResult();
2687 }
2688 catch (Exception e) {
2689 throw processException(e);
2690 }
2691 finally {
2692 if (count == null) {
2693 count = Long.valueOf(0);
2694 }
2695
2696 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2697 finderArgs, count);
2698
2699 closeSession(session);
2700 }
2701 }
2702
2703 return count.intValue();
2704 }
2705
2706
2713 public int filterCountByGroupId(long groupId) throws SystemException {
2714 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2715 return countByGroupId(groupId);
2716 }
2717
2718 StringBundler query = new StringBundler(2);
2719
2720 query.append(_FILTER_SQL_COUNT_WIKINODE_WHERE);
2721
2722 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2723
2724 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2725 WikiNode.class.getName(),
2726 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2727
2728 Session session = null;
2729
2730 try {
2731 session = openSession();
2732
2733 SQLQuery q = session.createSQLQuery(sql);
2734
2735 q.addScalar(COUNT_COLUMN_NAME,
2736 com.liferay.portal.kernel.dao.orm.Type.LONG);
2737
2738 QueryPos qPos = QueryPos.getInstance(q);
2739
2740 qPos.add(groupId);
2741
2742 Long count = (Long)q.uniqueResult();
2743
2744 return count.intValue();
2745 }
2746 catch (Exception e) {
2747 throw processException(e);
2748 }
2749 finally {
2750 closeSession(session);
2751 }
2752 }
2753
2754
2761 public int countByCompanyId(long companyId) throws SystemException {
2762 Object[] finderArgs = new Object[] { companyId };
2763
2764 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2765 finderArgs, this);
2766
2767 if (count == null) {
2768 StringBundler query = new StringBundler(2);
2769
2770 query.append(_SQL_COUNT_WIKINODE_WHERE);
2771
2772 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2773
2774 String sql = query.toString();
2775
2776 Session session = null;
2777
2778 try {
2779 session = openSession();
2780
2781 Query q = session.createQuery(sql);
2782
2783 QueryPos qPos = QueryPos.getInstance(q);
2784
2785 qPos.add(companyId);
2786
2787 count = (Long)q.uniqueResult();
2788 }
2789 catch (Exception e) {
2790 throw processException(e);
2791 }
2792 finally {
2793 if (count == null) {
2794 count = Long.valueOf(0);
2795 }
2796
2797 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2798 finderArgs, count);
2799
2800 closeSession(session);
2801 }
2802 }
2803
2804 return count.intValue();
2805 }
2806
2807
2815 public int countByG_N(long groupId, String name) throws SystemException {
2816 Object[] finderArgs = new Object[] { groupId, name };
2817
2818 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
2819 finderArgs, this);
2820
2821 if (count == null) {
2822 StringBundler query = new StringBundler(3);
2823
2824 query.append(_SQL_COUNT_WIKINODE_WHERE);
2825
2826 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2827
2828 if (name == null) {
2829 query.append(_FINDER_COLUMN_G_N_NAME_1);
2830 }
2831 else {
2832 if (name.equals(StringPool.BLANK)) {
2833 query.append(_FINDER_COLUMN_G_N_NAME_3);
2834 }
2835 else {
2836 query.append(_FINDER_COLUMN_G_N_NAME_2);
2837 }
2838 }
2839
2840 String sql = query.toString();
2841
2842 Session session = null;
2843
2844 try {
2845 session = openSession();
2846
2847 Query q = session.createQuery(sql);
2848
2849 QueryPos qPos = QueryPos.getInstance(q);
2850
2851 qPos.add(groupId);
2852
2853 if (name != null) {
2854 qPos.add(name);
2855 }
2856
2857 count = (Long)q.uniqueResult();
2858 }
2859 catch (Exception e) {
2860 throw processException(e);
2861 }
2862 finally {
2863 if (count == null) {
2864 count = Long.valueOf(0);
2865 }
2866
2867 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
2868 count);
2869
2870 closeSession(session);
2871 }
2872 }
2873
2874 return count.intValue();
2875 }
2876
2877
2883 public int countAll() throws SystemException {
2884 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2885 FINDER_ARGS_EMPTY, this);
2886
2887 if (count == null) {
2888 Session session = null;
2889
2890 try {
2891 session = openSession();
2892
2893 Query q = session.createQuery(_SQL_COUNT_WIKINODE);
2894
2895 count = (Long)q.uniqueResult();
2896 }
2897 catch (Exception e) {
2898 throw processException(e);
2899 }
2900 finally {
2901 if (count == null) {
2902 count = Long.valueOf(0);
2903 }
2904
2905 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2906 FINDER_ARGS_EMPTY, count);
2907
2908 closeSession(session);
2909 }
2910 }
2911
2912 return count.intValue();
2913 }
2914
2915
2918 public void afterPropertiesSet() {
2919 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2920 com.liferay.portal.util.PropsUtil.get(
2921 "value.object.listener.com.liferay.portlet.wiki.model.WikiNode")));
2922
2923 if (listenerClassNames.length > 0) {
2924 try {
2925 List<ModelListener<WikiNode>> listenersList = new ArrayList<ModelListener<WikiNode>>();
2926
2927 for (String listenerClassName : listenerClassNames) {
2928 listenersList.add((ModelListener<WikiNode>)InstanceFactory.newInstance(
2929 listenerClassName));
2930 }
2931
2932 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2933 }
2934 catch (Exception e) {
2935 _log.error(e);
2936 }
2937 }
2938 }
2939
2940 public void destroy() {
2941 EntityCacheUtil.removeCache(WikiNodeImpl.class.getName());
2942 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2943 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2944 }
2945
2946 @BeanReference(type = WikiNodePersistence.class)
2947 protected WikiNodePersistence wikiNodePersistence;
2948 @BeanReference(type = WikiPagePersistence.class)
2949 protected WikiPagePersistence wikiPagePersistence;
2950 @BeanReference(type = WikiPageResourcePersistence.class)
2951 protected WikiPageResourcePersistence wikiPageResourcePersistence;
2952 @BeanReference(type = GroupPersistence.class)
2953 protected GroupPersistence groupPersistence;
2954 @BeanReference(type = ResourcePersistence.class)
2955 protected ResourcePersistence resourcePersistence;
2956 @BeanReference(type = SubscriptionPersistence.class)
2957 protected SubscriptionPersistence subscriptionPersistence;
2958 @BeanReference(type = UserPersistence.class)
2959 protected UserPersistence userPersistence;
2960 private static final String _SQL_SELECT_WIKINODE = "SELECT wikiNode FROM WikiNode wikiNode";
2961 private static final String _SQL_SELECT_WIKINODE_WHERE = "SELECT wikiNode FROM WikiNode wikiNode WHERE ";
2962 private static final String _SQL_COUNT_WIKINODE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode";
2963 private static final String _SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode WHERE ";
2964 private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiNode.uuid IS NULL";
2965 private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiNode.uuid = ?";
2966 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?)";
2967 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiNode.uuid IS NULL AND ";
2968 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiNode.uuid = ? AND ";
2969 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?) AND ";
2970 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiNode.groupId = ?";
2971 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "wikiNode.groupId = ?";
2972 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "wikiNode.companyId = ?";
2973 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "wikiNode.groupId = ? AND ";
2974 private static final String _FINDER_COLUMN_G_N_NAME_1 = "wikiNode.name IS NULL";
2975 private static final String _FINDER_COLUMN_G_N_NAME_2 = "wikiNode.name = ?";
2976 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(wikiNode.name IS NULL OR wikiNode.name = ?)";
2977 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "wikiNode.nodeId";
2978 private static final String _FILTER_SQL_SELECT_WIKINODE_WHERE = "SELECT DISTINCT {wikiNode.*} FROM WikiNode wikiNode WHERE ";
2979 private static final String _FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1 =
2980 "SELECT {WikiNode.*} FROM (SELECT DISTINCT wikiNode.nodeId FROM WikiNode wikiNode WHERE ";
2981 private static final String _FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2 =
2982 ") TEMP_TABLE INNER JOIN WikiNode ON TEMP_TABLE.nodeId = WikiNode.nodeId";
2983 private static final String _FILTER_SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(DISTINCT wikiNode.nodeId) AS COUNT_VALUE FROM WikiNode wikiNode WHERE ";
2984 private static final String _FILTER_ENTITY_ALIAS = "wikiNode";
2985 private static final String _FILTER_ENTITY_TABLE = "WikiNode";
2986 private static final String _ORDER_BY_ENTITY_ALIAS = "wikiNode.";
2987 private static final String _ORDER_BY_ENTITY_TABLE = "WikiNode.";
2988 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiNode exists with the primary key ";
2989 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiNode exists with the key {";
2990 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2991 private static Log _log = LogFactoryUtil.getLog(WikiNodePersistenceImpl.class);
2992 private static WikiNode _nullWikiNode = new WikiNodeImpl() {
2993 @Override
2994 public Object clone() {
2995 return this;
2996 }
2997
2998 @Override
2999 public CacheModel<WikiNode> toCacheModel() {
3000 return _nullWikiNodeCacheModel;
3001 }
3002 };
3003
3004 private static CacheModel<WikiNode> _nullWikiNodeCacheModel = new CacheModel<WikiNode>() {
3005 public WikiNode toEntityModel() {
3006 return _nullWikiNode;
3007 }
3008 };
3009 }