001
014
015 package com.liferay.portlet.wiki.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.SQLQuery;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.UnmodifiableList;
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.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.wiki.NoSuchNodeException;
045 import com.liferay.portlet.wiki.model.WikiNode;
046 import com.liferay.portlet.wiki.model.impl.WikiNodeImpl;
047 import com.liferay.portlet.wiki.model.impl.WikiNodeModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.ArrayList;
052 import java.util.Collections;
053 import java.util.List;
054
055
067 public class WikiNodePersistenceImpl extends BasePersistenceImpl<WikiNode>
068 implements WikiNodePersistence {
069
074 public static final String FINDER_CLASS_NAME_ENTITY = WikiNodeImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List1";
077 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List2";
079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
080 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
081 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
082 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
083 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
086 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
089 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
090 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
091 new String[] {
092 String.class.getName(),
093
094 Integer.class.getName(), Integer.class.getName(),
095 OrderByComparator.class.getName()
096 });
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
098 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
100 new String[] { String.class.getName() },
101 WikiNodeModelImpl.UUID_COLUMN_BITMASK |
102 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
103 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
104 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
106 new String[] { String.class.getName() });
107
108
115 public List<WikiNode> findByUuid(String uuid) throws SystemException {
116 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
117 }
118
119
132 public List<WikiNode> findByUuid(String uuid, int start, int end)
133 throws SystemException {
134 return findByUuid(uuid, start, end, null);
135 }
136
137
151 public List<WikiNode> findByUuid(String uuid, int start, int end,
152 OrderByComparator orderByComparator) throws SystemException {
153 boolean pagination = true;
154 FinderPath finderPath = null;
155 Object[] finderArgs = null;
156
157 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
158 (orderByComparator == null)) {
159 pagination = false;
160 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
161 finderArgs = new Object[] { uuid };
162 }
163 else {
164 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
165 finderArgs = new Object[] { uuid, start, end, orderByComparator };
166 }
167
168 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
169 finderArgs, this);
170
171 if ((list != null) && !list.isEmpty()) {
172 for (WikiNode wikiNode : list) {
173 if (!Validator.equals(uuid, wikiNode.getUuid())) {
174 list = null;
175
176 break;
177 }
178 }
179 }
180
181 if (list == null) {
182 StringBundler query = null;
183
184 if (orderByComparator != null) {
185 query = new StringBundler(3 +
186 (orderByComparator.getOrderByFields().length * 3));
187 }
188 else {
189 query = new StringBundler(3);
190 }
191
192 query.append(_SQL_SELECT_WIKINODE_WHERE);
193
194 if (uuid == null) {
195 query.append(_FINDER_COLUMN_UUID_UUID_1);
196 }
197 else {
198 if (uuid.equals(StringPool.BLANK)) {
199 query.append(_FINDER_COLUMN_UUID_UUID_3);
200 }
201 else {
202 query.append(_FINDER_COLUMN_UUID_UUID_2);
203 }
204 }
205
206 if (orderByComparator != null) {
207 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
208 orderByComparator);
209 }
210 else
211 if (pagination) {
212 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
213 }
214
215 String sql = query.toString();
216
217 Session session = null;
218
219 try {
220 session = openSession();
221
222 Query q = session.createQuery(sql);
223
224 QueryPos qPos = QueryPos.getInstance(q);
225
226 if (uuid != null) {
227 qPos.add(uuid);
228 }
229
230 if (!pagination) {
231 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
232 start, end, false);
233
234 Collections.sort(list);
235
236 list = new UnmodifiableList<WikiNode>(list);
237 }
238 else {
239 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
240 start, end);
241 }
242
243 cacheResult(list);
244
245 FinderCacheUtil.putResult(finderPath, finderArgs, list);
246 }
247 catch (Exception e) {
248 FinderCacheUtil.removeResult(finderPath, finderArgs);
249
250 throw processException(e);
251 }
252 finally {
253 closeSession(session);
254 }
255 }
256
257 return list;
258 }
259
260
269 public WikiNode findByUuid_First(String uuid,
270 OrderByComparator orderByComparator)
271 throws NoSuchNodeException, SystemException {
272 WikiNode wikiNode = fetchByUuid_First(uuid, orderByComparator);
273
274 if (wikiNode != null) {
275 return wikiNode;
276 }
277
278 StringBundler msg = new StringBundler(4);
279
280 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
281
282 msg.append("uuid=");
283 msg.append(uuid);
284
285 msg.append(StringPool.CLOSE_CURLY_BRACE);
286
287 throw new NoSuchNodeException(msg.toString());
288 }
289
290
298 public WikiNode fetchByUuid_First(String uuid,
299 OrderByComparator orderByComparator) throws SystemException {
300 List<WikiNode> list = findByUuid(uuid, 0, 1, orderByComparator);
301
302 if (!list.isEmpty()) {
303 return list.get(0);
304 }
305
306 return null;
307 }
308
309
318 public WikiNode findByUuid_Last(String uuid,
319 OrderByComparator orderByComparator)
320 throws NoSuchNodeException, SystemException {
321 WikiNode wikiNode = fetchByUuid_Last(uuid, orderByComparator);
322
323 if (wikiNode != null) {
324 return wikiNode;
325 }
326
327 StringBundler msg = new StringBundler(4);
328
329 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
330
331 msg.append("uuid=");
332 msg.append(uuid);
333
334 msg.append(StringPool.CLOSE_CURLY_BRACE);
335
336 throw new NoSuchNodeException(msg.toString());
337 }
338
339
347 public WikiNode fetchByUuid_Last(String uuid,
348 OrderByComparator orderByComparator) throws SystemException {
349 int count = countByUuid(uuid);
350
351 List<WikiNode> list = findByUuid(uuid, count - 1, count,
352 orderByComparator);
353
354 if (!list.isEmpty()) {
355 return list.get(0);
356 }
357
358 return null;
359 }
360
361
371 public WikiNode[] findByUuid_PrevAndNext(long nodeId, String uuid,
372 OrderByComparator orderByComparator)
373 throws NoSuchNodeException, SystemException {
374 WikiNode wikiNode = findByPrimaryKey(nodeId);
375
376 Session session = null;
377
378 try {
379 session = openSession();
380
381 WikiNode[] array = new WikiNodeImpl[3];
382
383 array[0] = getByUuid_PrevAndNext(session, wikiNode, uuid,
384 orderByComparator, true);
385
386 array[1] = wikiNode;
387
388 array[2] = getByUuid_PrevAndNext(session, wikiNode, uuid,
389 orderByComparator, false);
390
391 return array;
392 }
393 catch (Exception e) {
394 throw processException(e);
395 }
396 finally {
397 closeSession(session);
398 }
399 }
400
401 protected WikiNode getByUuid_PrevAndNext(Session session,
402 WikiNode wikiNode, String uuid, OrderByComparator orderByComparator,
403 boolean previous) {
404 StringBundler query = null;
405
406 if (orderByComparator != null) {
407 query = new StringBundler(6 +
408 (orderByComparator.getOrderByFields().length * 6));
409 }
410 else {
411 query = new StringBundler(3);
412 }
413
414 query.append(_SQL_SELECT_WIKINODE_WHERE);
415
416 if (uuid == null) {
417 query.append(_FINDER_COLUMN_UUID_UUID_1);
418 }
419 else {
420 if (uuid.equals(StringPool.BLANK)) {
421 query.append(_FINDER_COLUMN_UUID_UUID_3);
422 }
423 else {
424 query.append(_FINDER_COLUMN_UUID_UUID_2);
425 }
426 }
427
428 if (orderByComparator != null) {
429 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
430
431 if (orderByConditionFields.length > 0) {
432 query.append(WHERE_AND);
433 }
434
435 for (int i = 0; i < orderByConditionFields.length; i++) {
436 query.append(_ORDER_BY_ENTITY_ALIAS);
437 query.append(orderByConditionFields[i]);
438
439 if ((i + 1) < orderByConditionFields.length) {
440 if (orderByComparator.isAscending() ^ previous) {
441 query.append(WHERE_GREATER_THAN_HAS_NEXT);
442 }
443 else {
444 query.append(WHERE_LESSER_THAN_HAS_NEXT);
445 }
446 }
447 else {
448 if (orderByComparator.isAscending() ^ previous) {
449 query.append(WHERE_GREATER_THAN);
450 }
451 else {
452 query.append(WHERE_LESSER_THAN);
453 }
454 }
455 }
456
457 query.append(ORDER_BY_CLAUSE);
458
459 String[] orderByFields = orderByComparator.getOrderByFields();
460
461 for (int i = 0; i < orderByFields.length; i++) {
462 query.append(_ORDER_BY_ENTITY_ALIAS);
463 query.append(orderByFields[i]);
464
465 if ((i + 1) < orderByFields.length) {
466 if (orderByComparator.isAscending() ^ previous) {
467 query.append(ORDER_BY_ASC_HAS_NEXT);
468 }
469 else {
470 query.append(ORDER_BY_DESC_HAS_NEXT);
471 }
472 }
473 else {
474 if (orderByComparator.isAscending() ^ previous) {
475 query.append(ORDER_BY_ASC);
476 }
477 else {
478 query.append(ORDER_BY_DESC);
479 }
480 }
481 }
482 }
483 else {
484 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
485 }
486
487 String sql = query.toString();
488
489 Query q = session.createQuery(sql);
490
491 q.setFirstResult(0);
492 q.setMaxResults(2);
493
494 QueryPos qPos = QueryPos.getInstance(q);
495
496 if (uuid != null) {
497 qPos.add(uuid);
498 }
499
500 if (orderByComparator != null) {
501 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
502
503 for (Object value : values) {
504 qPos.add(value);
505 }
506 }
507
508 List<WikiNode> list = q.list();
509
510 if (list.size() == 2) {
511 return list.get(1);
512 }
513 else {
514 return null;
515 }
516 }
517
518
524 public void removeByUuid(String uuid) throws SystemException {
525 for (WikiNode wikiNode : findByUuid(uuid, QueryUtil.ALL_POS,
526 QueryUtil.ALL_POS, null)) {
527 remove(wikiNode);
528 }
529 }
530
531
538 public int countByUuid(String uuid) throws SystemException {
539 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
540
541 Object[] finderArgs = new Object[] { uuid };
542
543 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
544 this);
545
546 if (count == null) {
547 StringBundler query = new StringBundler(2);
548
549 query.append(_SQL_COUNT_WIKINODE_WHERE);
550
551 if (uuid == null) {
552 query.append(_FINDER_COLUMN_UUID_UUID_1);
553 }
554 else {
555 if (uuid.equals(StringPool.BLANK)) {
556 query.append(_FINDER_COLUMN_UUID_UUID_3);
557 }
558 else {
559 query.append(_FINDER_COLUMN_UUID_UUID_2);
560 }
561 }
562
563 String sql = query.toString();
564
565 Session session = null;
566
567 try {
568 session = openSession();
569
570 Query q = session.createQuery(sql);
571
572 QueryPos qPos = QueryPos.getInstance(q);
573
574 if (uuid != null) {
575 qPos.add(uuid);
576 }
577
578 count = (Long)q.uniqueResult();
579
580 FinderCacheUtil.putResult(finderPath, finderArgs, count);
581 }
582 catch (Exception e) {
583 FinderCacheUtil.removeResult(finderPath, finderArgs);
584
585 throw processException(e);
586 }
587 finally {
588 closeSession(session);
589 }
590 }
591
592 return count.intValue();
593 }
594
595 private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiNode.uuid IS NULL";
596 private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiNode.uuid = ?";
597 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?)";
598 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
599 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
600 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
601 new String[] { String.class.getName(), Long.class.getName() },
602 WikiNodeModelImpl.UUID_COLUMN_BITMASK |
603 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK);
604 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
605 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
606 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
607 new String[] { String.class.getName(), Long.class.getName() });
608
609
618 public WikiNode findByUUID_G(String uuid, long groupId)
619 throws NoSuchNodeException, SystemException {
620 WikiNode wikiNode = fetchByUUID_G(uuid, groupId);
621
622 if (wikiNode == null) {
623 StringBundler msg = new StringBundler(6);
624
625 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
626
627 msg.append("uuid=");
628 msg.append(uuid);
629
630 msg.append(", groupId=");
631 msg.append(groupId);
632
633 msg.append(StringPool.CLOSE_CURLY_BRACE);
634
635 if (_log.isWarnEnabled()) {
636 _log.warn(msg.toString());
637 }
638
639 throw new NoSuchNodeException(msg.toString());
640 }
641
642 return wikiNode;
643 }
644
645
653 public WikiNode fetchByUUID_G(String uuid, long groupId)
654 throws SystemException {
655 return fetchByUUID_G(uuid, groupId, true);
656 }
657
658
667 public WikiNode fetchByUUID_G(String uuid, long groupId,
668 boolean retrieveFromCache) throws SystemException {
669 Object[] finderArgs = new Object[] { uuid, groupId };
670
671 Object result = null;
672
673 if (retrieveFromCache) {
674 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
675 finderArgs, this);
676 }
677
678 if (result instanceof WikiNode) {
679 WikiNode wikiNode = (WikiNode)result;
680
681 if (!Validator.equals(uuid, wikiNode.getUuid()) ||
682 (groupId != wikiNode.getGroupId())) {
683 result = null;
684 }
685 }
686
687 if (result == null) {
688 StringBundler query = new StringBundler(4);
689
690 query.append(_SQL_SELECT_WIKINODE_WHERE);
691
692 if (uuid == null) {
693 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
694 }
695 else {
696 if (uuid.equals(StringPool.BLANK)) {
697 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
698 }
699 else {
700 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
701 }
702 }
703
704 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
705
706 String sql = query.toString();
707
708 Session session = null;
709
710 try {
711 session = openSession();
712
713 Query q = session.createQuery(sql);
714
715 QueryPos qPos = QueryPos.getInstance(q);
716
717 if (uuid != null) {
718 qPos.add(uuid);
719 }
720
721 qPos.add(groupId);
722
723 List<WikiNode> list = q.list();
724
725 if (list.isEmpty()) {
726 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
727 finderArgs, list);
728 }
729 else {
730 WikiNode wikiNode = list.get(0);
731
732 result = wikiNode;
733
734 cacheResult(wikiNode);
735
736 if ((wikiNode.getUuid() == null) ||
737 !wikiNode.getUuid().equals(uuid) ||
738 (wikiNode.getGroupId() != groupId)) {
739 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
740 finderArgs, wikiNode);
741 }
742 }
743 }
744 catch (Exception e) {
745 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
746 finderArgs);
747
748 throw processException(e);
749 }
750 finally {
751 closeSession(session);
752 }
753 }
754
755 if (result instanceof List<?>) {
756 return null;
757 }
758 else {
759 return (WikiNode)result;
760 }
761 }
762
763
771 public WikiNode removeByUUID_G(String uuid, long groupId)
772 throws NoSuchNodeException, SystemException {
773 WikiNode wikiNode = findByUUID_G(uuid, groupId);
774
775 return remove(wikiNode);
776 }
777
778
786 public int countByUUID_G(String uuid, long groupId)
787 throws SystemException {
788 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
789
790 Object[] finderArgs = new Object[] { uuid, groupId };
791
792 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
793 this);
794
795 if (count == null) {
796 StringBundler query = new StringBundler(3);
797
798 query.append(_SQL_COUNT_WIKINODE_WHERE);
799
800 if (uuid == null) {
801 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
802 }
803 else {
804 if (uuid.equals(StringPool.BLANK)) {
805 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
806 }
807 else {
808 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
809 }
810 }
811
812 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
813
814 String sql = query.toString();
815
816 Session session = null;
817
818 try {
819 session = openSession();
820
821 Query q = session.createQuery(sql);
822
823 QueryPos qPos = QueryPos.getInstance(q);
824
825 if (uuid != null) {
826 qPos.add(uuid);
827 }
828
829 qPos.add(groupId);
830
831 count = (Long)q.uniqueResult();
832
833 FinderCacheUtil.putResult(finderPath, finderArgs, count);
834 }
835 catch (Exception e) {
836 FinderCacheUtil.removeResult(finderPath, finderArgs);
837
838 throw processException(e);
839 }
840 finally {
841 closeSession(session);
842 }
843 }
844
845 return count.intValue();
846 }
847
848 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiNode.uuid IS NULL AND ";
849 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiNode.uuid = ? AND ";
850 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?) AND ";
851 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiNode.groupId = ?";
852 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
853 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
854 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
855 new String[] {
856 String.class.getName(), Long.class.getName(),
857
858 Integer.class.getName(), Integer.class.getName(),
859 OrderByComparator.class.getName()
860 });
861 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
862 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
863 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
864 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
865 new String[] { String.class.getName(), Long.class.getName() },
866 WikiNodeModelImpl.UUID_COLUMN_BITMASK |
867 WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK |
868 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
869 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
870 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
871 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
872 new String[] { String.class.getName(), Long.class.getName() });
873
874
882 public List<WikiNode> findByUuid_C(String uuid, long companyId)
883 throws SystemException {
884 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
885 QueryUtil.ALL_POS, null);
886 }
887
888
902 public List<WikiNode> findByUuid_C(String uuid, long companyId, int start,
903 int end) throws SystemException {
904 return findByUuid_C(uuid, companyId, start, end, null);
905 }
906
907
922 public List<WikiNode> findByUuid_C(String uuid, long companyId, int start,
923 int end, OrderByComparator orderByComparator) throws SystemException {
924 boolean pagination = true;
925 FinderPath finderPath = null;
926 Object[] finderArgs = null;
927
928 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
929 (orderByComparator == null)) {
930 pagination = false;
931 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
932 finderArgs = new Object[] { uuid, companyId };
933 }
934 else {
935 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
936 finderArgs = new Object[] {
937 uuid, companyId,
938
939 start, end, orderByComparator
940 };
941 }
942
943 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
944 finderArgs, this);
945
946 if ((list != null) && !list.isEmpty()) {
947 for (WikiNode wikiNode : list) {
948 if (!Validator.equals(uuid, wikiNode.getUuid()) ||
949 (companyId != wikiNode.getCompanyId())) {
950 list = null;
951
952 break;
953 }
954 }
955 }
956
957 if (list == null) {
958 StringBundler query = null;
959
960 if (orderByComparator != null) {
961 query = new StringBundler(4 +
962 (orderByComparator.getOrderByFields().length * 3));
963 }
964 else {
965 query = new StringBundler(4);
966 }
967
968 query.append(_SQL_SELECT_WIKINODE_WHERE);
969
970 if (uuid == null) {
971 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
972 }
973 else {
974 if (uuid.equals(StringPool.BLANK)) {
975 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
976 }
977 else {
978 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
979 }
980 }
981
982 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
983
984 if (orderByComparator != null) {
985 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
986 orderByComparator);
987 }
988 else
989 if (pagination) {
990 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
991 }
992
993 String sql = query.toString();
994
995 Session session = null;
996
997 try {
998 session = openSession();
999
1000 Query q = session.createQuery(sql);
1001
1002 QueryPos qPos = QueryPos.getInstance(q);
1003
1004 if (uuid != null) {
1005 qPos.add(uuid);
1006 }
1007
1008 qPos.add(companyId);
1009
1010 if (!pagination) {
1011 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1012 start, end, false);
1013
1014 Collections.sort(list);
1015
1016 list = new UnmodifiableList<WikiNode>(list);
1017 }
1018 else {
1019 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1020 start, end);
1021 }
1022
1023 cacheResult(list);
1024
1025 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1026 }
1027 catch (Exception e) {
1028 FinderCacheUtil.removeResult(finderPath, finderArgs);
1029
1030 throw processException(e);
1031 }
1032 finally {
1033 closeSession(session);
1034 }
1035 }
1036
1037 return list;
1038 }
1039
1040
1050 public WikiNode findByUuid_C_First(String uuid, long companyId,
1051 OrderByComparator orderByComparator)
1052 throws NoSuchNodeException, SystemException {
1053 WikiNode wikiNode = fetchByUuid_C_First(uuid, companyId,
1054 orderByComparator);
1055
1056 if (wikiNode != null) {
1057 return wikiNode;
1058 }
1059
1060 StringBundler msg = new StringBundler(6);
1061
1062 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1063
1064 msg.append("uuid=");
1065 msg.append(uuid);
1066
1067 msg.append(", companyId=");
1068 msg.append(companyId);
1069
1070 msg.append(StringPool.CLOSE_CURLY_BRACE);
1071
1072 throw new NoSuchNodeException(msg.toString());
1073 }
1074
1075
1084 public WikiNode fetchByUuid_C_First(String uuid, long companyId,
1085 OrderByComparator orderByComparator) throws SystemException {
1086 List<WikiNode> list = findByUuid_C(uuid, companyId, 0, 1,
1087 orderByComparator);
1088
1089 if (!list.isEmpty()) {
1090 return list.get(0);
1091 }
1092
1093 return null;
1094 }
1095
1096
1106 public WikiNode findByUuid_C_Last(String uuid, long companyId,
1107 OrderByComparator orderByComparator)
1108 throws NoSuchNodeException, SystemException {
1109 WikiNode wikiNode = fetchByUuid_C_Last(uuid, companyId,
1110 orderByComparator);
1111
1112 if (wikiNode != null) {
1113 return wikiNode;
1114 }
1115
1116 StringBundler msg = new StringBundler(6);
1117
1118 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1119
1120 msg.append("uuid=");
1121 msg.append(uuid);
1122
1123 msg.append(", companyId=");
1124 msg.append(companyId);
1125
1126 msg.append(StringPool.CLOSE_CURLY_BRACE);
1127
1128 throw new NoSuchNodeException(msg.toString());
1129 }
1130
1131
1140 public WikiNode fetchByUuid_C_Last(String uuid, long companyId,
1141 OrderByComparator orderByComparator) throws SystemException {
1142 int count = countByUuid_C(uuid, companyId);
1143
1144 List<WikiNode> list = findByUuid_C(uuid, companyId, count - 1, count,
1145 orderByComparator);
1146
1147 if (!list.isEmpty()) {
1148 return list.get(0);
1149 }
1150
1151 return null;
1152 }
1153
1154
1165 public WikiNode[] findByUuid_C_PrevAndNext(long nodeId, String uuid,
1166 long companyId, OrderByComparator orderByComparator)
1167 throws NoSuchNodeException, SystemException {
1168 WikiNode wikiNode = findByPrimaryKey(nodeId);
1169
1170 Session session = null;
1171
1172 try {
1173 session = openSession();
1174
1175 WikiNode[] array = new WikiNodeImpl[3];
1176
1177 array[0] = getByUuid_C_PrevAndNext(session, wikiNode, uuid,
1178 companyId, orderByComparator, true);
1179
1180 array[1] = wikiNode;
1181
1182 array[2] = getByUuid_C_PrevAndNext(session, wikiNode, uuid,
1183 companyId, orderByComparator, false);
1184
1185 return array;
1186 }
1187 catch (Exception e) {
1188 throw processException(e);
1189 }
1190 finally {
1191 closeSession(session);
1192 }
1193 }
1194
1195 protected WikiNode getByUuid_C_PrevAndNext(Session session,
1196 WikiNode wikiNode, String uuid, long companyId,
1197 OrderByComparator orderByComparator, boolean previous) {
1198 StringBundler query = null;
1199
1200 if (orderByComparator != null) {
1201 query = new StringBundler(6 +
1202 (orderByComparator.getOrderByFields().length * 6));
1203 }
1204 else {
1205 query = new StringBundler(3);
1206 }
1207
1208 query.append(_SQL_SELECT_WIKINODE_WHERE);
1209
1210 if (uuid == null) {
1211 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1212 }
1213 else {
1214 if (uuid.equals(StringPool.BLANK)) {
1215 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1216 }
1217 else {
1218 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1219 }
1220 }
1221
1222 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1223
1224 if (orderByComparator != null) {
1225 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1226
1227 if (orderByConditionFields.length > 0) {
1228 query.append(WHERE_AND);
1229 }
1230
1231 for (int i = 0; i < orderByConditionFields.length; i++) {
1232 query.append(_ORDER_BY_ENTITY_ALIAS);
1233 query.append(orderByConditionFields[i]);
1234
1235 if ((i + 1) < orderByConditionFields.length) {
1236 if (orderByComparator.isAscending() ^ previous) {
1237 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1238 }
1239 else {
1240 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1241 }
1242 }
1243 else {
1244 if (orderByComparator.isAscending() ^ previous) {
1245 query.append(WHERE_GREATER_THAN);
1246 }
1247 else {
1248 query.append(WHERE_LESSER_THAN);
1249 }
1250 }
1251 }
1252
1253 query.append(ORDER_BY_CLAUSE);
1254
1255 String[] orderByFields = orderByComparator.getOrderByFields();
1256
1257 for (int i = 0; i < orderByFields.length; i++) {
1258 query.append(_ORDER_BY_ENTITY_ALIAS);
1259 query.append(orderByFields[i]);
1260
1261 if ((i + 1) < orderByFields.length) {
1262 if (orderByComparator.isAscending() ^ previous) {
1263 query.append(ORDER_BY_ASC_HAS_NEXT);
1264 }
1265 else {
1266 query.append(ORDER_BY_DESC_HAS_NEXT);
1267 }
1268 }
1269 else {
1270 if (orderByComparator.isAscending() ^ previous) {
1271 query.append(ORDER_BY_ASC);
1272 }
1273 else {
1274 query.append(ORDER_BY_DESC);
1275 }
1276 }
1277 }
1278 }
1279 else {
1280 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1281 }
1282
1283 String sql = query.toString();
1284
1285 Query q = session.createQuery(sql);
1286
1287 q.setFirstResult(0);
1288 q.setMaxResults(2);
1289
1290 QueryPos qPos = QueryPos.getInstance(q);
1291
1292 if (uuid != null) {
1293 qPos.add(uuid);
1294 }
1295
1296 qPos.add(companyId);
1297
1298 if (orderByComparator != null) {
1299 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1300
1301 for (Object value : values) {
1302 qPos.add(value);
1303 }
1304 }
1305
1306 List<WikiNode> list = q.list();
1307
1308 if (list.size() == 2) {
1309 return list.get(1);
1310 }
1311 else {
1312 return null;
1313 }
1314 }
1315
1316
1323 public void removeByUuid_C(String uuid, long companyId)
1324 throws SystemException {
1325 for (WikiNode wikiNode : findByUuid_C(uuid, companyId,
1326 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1327 remove(wikiNode);
1328 }
1329 }
1330
1331
1339 public int countByUuid_C(String uuid, long companyId)
1340 throws SystemException {
1341 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1342
1343 Object[] finderArgs = new Object[] { uuid, companyId };
1344
1345 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1346 this);
1347
1348 if (count == null) {
1349 StringBundler query = new StringBundler(3);
1350
1351 query.append(_SQL_COUNT_WIKINODE_WHERE);
1352
1353 if (uuid == null) {
1354 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1355 }
1356 else {
1357 if (uuid.equals(StringPool.BLANK)) {
1358 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1359 }
1360 else {
1361 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1362 }
1363 }
1364
1365 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1366
1367 String sql = query.toString();
1368
1369 Session session = null;
1370
1371 try {
1372 session = openSession();
1373
1374 Query q = session.createQuery(sql);
1375
1376 QueryPos qPos = QueryPos.getInstance(q);
1377
1378 if (uuid != null) {
1379 qPos.add(uuid);
1380 }
1381
1382 qPos.add(companyId);
1383
1384 count = (Long)q.uniqueResult();
1385
1386 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1387 }
1388 catch (Exception e) {
1389 FinderCacheUtil.removeResult(finderPath, finderArgs);
1390
1391 throw processException(e);
1392 }
1393 finally {
1394 closeSession(session);
1395 }
1396 }
1397
1398 return count.intValue();
1399 }
1400
1401 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "wikiNode.uuid IS NULL AND ";
1402 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "wikiNode.uuid = ? AND ";
1403 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?) AND ";
1404 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "wikiNode.companyId = ?";
1405 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
1406 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
1407 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1408 new String[] {
1409 Long.class.getName(),
1410
1411 Integer.class.getName(), Integer.class.getName(),
1412 OrderByComparator.class.getName()
1413 });
1414 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1415 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
1416 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
1417 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1418 new String[] { Long.class.getName() },
1419 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
1420 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
1421 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
1422 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
1423 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1424 new String[] { Long.class.getName() });
1425
1426
1433 public List<WikiNode> findByGroupId(long groupId) throws SystemException {
1434 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1435 }
1436
1437
1450 public List<WikiNode> findByGroupId(long groupId, int start, int end)
1451 throws SystemException {
1452 return findByGroupId(groupId, start, end, null);
1453 }
1454
1455
1469 public List<WikiNode> findByGroupId(long groupId, int start, int end,
1470 OrderByComparator orderByComparator) throws SystemException {
1471 boolean pagination = true;
1472 FinderPath finderPath = null;
1473 Object[] finderArgs = null;
1474
1475 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1476 (orderByComparator == null)) {
1477 pagination = false;
1478 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1479 finderArgs = new Object[] { groupId };
1480 }
1481 else {
1482 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1483 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1484 }
1485
1486 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
1487 finderArgs, this);
1488
1489 if ((list != null) && !list.isEmpty()) {
1490 for (WikiNode wikiNode : list) {
1491 if ((groupId != wikiNode.getGroupId())) {
1492 list = null;
1493
1494 break;
1495 }
1496 }
1497 }
1498
1499 if (list == null) {
1500 StringBundler query = null;
1501
1502 if (orderByComparator != null) {
1503 query = new StringBundler(3 +
1504 (orderByComparator.getOrderByFields().length * 3));
1505 }
1506 else {
1507 query = new StringBundler(3);
1508 }
1509
1510 query.append(_SQL_SELECT_WIKINODE_WHERE);
1511
1512 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1513
1514 if (orderByComparator != null) {
1515 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1516 orderByComparator);
1517 }
1518 else
1519 if (pagination) {
1520 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1521 }
1522
1523 String sql = query.toString();
1524
1525 Session session = null;
1526
1527 try {
1528 session = openSession();
1529
1530 Query q = session.createQuery(sql);
1531
1532 QueryPos qPos = QueryPos.getInstance(q);
1533
1534 qPos.add(groupId);
1535
1536 if (!pagination) {
1537 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1538 start, end, false);
1539
1540 Collections.sort(list);
1541
1542 list = new UnmodifiableList<WikiNode>(list);
1543 }
1544 else {
1545 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1546 start, end);
1547 }
1548
1549 cacheResult(list);
1550
1551 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1552 }
1553 catch (Exception e) {
1554 FinderCacheUtil.removeResult(finderPath, finderArgs);
1555
1556 throw processException(e);
1557 }
1558 finally {
1559 closeSession(session);
1560 }
1561 }
1562
1563 return list;
1564 }
1565
1566
1575 public WikiNode findByGroupId_First(long groupId,
1576 OrderByComparator orderByComparator)
1577 throws NoSuchNodeException, SystemException {
1578 WikiNode wikiNode = fetchByGroupId_First(groupId, orderByComparator);
1579
1580 if (wikiNode != null) {
1581 return wikiNode;
1582 }
1583
1584 StringBundler msg = new StringBundler(4);
1585
1586 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1587
1588 msg.append("groupId=");
1589 msg.append(groupId);
1590
1591 msg.append(StringPool.CLOSE_CURLY_BRACE);
1592
1593 throw new NoSuchNodeException(msg.toString());
1594 }
1595
1596
1604 public WikiNode fetchByGroupId_First(long groupId,
1605 OrderByComparator orderByComparator) throws SystemException {
1606 List<WikiNode> list = findByGroupId(groupId, 0, 1, orderByComparator);
1607
1608 if (!list.isEmpty()) {
1609 return list.get(0);
1610 }
1611
1612 return null;
1613 }
1614
1615
1624 public WikiNode findByGroupId_Last(long groupId,
1625 OrderByComparator orderByComparator)
1626 throws NoSuchNodeException, SystemException {
1627 WikiNode wikiNode = fetchByGroupId_Last(groupId, orderByComparator);
1628
1629 if (wikiNode != null) {
1630 return wikiNode;
1631 }
1632
1633 StringBundler msg = new StringBundler(4);
1634
1635 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1636
1637 msg.append("groupId=");
1638 msg.append(groupId);
1639
1640 msg.append(StringPool.CLOSE_CURLY_BRACE);
1641
1642 throw new NoSuchNodeException(msg.toString());
1643 }
1644
1645
1653 public WikiNode fetchByGroupId_Last(long groupId,
1654 OrderByComparator orderByComparator) throws SystemException {
1655 int count = countByGroupId(groupId);
1656
1657 List<WikiNode> list = findByGroupId(groupId, count - 1, count,
1658 orderByComparator);
1659
1660 if (!list.isEmpty()) {
1661 return list.get(0);
1662 }
1663
1664 return null;
1665 }
1666
1667
1677 public WikiNode[] findByGroupId_PrevAndNext(long nodeId, long groupId,
1678 OrderByComparator orderByComparator)
1679 throws NoSuchNodeException, SystemException {
1680 WikiNode wikiNode = findByPrimaryKey(nodeId);
1681
1682 Session session = null;
1683
1684 try {
1685 session = openSession();
1686
1687 WikiNode[] array = new WikiNodeImpl[3];
1688
1689 array[0] = getByGroupId_PrevAndNext(session, wikiNode, groupId,
1690 orderByComparator, true);
1691
1692 array[1] = wikiNode;
1693
1694 array[2] = getByGroupId_PrevAndNext(session, wikiNode, groupId,
1695 orderByComparator, false);
1696
1697 return array;
1698 }
1699 catch (Exception e) {
1700 throw processException(e);
1701 }
1702 finally {
1703 closeSession(session);
1704 }
1705 }
1706
1707 protected WikiNode getByGroupId_PrevAndNext(Session session,
1708 WikiNode wikiNode, long groupId, OrderByComparator orderByComparator,
1709 boolean previous) {
1710 StringBundler query = null;
1711
1712 if (orderByComparator != null) {
1713 query = new StringBundler(6 +
1714 (orderByComparator.getOrderByFields().length * 6));
1715 }
1716 else {
1717 query = new StringBundler(3);
1718 }
1719
1720 query.append(_SQL_SELECT_WIKINODE_WHERE);
1721
1722 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1723
1724 if (orderByComparator != null) {
1725 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1726
1727 if (orderByConditionFields.length > 0) {
1728 query.append(WHERE_AND);
1729 }
1730
1731 for (int i = 0; i < orderByConditionFields.length; i++) {
1732 query.append(_ORDER_BY_ENTITY_ALIAS);
1733 query.append(orderByConditionFields[i]);
1734
1735 if ((i + 1) < orderByConditionFields.length) {
1736 if (orderByComparator.isAscending() ^ previous) {
1737 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1738 }
1739 else {
1740 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1741 }
1742 }
1743 else {
1744 if (orderByComparator.isAscending() ^ previous) {
1745 query.append(WHERE_GREATER_THAN);
1746 }
1747 else {
1748 query.append(WHERE_LESSER_THAN);
1749 }
1750 }
1751 }
1752
1753 query.append(ORDER_BY_CLAUSE);
1754
1755 String[] orderByFields = orderByComparator.getOrderByFields();
1756
1757 for (int i = 0; i < orderByFields.length; i++) {
1758 query.append(_ORDER_BY_ENTITY_ALIAS);
1759 query.append(orderByFields[i]);
1760
1761 if ((i + 1) < orderByFields.length) {
1762 if (orderByComparator.isAscending() ^ previous) {
1763 query.append(ORDER_BY_ASC_HAS_NEXT);
1764 }
1765 else {
1766 query.append(ORDER_BY_DESC_HAS_NEXT);
1767 }
1768 }
1769 else {
1770 if (orderByComparator.isAscending() ^ previous) {
1771 query.append(ORDER_BY_ASC);
1772 }
1773 else {
1774 query.append(ORDER_BY_DESC);
1775 }
1776 }
1777 }
1778 }
1779 else {
1780 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1781 }
1782
1783 String sql = query.toString();
1784
1785 Query q = session.createQuery(sql);
1786
1787 q.setFirstResult(0);
1788 q.setMaxResults(2);
1789
1790 QueryPos qPos = QueryPos.getInstance(q);
1791
1792 qPos.add(groupId);
1793
1794 if (orderByComparator != null) {
1795 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1796
1797 for (Object value : values) {
1798 qPos.add(value);
1799 }
1800 }
1801
1802 List<WikiNode> list = q.list();
1803
1804 if (list.size() == 2) {
1805 return list.get(1);
1806 }
1807 else {
1808 return null;
1809 }
1810 }
1811
1812
1819 public List<WikiNode> filterFindByGroupId(long groupId)
1820 throws SystemException {
1821 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1822 QueryUtil.ALL_POS, null);
1823 }
1824
1825
1838 public List<WikiNode> filterFindByGroupId(long groupId, int start, int end)
1839 throws SystemException {
1840 return filterFindByGroupId(groupId, start, end, null);
1841 }
1842
1843
1857 public List<WikiNode> filterFindByGroupId(long groupId, int start, int end,
1858 OrderByComparator orderByComparator) throws SystemException {
1859 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1860 return findByGroupId(groupId, start, end, orderByComparator);
1861 }
1862
1863 StringBundler query = null;
1864
1865 if (orderByComparator != null) {
1866 query = new StringBundler(3 +
1867 (orderByComparator.getOrderByFields().length * 3));
1868 }
1869 else {
1870 query = new StringBundler(3);
1871 }
1872
1873 if (getDB().isSupportsInlineDistinct()) {
1874 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
1875 }
1876 else {
1877 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
1878 }
1879
1880 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1881
1882 if (!getDB().isSupportsInlineDistinct()) {
1883 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
1884 }
1885
1886 if (orderByComparator != null) {
1887 if (getDB().isSupportsInlineDistinct()) {
1888 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1889 orderByComparator);
1890 }
1891 else {
1892 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1893 orderByComparator);
1894 }
1895 }
1896 else {
1897 if (getDB().isSupportsInlineDistinct()) {
1898 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1899 }
1900 else {
1901 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
1902 }
1903 }
1904
1905 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1906 WikiNode.class.getName(),
1907 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1908
1909 Session session = null;
1910
1911 try {
1912 session = openSession();
1913
1914 SQLQuery q = session.createSQLQuery(sql);
1915
1916 if (getDB().isSupportsInlineDistinct()) {
1917 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
1918 }
1919 else {
1920 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
1921 }
1922
1923 QueryPos qPos = QueryPos.getInstance(q);
1924
1925 qPos.add(groupId);
1926
1927 return (List<WikiNode>)QueryUtil.list(q, getDialect(), start, end);
1928 }
1929 catch (Exception e) {
1930 throw processException(e);
1931 }
1932 finally {
1933 closeSession(session);
1934 }
1935 }
1936
1937
1947 public WikiNode[] filterFindByGroupId_PrevAndNext(long nodeId,
1948 long groupId, OrderByComparator orderByComparator)
1949 throws NoSuchNodeException, SystemException {
1950 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1951 return findByGroupId_PrevAndNext(nodeId, groupId, orderByComparator);
1952 }
1953
1954 WikiNode wikiNode = findByPrimaryKey(nodeId);
1955
1956 Session session = null;
1957
1958 try {
1959 session = openSession();
1960
1961 WikiNode[] array = new WikiNodeImpl[3];
1962
1963 array[0] = filterGetByGroupId_PrevAndNext(session, wikiNode,
1964 groupId, orderByComparator, true);
1965
1966 array[1] = wikiNode;
1967
1968 array[2] = filterGetByGroupId_PrevAndNext(session, wikiNode,
1969 groupId, orderByComparator, false);
1970
1971 return array;
1972 }
1973 catch (Exception e) {
1974 throw processException(e);
1975 }
1976 finally {
1977 closeSession(session);
1978 }
1979 }
1980
1981 protected WikiNode filterGetByGroupId_PrevAndNext(Session session,
1982 WikiNode wikiNode, long groupId, OrderByComparator orderByComparator,
1983 boolean previous) {
1984 StringBundler query = null;
1985
1986 if (orderByComparator != null) {
1987 query = new StringBundler(6 +
1988 (orderByComparator.getOrderByFields().length * 6));
1989 }
1990 else {
1991 query = new StringBundler(3);
1992 }
1993
1994 if (getDB().isSupportsInlineDistinct()) {
1995 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
1996 }
1997 else {
1998 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
1999 }
2000
2001 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2002
2003 if (!getDB().isSupportsInlineDistinct()) {
2004 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
2005 }
2006
2007 if (orderByComparator != null) {
2008 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2009
2010 if (orderByConditionFields.length > 0) {
2011 query.append(WHERE_AND);
2012 }
2013
2014 for (int i = 0; i < orderByConditionFields.length; i++) {
2015 if (getDB().isSupportsInlineDistinct()) {
2016 query.append(_ORDER_BY_ENTITY_ALIAS);
2017 }
2018 else {
2019 query.append(_ORDER_BY_ENTITY_TABLE);
2020 }
2021
2022 query.append(orderByConditionFields[i]);
2023
2024 if ((i + 1) < orderByConditionFields.length) {
2025 if (orderByComparator.isAscending() ^ previous) {
2026 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2027 }
2028 else {
2029 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2030 }
2031 }
2032 else {
2033 if (orderByComparator.isAscending() ^ previous) {
2034 query.append(WHERE_GREATER_THAN);
2035 }
2036 else {
2037 query.append(WHERE_LESSER_THAN);
2038 }
2039 }
2040 }
2041
2042 query.append(ORDER_BY_CLAUSE);
2043
2044 String[] orderByFields = orderByComparator.getOrderByFields();
2045
2046 for (int i = 0; i < orderByFields.length; i++) {
2047 if (getDB().isSupportsInlineDistinct()) {
2048 query.append(_ORDER_BY_ENTITY_ALIAS);
2049 }
2050 else {
2051 query.append(_ORDER_BY_ENTITY_TABLE);
2052 }
2053
2054 query.append(orderByFields[i]);
2055
2056 if ((i + 1) < orderByFields.length) {
2057 if (orderByComparator.isAscending() ^ previous) {
2058 query.append(ORDER_BY_ASC_HAS_NEXT);
2059 }
2060 else {
2061 query.append(ORDER_BY_DESC_HAS_NEXT);
2062 }
2063 }
2064 else {
2065 if (orderByComparator.isAscending() ^ previous) {
2066 query.append(ORDER_BY_ASC);
2067 }
2068 else {
2069 query.append(ORDER_BY_DESC);
2070 }
2071 }
2072 }
2073 }
2074 else {
2075 if (getDB().isSupportsInlineDistinct()) {
2076 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2077 }
2078 else {
2079 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
2080 }
2081 }
2082
2083 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2084 WikiNode.class.getName(),
2085 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2086
2087 SQLQuery q = session.createSQLQuery(sql);
2088
2089 q.setFirstResult(0);
2090 q.setMaxResults(2);
2091
2092 if (getDB().isSupportsInlineDistinct()) {
2093 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
2094 }
2095 else {
2096 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
2097 }
2098
2099 QueryPos qPos = QueryPos.getInstance(q);
2100
2101 qPos.add(groupId);
2102
2103 if (orderByComparator != null) {
2104 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
2105
2106 for (Object value : values) {
2107 qPos.add(value);
2108 }
2109 }
2110
2111 List<WikiNode> list = q.list();
2112
2113 if (list.size() == 2) {
2114 return list.get(1);
2115 }
2116 else {
2117 return null;
2118 }
2119 }
2120
2121
2127 public void removeByGroupId(long groupId) throws SystemException {
2128 for (WikiNode wikiNode : findByGroupId(groupId, QueryUtil.ALL_POS,
2129 QueryUtil.ALL_POS, null)) {
2130 remove(wikiNode);
2131 }
2132 }
2133
2134
2141 public int countByGroupId(long groupId) throws SystemException {
2142 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2143
2144 Object[] finderArgs = new Object[] { groupId };
2145
2146 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2147 this);
2148
2149 if (count == null) {
2150 StringBundler query = new StringBundler(2);
2151
2152 query.append(_SQL_COUNT_WIKINODE_WHERE);
2153
2154 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2155
2156 String sql = query.toString();
2157
2158 Session session = null;
2159
2160 try {
2161 session = openSession();
2162
2163 Query q = session.createQuery(sql);
2164
2165 QueryPos qPos = QueryPos.getInstance(q);
2166
2167 qPos.add(groupId);
2168
2169 count = (Long)q.uniqueResult();
2170
2171 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2172 }
2173 catch (Exception e) {
2174 FinderCacheUtil.removeResult(finderPath, finderArgs);
2175
2176 throw processException(e);
2177 }
2178 finally {
2179 closeSession(session);
2180 }
2181 }
2182
2183 return count.intValue();
2184 }
2185
2186
2193 public int filterCountByGroupId(long groupId) throws SystemException {
2194 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2195 return countByGroupId(groupId);
2196 }
2197
2198 StringBundler query = new StringBundler(2);
2199
2200 query.append(_FILTER_SQL_COUNT_WIKINODE_WHERE);
2201
2202 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2203
2204 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2205 WikiNode.class.getName(),
2206 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2207
2208 Session session = null;
2209
2210 try {
2211 session = openSession();
2212
2213 SQLQuery q = session.createSQLQuery(sql);
2214
2215 q.addScalar(COUNT_COLUMN_NAME,
2216 com.liferay.portal.kernel.dao.orm.Type.LONG);
2217
2218 QueryPos qPos = QueryPos.getInstance(q);
2219
2220 qPos.add(groupId);
2221
2222 Long count = (Long)q.uniqueResult();
2223
2224 return count.intValue();
2225 }
2226 catch (Exception e) {
2227 throw processException(e);
2228 }
2229 finally {
2230 closeSession(session);
2231 }
2232 }
2233
2234 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "wikiNode.groupId = ?";
2235 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2236 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2237 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2238 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2239 new String[] {
2240 Long.class.getName(),
2241
2242 Integer.class.getName(), Integer.class.getName(),
2243 OrderByComparator.class.getName()
2244 });
2245 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2246 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2247 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2248 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2249 new String[] { Long.class.getName() },
2250 WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK |
2251 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
2252 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2253 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2254 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2255 new String[] { Long.class.getName() });
2256
2257
2264 public List<WikiNode> findByCompanyId(long companyId)
2265 throws SystemException {
2266 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2267 null);
2268 }
2269
2270
2283 public List<WikiNode> findByCompanyId(long companyId, int start, int end)
2284 throws SystemException {
2285 return findByCompanyId(companyId, start, end, null);
2286 }
2287
2288
2302 public List<WikiNode> findByCompanyId(long companyId, int start, int end,
2303 OrderByComparator orderByComparator) throws SystemException {
2304 boolean pagination = true;
2305 FinderPath finderPath = null;
2306 Object[] finderArgs = null;
2307
2308 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2309 (orderByComparator == null)) {
2310 pagination = false;
2311 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2312 finderArgs = new Object[] { companyId };
2313 }
2314 else {
2315 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2316 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2317 }
2318
2319 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
2320 finderArgs, this);
2321
2322 if ((list != null) && !list.isEmpty()) {
2323 for (WikiNode wikiNode : list) {
2324 if ((companyId != wikiNode.getCompanyId())) {
2325 list = null;
2326
2327 break;
2328 }
2329 }
2330 }
2331
2332 if (list == null) {
2333 StringBundler query = null;
2334
2335 if (orderByComparator != null) {
2336 query = new StringBundler(3 +
2337 (orderByComparator.getOrderByFields().length * 3));
2338 }
2339 else {
2340 query = new StringBundler(3);
2341 }
2342
2343 query.append(_SQL_SELECT_WIKINODE_WHERE);
2344
2345 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2346
2347 if (orderByComparator != null) {
2348 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2349 orderByComparator);
2350 }
2351 else
2352 if (pagination) {
2353 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2354 }
2355
2356 String sql = query.toString();
2357
2358 Session session = null;
2359
2360 try {
2361 session = openSession();
2362
2363 Query q = session.createQuery(sql);
2364
2365 QueryPos qPos = QueryPos.getInstance(q);
2366
2367 qPos.add(companyId);
2368
2369 if (!pagination) {
2370 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
2371 start, end, false);
2372
2373 Collections.sort(list);
2374
2375 list = new UnmodifiableList<WikiNode>(list);
2376 }
2377 else {
2378 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
2379 start, end);
2380 }
2381
2382 cacheResult(list);
2383
2384 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2385 }
2386 catch (Exception e) {
2387 FinderCacheUtil.removeResult(finderPath, finderArgs);
2388
2389 throw processException(e);
2390 }
2391 finally {
2392 closeSession(session);
2393 }
2394 }
2395
2396 return list;
2397 }
2398
2399
2408 public WikiNode findByCompanyId_First(long companyId,
2409 OrderByComparator orderByComparator)
2410 throws NoSuchNodeException, SystemException {
2411 WikiNode wikiNode = fetchByCompanyId_First(companyId, orderByComparator);
2412
2413 if (wikiNode != null) {
2414 return wikiNode;
2415 }
2416
2417 StringBundler msg = new StringBundler(4);
2418
2419 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2420
2421 msg.append("companyId=");
2422 msg.append(companyId);
2423
2424 msg.append(StringPool.CLOSE_CURLY_BRACE);
2425
2426 throw new NoSuchNodeException(msg.toString());
2427 }
2428
2429
2437 public WikiNode fetchByCompanyId_First(long companyId,
2438 OrderByComparator orderByComparator) throws SystemException {
2439 List<WikiNode> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2440
2441 if (!list.isEmpty()) {
2442 return list.get(0);
2443 }
2444
2445 return null;
2446 }
2447
2448
2457 public WikiNode findByCompanyId_Last(long companyId,
2458 OrderByComparator orderByComparator)
2459 throws NoSuchNodeException, SystemException {
2460 WikiNode wikiNode = fetchByCompanyId_Last(companyId, orderByComparator);
2461
2462 if (wikiNode != null) {
2463 return wikiNode;
2464 }
2465
2466 StringBundler msg = new StringBundler(4);
2467
2468 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2469
2470 msg.append("companyId=");
2471 msg.append(companyId);
2472
2473 msg.append(StringPool.CLOSE_CURLY_BRACE);
2474
2475 throw new NoSuchNodeException(msg.toString());
2476 }
2477
2478
2486 public WikiNode fetchByCompanyId_Last(long companyId,
2487 OrderByComparator orderByComparator) throws SystemException {
2488 int count = countByCompanyId(companyId);
2489
2490 List<WikiNode> list = findByCompanyId(companyId, count - 1, count,
2491 orderByComparator);
2492
2493 if (!list.isEmpty()) {
2494 return list.get(0);
2495 }
2496
2497 return null;
2498 }
2499
2500
2510 public WikiNode[] findByCompanyId_PrevAndNext(long nodeId, long companyId,
2511 OrderByComparator orderByComparator)
2512 throws NoSuchNodeException, SystemException {
2513 WikiNode wikiNode = findByPrimaryKey(nodeId);
2514
2515 Session session = null;
2516
2517 try {
2518 session = openSession();
2519
2520 WikiNode[] array = new WikiNodeImpl[3];
2521
2522 array[0] = getByCompanyId_PrevAndNext(session, wikiNode, companyId,
2523 orderByComparator, true);
2524
2525 array[1] = wikiNode;
2526
2527 array[2] = getByCompanyId_PrevAndNext(session, wikiNode, companyId,
2528 orderByComparator, false);
2529
2530 return array;
2531 }
2532 catch (Exception e) {
2533 throw processException(e);
2534 }
2535 finally {
2536 closeSession(session);
2537 }
2538 }
2539
2540 protected WikiNode getByCompanyId_PrevAndNext(Session session,
2541 WikiNode wikiNode, long companyId, OrderByComparator orderByComparator,
2542 boolean previous) {
2543 StringBundler query = null;
2544
2545 if (orderByComparator != null) {
2546 query = new StringBundler(6 +
2547 (orderByComparator.getOrderByFields().length * 6));
2548 }
2549 else {
2550 query = new StringBundler(3);
2551 }
2552
2553 query.append(_SQL_SELECT_WIKINODE_WHERE);
2554
2555 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2556
2557 if (orderByComparator != null) {
2558 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2559
2560 if (orderByConditionFields.length > 0) {
2561 query.append(WHERE_AND);
2562 }
2563
2564 for (int i = 0; i < orderByConditionFields.length; i++) {
2565 query.append(_ORDER_BY_ENTITY_ALIAS);
2566 query.append(orderByConditionFields[i]);
2567
2568 if ((i + 1) < orderByConditionFields.length) {
2569 if (orderByComparator.isAscending() ^ previous) {
2570 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2571 }
2572 else {
2573 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2574 }
2575 }
2576 else {
2577 if (orderByComparator.isAscending() ^ previous) {
2578 query.append(WHERE_GREATER_THAN);
2579 }
2580 else {
2581 query.append(WHERE_LESSER_THAN);
2582 }
2583 }
2584 }
2585
2586 query.append(ORDER_BY_CLAUSE);
2587
2588 String[] orderByFields = orderByComparator.getOrderByFields();
2589
2590 for (int i = 0; i < orderByFields.length; i++) {
2591 query.append(_ORDER_BY_ENTITY_ALIAS);
2592 query.append(orderByFields[i]);
2593
2594 if ((i + 1) < orderByFields.length) {
2595 if (orderByComparator.isAscending() ^ previous) {
2596 query.append(ORDER_BY_ASC_HAS_NEXT);
2597 }
2598 else {
2599 query.append(ORDER_BY_DESC_HAS_NEXT);
2600 }
2601 }
2602 else {
2603 if (orderByComparator.isAscending() ^ previous) {
2604 query.append(ORDER_BY_ASC);
2605 }
2606 else {
2607 query.append(ORDER_BY_DESC);
2608 }
2609 }
2610 }
2611 }
2612 else {
2613 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2614 }
2615
2616 String sql = query.toString();
2617
2618 Query q = session.createQuery(sql);
2619
2620 q.setFirstResult(0);
2621 q.setMaxResults(2);
2622
2623 QueryPos qPos = QueryPos.getInstance(q);
2624
2625 qPos.add(companyId);
2626
2627 if (orderByComparator != null) {
2628 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
2629
2630 for (Object value : values) {
2631 qPos.add(value);
2632 }
2633 }
2634
2635 List<WikiNode> list = q.list();
2636
2637 if (list.size() == 2) {
2638 return list.get(1);
2639 }
2640 else {
2641 return null;
2642 }
2643 }
2644
2645
2651 public void removeByCompanyId(long companyId) throws SystemException {
2652 for (WikiNode wikiNode : findByCompanyId(companyId, QueryUtil.ALL_POS,
2653 QueryUtil.ALL_POS, null)) {
2654 remove(wikiNode);
2655 }
2656 }
2657
2658
2665 public int countByCompanyId(long companyId) throws SystemException {
2666 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2667
2668 Object[] finderArgs = new Object[] { companyId };
2669
2670 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2671 this);
2672
2673 if (count == null) {
2674 StringBundler query = new StringBundler(2);
2675
2676 query.append(_SQL_COUNT_WIKINODE_WHERE);
2677
2678 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2679
2680 String sql = query.toString();
2681
2682 Session session = null;
2683
2684 try {
2685 session = openSession();
2686
2687 Query q = session.createQuery(sql);
2688
2689 QueryPos qPos = QueryPos.getInstance(q);
2690
2691 qPos.add(companyId);
2692
2693 count = (Long)q.uniqueResult();
2694
2695 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2696 }
2697 catch (Exception e) {
2698 FinderCacheUtil.removeResult(finderPath, finderArgs);
2699
2700 throw processException(e);
2701 }
2702 finally {
2703 closeSession(session);
2704 }
2705 }
2706
2707 return count.intValue();
2708 }
2709
2710 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "wikiNode.companyId = ?";
2711 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2712 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2713 FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
2714 new String[] { Long.class.getName(), String.class.getName() },
2715 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
2716 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
2717 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2718 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2719 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
2720 new String[] { Long.class.getName(), String.class.getName() });
2721
2722
2731 public WikiNode findByG_N(long groupId, String name)
2732 throws NoSuchNodeException, SystemException {
2733 WikiNode wikiNode = fetchByG_N(groupId, name);
2734
2735 if (wikiNode == null) {
2736 StringBundler msg = new StringBundler(6);
2737
2738 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2739
2740 msg.append("groupId=");
2741 msg.append(groupId);
2742
2743 msg.append(", name=");
2744 msg.append(name);
2745
2746 msg.append(StringPool.CLOSE_CURLY_BRACE);
2747
2748 if (_log.isWarnEnabled()) {
2749 _log.warn(msg.toString());
2750 }
2751
2752 throw new NoSuchNodeException(msg.toString());
2753 }
2754
2755 return wikiNode;
2756 }
2757
2758
2766 public WikiNode fetchByG_N(long groupId, String name)
2767 throws SystemException {
2768 return fetchByG_N(groupId, name, true);
2769 }
2770
2771
2780 public WikiNode fetchByG_N(long groupId, String name,
2781 boolean retrieveFromCache) throws SystemException {
2782 Object[] finderArgs = new Object[] { groupId, name };
2783
2784 Object result = null;
2785
2786 if (retrieveFromCache) {
2787 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2788 finderArgs, this);
2789 }
2790
2791 if (result instanceof WikiNode) {
2792 WikiNode wikiNode = (WikiNode)result;
2793
2794 if ((groupId != wikiNode.getGroupId()) ||
2795 !Validator.equals(name, wikiNode.getName())) {
2796 result = null;
2797 }
2798 }
2799
2800 if (result == null) {
2801 StringBundler query = new StringBundler(4);
2802
2803 query.append(_SQL_SELECT_WIKINODE_WHERE);
2804
2805 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2806
2807 if (name == null) {
2808 query.append(_FINDER_COLUMN_G_N_NAME_1);
2809 }
2810 else {
2811 if (name.equals(StringPool.BLANK)) {
2812 query.append(_FINDER_COLUMN_G_N_NAME_3);
2813 }
2814 else {
2815 query.append(_FINDER_COLUMN_G_N_NAME_2);
2816 }
2817 }
2818
2819 String sql = query.toString();
2820
2821 Session session = null;
2822
2823 try {
2824 session = openSession();
2825
2826 Query q = session.createQuery(sql);
2827
2828 QueryPos qPos = QueryPos.getInstance(q);
2829
2830 qPos.add(groupId);
2831
2832 if (name != null) {
2833 qPos.add(name);
2834 }
2835
2836 List<WikiNode> list = q.list();
2837
2838 if (list.isEmpty()) {
2839 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2840 finderArgs, list);
2841 }
2842 else {
2843 WikiNode wikiNode = list.get(0);
2844
2845 result = wikiNode;
2846
2847 cacheResult(wikiNode);
2848
2849 if ((wikiNode.getGroupId() != groupId) ||
2850 (wikiNode.getName() == null) ||
2851 !wikiNode.getName().equals(name)) {
2852 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2853 finderArgs, wikiNode);
2854 }
2855 }
2856 }
2857 catch (Exception e) {
2858 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2859 finderArgs);
2860
2861 throw processException(e);
2862 }
2863 finally {
2864 closeSession(session);
2865 }
2866 }
2867
2868 if (result instanceof List<?>) {
2869 return null;
2870 }
2871 else {
2872 return (WikiNode)result;
2873 }
2874 }
2875
2876
2884 public WikiNode removeByG_N(long groupId, String name)
2885 throws NoSuchNodeException, SystemException {
2886 WikiNode wikiNode = findByG_N(groupId, name);
2887
2888 return remove(wikiNode);
2889 }
2890
2891
2899 public int countByG_N(long groupId, String name) throws SystemException {
2900 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
2901
2902 Object[] finderArgs = new Object[] { groupId, name };
2903
2904 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2905 this);
2906
2907 if (count == null) {
2908 StringBundler query = new StringBundler(3);
2909
2910 query.append(_SQL_COUNT_WIKINODE_WHERE);
2911
2912 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2913
2914 if (name == null) {
2915 query.append(_FINDER_COLUMN_G_N_NAME_1);
2916 }
2917 else {
2918 if (name.equals(StringPool.BLANK)) {
2919 query.append(_FINDER_COLUMN_G_N_NAME_3);
2920 }
2921 else {
2922 query.append(_FINDER_COLUMN_G_N_NAME_2);
2923 }
2924 }
2925
2926 String sql = query.toString();
2927
2928 Session session = null;
2929
2930 try {
2931 session = openSession();
2932
2933 Query q = session.createQuery(sql);
2934
2935 QueryPos qPos = QueryPos.getInstance(q);
2936
2937 qPos.add(groupId);
2938
2939 if (name != null) {
2940 qPos.add(name);
2941 }
2942
2943 count = (Long)q.uniqueResult();
2944
2945 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2946 }
2947 catch (Exception e) {
2948 FinderCacheUtil.removeResult(finderPath, finderArgs);
2949
2950 throw processException(e);
2951 }
2952 finally {
2953 closeSession(session);
2954 }
2955 }
2956
2957 return count.intValue();
2958 }
2959
2960 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "wikiNode.groupId = ? AND ";
2961 private static final String _FINDER_COLUMN_G_N_NAME_1 = "wikiNode.name IS NULL";
2962 private static final String _FINDER_COLUMN_G_N_NAME_2 = "wikiNode.name = ?";
2963 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(wikiNode.name IS NULL OR wikiNode.name = ?)";
2964 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2965 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2966 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
2967 new String[] {
2968 Long.class.getName(), Integer.class.getName(),
2969
2970 Integer.class.getName(), Integer.class.getName(),
2971 OrderByComparator.class.getName()
2972 });
2973 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2974 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2975 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
2976 new String[] { Long.class.getName(), Integer.class.getName() },
2977 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
2978 WikiNodeModelImpl.STATUS_COLUMN_BITMASK |
2979 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
2980 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2981 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2982 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
2983 new String[] { Long.class.getName(), Integer.class.getName() });
2984
2985
2993 public List<WikiNode> findByG_S(long groupId, int status)
2994 throws SystemException {
2995 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2996 null);
2997 }
2998
2999
3013 public List<WikiNode> findByG_S(long groupId, int status, int start, int end)
3014 throws SystemException {
3015 return findByG_S(groupId, status, start, end, null);
3016 }
3017
3018
3033 public List<WikiNode> findByG_S(long groupId, int status, int start,
3034 int end, OrderByComparator orderByComparator) throws SystemException {
3035 boolean pagination = true;
3036 FinderPath finderPath = null;
3037 Object[] finderArgs = null;
3038
3039 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3040 (orderByComparator == null)) {
3041 pagination = false;
3042 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
3043 finderArgs = new Object[] { groupId, status };
3044 }
3045 else {
3046 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
3047 finderArgs = new Object[] {
3048 groupId, status,
3049
3050 start, end, orderByComparator
3051 };
3052 }
3053
3054 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
3055 finderArgs, this);
3056
3057 if ((list != null) && !list.isEmpty()) {
3058 for (WikiNode wikiNode : list) {
3059 if ((groupId != wikiNode.getGroupId()) ||
3060 (status != wikiNode.getStatus())) {
3061 list = null;
3062
3063 break;
3064 }
3065 }
3066 }
3067
3068 if (list == null) {
3069 StringBundler query = null;
3070
3071 if (orderByComparator != null) {
3072 query = new StringBundler(4 +
3073 (orderByComparator.getOrderByFields().length * 3));
3074 }
3075 else {
3076 query = new StringBundler(4);
3077 }
3078
3079 query.append(_SQL_SELECT_WIKINODE_WHERE);
3080
3081 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3082
3083 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3084
3085 if (orderByComparator != null) {
3086 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3087 orderByComparator);
3088 }
3089 else
3090 if (pagination) {
3091 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3092 }
3093
3094 String sql = query.toString();
3095
3096 Session session = null;
3097
3098 try {
3099 session = openSession();
3100
3101 Query q = session.createQuery(sql);
3102
3103 QueryPos qPos = QueryPos.getInstance(q);
3104
3105 qPos.add(groupId);
3106
3107 qPos.add(status);
3108
3109 if (!pagination) {
3110 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
3111 start, end, false);
3112
3113 Collections.sort(list);
3114
3115 list = new UnmodifiableList<WikiNode>(list);
3116 }
3117 else {
3118 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
3119 start, end);
3120 }
3121
3122 cacheResult(list);
3123
3124 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3125 }
3126 catch (Exception e) {
3127 FinderCacheUtil.removeResult(finderPath, finderArgs);
3128
3129 throw processException(e);
3130 }
3131 finally {
3132 closeSession(session);
3133 }
3134 }
3135
3136 return list;
3137 }
3138
3139
3149 public WikiNode findByG_S_First(long groupId, int status,
3150 OrderByComparator orderByComparator)
3151 throws NoSuchNodeException, SystemException {
3152 WikiNode wikiNode = fetchByG_S_First(groupId, status, orderByComparator);
3153
3154 if (wikiNode != null) {
3155 return wikiNode;
3156 }
3157
3158 StringBundler msg = new StringBundler(6);
3159
3160 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3161
3162 msg.append("groupId=");
3163 msg.append(groupId);
3164
3165 msg.append(", status=");
3166 msg.append(status);
3167
3168 msg.append(StringPool.CLOSE_CURLY_BRACE);
3169
3170 throw new NoSuchNodeException(msg.toString());
3171 }
3172
3173
3182 public WikiNode fetchByG_S_First(long groupId, int status,
3183 OrderByComparator orderByComparator) throws SystemException {
3184 List<WikiNode> list = findByG_S(groupId, status, 0, 1, orderByComparator);
3185
3186 if (!list.isEmpty()) {
3187 return list.get(0);
3188 }
3189
3190 return null;
3191 }
3192
3193
3203 public WikiNode findByG_S_Last(long groupId, int status,
3204 OrderByComparator orderByComparator)
3205 throws NoSuchNodeException, SystemException {
3206 WikiNode wikiNode = fetchByG_S_Last(groupId, status, orderByComparator);
3207
3208 if (wikiNode != null) {
3209 return wikiNode;
3210 }
3211
3212 StringBundler msg = new StringBundler(6);
3213
3214 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3215
3216 msg.append("groupId=");
3217 msg.append(groupId);
3218
3219 msg.append(", status=");
3220 msg.append(status);
3221
3222 msg.append(StringPool.CLOSE_CURLY_BRACE);
3223
3224 throw new NoSuchNodeException(msg.toString());
3225 }
3226
3227
3236 public WikiNode fetchByG_S_Last(long groupId, int status,
3237 OrderByComparator orderByComparator) throws SystemException {
3238 int count = countByG_S(groupId, status);
3239
3240 List<WikiNode> list = findByG_S(groupId, status, count - 1, count,
3241 orderByComparator);
3242
3243 if (!list.isEmpty()) {
3244 return list.get(0);
3245 }
3246
3247 return null;
3248 }
3249
3250
3261 public WikiNode[] findByG_S_PrevAndNext(long nodeId, long groupId,
3262 int status, OrderByComparator orderByComparator)
3263 throws NoSuchNodeException, SystemException {
3264 WikiNode wikiNode = findByPrimaryKey(nodeId);
3265
3266 Session session = null;
3267
3268 try {
3269 session = openSession();
3270
3271 WikiNode[] array = new WikiNodeImpl[3];
3272
3273 array[0] = getByG_S_PrevAndNext(session, wikiNode, groupId, status,
3274 orderByComparator, true);
3275
3276 array[1] = wikiNode;
3277
3278 array[2] = getByG_S_PrevAndNext(session, wikiNode, groupId, status,
3279 orderByComparator, false);
3280
3281 return array;
3282 }
3283 catch (Exception e) {
3284 throw processException(e);
3285 }
3286 finally {
3287 closeSession(session);
3288 }
3289 }
3290
3291 protected WikiNode getByG_S_PrevAndNext(Session session, WikiNode wikiNode,
3292 long groupId, int status, OrderByComparator orderByComparator,
3293 boolean previous) {
3294 StringBundler query = null;
3295
3296 if (orderByComparator != null) {
3297 query = new StringBundler(6 +
3298 (orderByComparator.getOrderByFields().length * 6));
3299 }
3300 else {
3301 query = new StringBundler(3);
3302 }
3303
3304 query.append(_SQL_SELECT_WIKINODE_WHERE);
3305
3306 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3307
3308 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3309
3310 if (orderByComparator != null) {
3311 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3312
3313 if (orderByConditionFields.length > 0) {
3314 query.append(WHERE_AND);
3315 }
3316
3317 for (int i = 0; i < orderByConditionFields.length; i++) {
3318 query.append(_ORDER_BY_ENTITY_ALIAS);
3319 query.append(orderByConditionFields[i]);
3320
3321 if ((i + 1) < orderByConditionFields.length) {
3322 if (orderByComparator.isAscending() ^ previous) {
3323 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3324 }
3325 else {
3326 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3327 }
3328 }
3329 else {
3330 if (orderByComparator.isAscending() ^ previous) {
3331 query.append(WHERE_GREATER_THAN);
3332 }
3333 else {
3334 query.append(WHERE_LESSER_THAN);
3335 }
3336 }
3337 }
3338
3339 query.append(ORDER_BY_CLAUSE);
3340
3341 String[] orderByFields = orderByComparator.getOrderByFields();
3342
3343 for (int i = 0; i < orderByFields.length; i++) {
3344 query.append(_ORDER_BY_ENTITY_ALIAS);
3345 query.append(orderByFields[i]);
3346
3347 if ((i + 1) < orderByFields.length) {
3348 if (orderByComparator.isAscending() ^ previous) {
3349 query.append(ORDER_BY_ASC_HAS_NEXT);
3350 }
3351 else {
3352 query.append(ORDER_BY_DESC_HAS_NEXT);
3353 }
3354 }
3355 else {
3356 if (orderByComparator.isAscending() ^ previous) {
3357 query.append(ORDER_BY_ASC);
3358 }
3359 else {
3360 query.append(ORDER_BY_DESC);
3361 }
3362 }
3363 }
3364 }
3365 else {
3366 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3367 }
3368
3369 String sql = query.toString();
3370
3371 Query q = session.createQuery(sql);
3372
3373 q.setFirstResult(0);
3374 q.setMaxResults(2);
3375
3376 QueryPos qPos = QueryPos.getInstance(q);
3377
3378 qPos.add(groupId);
3379
3380 qPos.add(status);
3381
3382 if (orderByComparator != null) {
3383 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
3384
3385 for (Object value : values) {
3386 qPos.add(value);
3387 }
3388 }
3389
3390 List<WikiNode> list = q.list();
3391
3392 if (list.size() == 2) {
3393 return list.get(1);
3394 }
3395 else {
3396 return null;
3397 }
3398 }
3399
3400
3408 public List<WikiNode> filterFindByG_S(long groupId, int status)
3409 throws SystemException {
3410 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
3411 QueryUtil.ALL_POS, null);
3412 }
3413
3414
3428 public List<WikiNode> filterFindByG_S(long groupId, int status, int start,
3429 int end) throws SystemException {
3430 return filterFindByG_S(groupId, status, start, end, null);
3431 }
3432
3433
3448 public List<WikiNode> filterFindByG_S(long groupId, int status, int start,
3449 int end, OrderByComparator orderByComparator) throws SystemException {
3450 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3451 return findByG_S(groupId, status, start, end, orderByComparator);
3452 }
3453
3454 StringBundler query = null;
3455
3456 if (orderByComparator != null) {
3457 query = new StringBundler(4 +
3458 (orderByComparator.getOrderByFields().length * 3));
3459 }
3460 else {
3461 query = new StringBundler(4);
3462 }
3463
3464 if (getDB().isSupportsInlineDistinct()) {
3465 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
3466 }
3467 else {
3468 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
3469 }
3470
3471 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3472
3473 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3474
3475 if (!getDB().isSupportsInlineDistinct()) {
3476 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
3477 }
3478
3479 if (orderByComparator != null) {
3480 if (getDB().isSupportsInlineDistinct()) {
3481 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3482 orderByComparator);
3483 }
3484 else {
3485 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3486 orderByComparator);
3487 }
3488 }
3489 else {
3490 if (getDB().isSupportsInlineDistinct()) {
3491 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3492 }
3493 else {
3494 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
3495 }
3496 }
3497
3498 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3499 WikiNode.class.getName(),
3500 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3501
3502 Session session = null;
3503
3504 try {
3505 session = openSession();
3506
3507 SQLQuery q = session.createSQLQuery(sql);
3508
3509 if (getDB().isSupportsInlineDistinct()) {
3510 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
3511 }
3512 else {
3513 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
3514 }
3515
3516 QueryPos qPos = QueryPos.getInstance(q);
3517
3518 qPos.add(groupId);
3519
3520 qPos.add(status);
3521
3522 return (List<WikiNode>)QueryUtil.list(q, getDialect(), start, end);
3523 }
3524 catch (Exception e) {
3525 throw processException(e);
3526 }
3527 finally {
3528 closeSession(session);
3529 }
3530 }
3531
3532
3543 public WikiNode[] filterFindByG_S_PrevAndNext(long nodeId, long groupId,
3544 int status, OrderByComparator orderByComparator)
3545 throws NoSuchNodeException, SystemException {
3546 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3547 return findByG_S_PrevAndNext(nodeId, groupId, status,
3548 orderByComparator);
3549 }
3550
3551 WikiNode wikiNode = findByPrimaryKey(nodeId);
3552
3553 Session session = null;
3554
3555 try {
3556 session = openSession();
3557
3558 WikiNode[] array = new WikiNodeImpl[3];
3559
3560 array[0] = filterGetByG_S_PrevAndNext(session, wikiNode, groupId,
3561 status, orderByComparator, true);
3562
3563 array[1] = wikiNode;
3564
3565 array[2] = filterGetByG_S_PrevAndNext(session, wikiNode, groupId,
3566 status, orderByComparator, false);
3567
3568 return array;
3569 }
3570 catch (Exception e) {
3571 throw processException(e);
3572 }
3573 finally {
3574 closeSession(session);
3575 }
3576 }
3577
3578 protected WikiNode filterGetByG_S_PrevAndNext(Session session,
3579 WikiNode wikiNode, long groupId, int status,
3580 OrderByComparator orderByComparator, boolean previous) {
3581 StringBundler query = null;
3582
3583 if (orderByComparator != null) {
3584 query = new StringBundler(6 +
3585 (orderByComparator.getOrderByFields().length * 6));
3586 }
3587 else {
3588 query = new StringBundler(3);
3589 }
3590
3591 if (getDB().isSupportsInlineDistinct()) {
3592 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
3593 }
3594 else {
3595 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
3596 }
3597
3598 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3599
3600 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3601
3602 if (!getDB().isSupportsInlineDistinct()) {
3603 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
3604 }
3605
3606 if (orderByComparator != null) {
3607 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3608
3609 if (orderByConditionFields.length > 0) {
3610 query.append(WHERE_AND);
3611 }
3612
3613 for (int i = 0; i < orderByConditionFields.length; i++) {
3614 if (getDB().isSupportsInlineDistinct()) {
3615 query.append(_ORDER_BY_ENTITY_ALIAS);
3616 }
3617 else {
3618 query.append(_ORDER_BY_ENTITY_TABLE);
3619 }
3620
3621 query.append(orderByConditionFields[i]);
3622
3623 if ((i + 1) < orderByConditionFields.length) {
3624 if (orderByComparator.isAscending() ^ previous) {
3625 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3626 }
3627 else {
3628 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3629 }
3630 }
3631 else {
3632 if (orderByComparator.isAscending() ^ previous) {
3633 query.append(WHERE_GREATER_THAN);
3634 }
3635 else {
3636 query.append(WHERE_LESSER_THAN);
3637 }
3638 }
3639 }
3640
3641 query.append(ORDER_BY_CLAUSE);
3642
3643 String[] orderByFields = orderByComparator.getOrderByFields();
3644
3645 for (int i = 0; i < orderByFields.length; i++) {
3646 if (getDB().isSupportsInlineDistinct()) {
3647 query.append(_ORDER_BY_ENTITY_ALIAS);
3648 }
3649 else {
3650 query.append(_ORDER_BY_ENTITY_TABLE);
3651 }
3652
3653 query.append(orderByFields[i]);
3654
3655 if ((i + 1) < orderByFields.length) {
3656 if (orderByComparator.isAscending() ^ previous) {
3657 query.append(ORDER_BY_ASC_HAS_NEXT);
3658 }
3659 else {
3660 query.append(ORDER_BY_DESC_HAS_NEXT);
3661 }
3662 }
3663 else {
3664 if (orderByComparator.isAscending() ^ previous) {
3665 query.append(ORDER_BY_ASC);
3666 }
3667 else {
3668 query.append(ORDER_BY_DESC);
3669 }
3670 }
3671 }
3672 }
3673 else {
3674 if (getDB().isSupportsInlineDistinct()) {
3675 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3676 }
3677 else {
3678 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
3679 }
3680 }
3681
3682 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3683 WikiNode.class.getName(),
3684 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3685
3686 SQLQuery q = session.createSQLQuery(sql);
3687
3688 q.setFirstResult(0);
3689 q.setMaxResults(2);
3690
3691 if (getDB().isSupportsInlineDistinct()) {
3692 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
3693 }
3694 else {
3695 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
3696 }
3697
3698 QueryPos qPos = QueryPos.getInstance(q);
3699
3700 qPos.add(groupId);
3701
3702 qPos.add(status);
3703
3704 if (orderByComparator != null) {
3705 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
3706
3707 for (Object value : values) {
3708 qPos.add(value);
3709 }
3710 }
3711
3712 List<WikiNode> list = q.list();
3713
3714 if (list.size() == 2) {
3715 return list.get(1);
3716 }
3717 else {
3718 return null;
3719 }
3720 }
3721
3722
3729 public void removeByG_S(long groupId, int status) throws SystemException {
3730 for (WikiNode wikiNode : findByG_S(groupId, status, QueryUtil.ALL_POS,
3731 QueryUtil.ALL_POS, null)) {
3732 remove(wikiNode);
3733 }
3734 }
3735
3736
3744 public int countByG_S(long groupId, int status) throws SystemException {
3745 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
3746
3747 Object[] finderArgs = new Object[] { groupId, status };
3748
3749 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3750 this);
3751
3752 if (count == null) {
3753 StringBundler query = new StringBundler(3);
3754
3755 query.append(_SQL_COUNT_WIKINODE_WHERE);
3756
3757 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3758
3759 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3760
3761 String sql = query.toString();
3762
3763 Session session = null;
3764
3765 try {
3766 session = openSession();
3767
3768 Query q = session.createQuery(sql);
3769
3770 QueryPos qPos = QueryPos.getInstance(q);
3771
3772 qPos.add(groupId);
3773
3774 qPos.add(status);
3775
3776 count = (Long)q.uniqueResult();
3777
3778 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3779 }
3780 catch (Exception e) {
3781 FinderCacheUtil.removeResult(finderPath, finderArgs);
3782
3783 throw processException(e);
3784 }
3785 finally {
3786 closeSession(session);
3787 }
3788 }
3789
3790 return count.intValue();
3791 }
3792
3793
3801 public int filterCountByG_S(long groupId, int status)
3802 throws SystemException {
3803 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3804 return countByG_S(groupId, status);
3805 }
3806
3807 StringBundler query = new StringBundler(3);
3808
3809 query.append(_FILTER_SQL_COUNT_WIKINODE_WHERE);
3810
3811 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3812
3813 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3814
3815 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3816 WikiNode.class.getName(),
3817 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3818
3819 Session session = null;
3820
3821 try {
3822 session = openSession();
3823
3824 SQLQuery q = session.createSQLQuery(sql);
3825
3826 q.addScalar(COUNT_COLUMN_NAME,
3827 com.liferay.portal.kernel.dao.orm.Type.LONG);
3828
3829 QueryPos qPos = QueryPos.getInstance(q);
3830
3831 qPos.add(groupId);
3832
3833 qPos.add(status);
3834
3835 Long count = (Long)q.uniqueResult();
3836
3837 return count.intValue();
3838 }
3839 catch (Exception e) {
3840 throw processException(e);
3841 }
3842 finally {
3843 closeSession(session);
3844 }
3845 }
3846
3847 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "wikiNode.groupId = ? AND ";
3848 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "wikiNode.status = ?";
3849 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
3850 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
3851 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
3852 new String[] {
3853 Long.class.getName(), Integer.class.getName(),
3854
3855 Integer.class.getName(), Integer.class.getName(),
3856 OrderByComparator.class.getName()
3857 });
3858 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
3859 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
3860 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
3861 new String[] { Long.class.getName(), Integer.class.getName() },
3862 WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK |
3863 WikiNodeModelImpl.STATUS_COLUMN_BITMASK |
3864 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
3865 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
3866 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
3867 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
3868 new String[] { Long.class.getName(), Integer.class.getName() });
3869
3870
3878 public List<WikiNode> findByC_S(long companyId, int status)
3879 throws SystemException {
3880 return findByC_S(companyId, status, QueryUtil.ALL_POS,
3881 QueryUtil.ALL_POS, null);
3882 }
3883
3884
3898 public List<WikiNode> findByC_S(long companyId, int status, int start,
3899 int end) throws SystemException {
3900 return findByC_S(companyId, status, start, end, null);
3901 }
3902
3903
3918 public List<WikiNode> findByC_S(long companyId, int status, int start,
3919 int end, OrderByComparator orderByComparator) throws SystemException {
3920 boolean pagination = true;
3921 FinderPath finderPath = null;
3922 Object[] finderArgs = null;
3923
3924 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3925 (orderByComparator == null)) {
3926 pagination = false;
3927 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
3928 finderArgs = new Object[] { companyId, status };
3929 }
3930 else {
3931 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
3932 finderArgs = new Object[] {
3933 companyId, status,
3934
3935 start, end, orderByComparator
3936 };
3937 }
3938
3939 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
3940 finderArgs, this);
3941
3942 if ((list != null) && !list.isEmpty()) {
3943 for (WikiNode wikiNode : list) {
3944 if ((companyId != wikiNode.getCompanyId()) ||
3945 (status != wikiNode.getStatus())) {
3946 list = null;
3947
3948 break;
3949 }
3950 }
3951 }
3952
3953 if (list == null) {
3954 StringBundler query = null;
3955
3956 if (orderByComparator != null) {
3957 query = new StringBundler(4 +
3958 (orderByComparator.getOrderByFields().length * 3));
3959 }
3960 else {
3961 query = new StringBundler(4);
3962 }
3963
3964 query.append(_SQL_SELECT_WIKINODE_WHERE);
3965
3966 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3967
3968 query.append(_FINDER_COLUMN_C_S_STATUS_2);
3969
3970 if (orderByComparator != null) {
3971 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3972 orderByComparator);
3973 }
3974 else
3975 if (pagination) {
3976 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3977 }
3978
3979 String sql = query.toString();
3980
3981 Session session = null;
3982
3983 try {
3984 session = openSession();
3985
3986 Query q = session.createQuery(sql);
3987
3988 QueryPos qPos = QueryPos.getInstance(q);
3989
3990 qPos.add(companyId);
3991
3992 qPos.add(status);
3993
3994 if (!pagination) {
3995 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
3996 start, end, false);
3997
3998 Collections.sort(list);
3999
4000 list = new UnmodifiableList<WikiNode>(list);
4001 }
4002 else {
4003 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
4004 start, end);
4005 }
4006
4007 cacheResult(list);
4008
4009 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4010 }
4011 catch (Exception e) {
4012 FinderCacheUtil.removeResult(finderPath, finderArgs);
4013
4014 throw processException(e);
4015 }
4016 finally {
4017 closeSession(session);
4018 }
4019 }
4020
4021 return list;
4022 }
4023
4024
4034 public WikiNode findByC_S_First(long companyId, int status,
4035 OrderByComparator orderByComparator)
4036 throws NoSuchNodeException, SystemException {
4037 WikiNode wikiNode = fetchByC_S_First(companyId, status,
4038 orderByComparator);
4039
4040 if (wikiNode != null) {
4041 return wikiNode;
4042 }
4043
4044 StringBundler msg = new StringBundler(6);
4045
4046 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4047
4048 msg.append("companyId=");
4049 msg.append(companyId);
4050
4051 msg.append(", status=");
4052 msg.append(status);
4053
4054 msg.append(StringPool.CLOSE_CURLY_BRACE);
4055
4056 throw new NoSuchNodeException(msg.toString());
4057 }
4058
4059
4068 public WikiNode fetchByC_S_First(long companyId, int status,
4069 OrderByComparator orderByComparator) throws SystemException {
4070 List<WikiNode> list = findByC_S(companyId, status, 0, 1,
4071 orderByComparator);
4072
4073 if (!list.isEmpty()) {
4074 return list.get(0);
4075 }
4076
4077 return null;
4078 }
4079
4080
4090 public WikiNode findByC_S_Last(long companyId, int status,
4091 OrderByComparator orderByComparator)
4092 throws NoSuchNodeException, SystemException {
4093 WikiNode wikiNode = fetchByC_S_Last(companyId, status, orderByComparator);
4094
4095 if (wikiNode != null) {
4096 return wikiNode;
4097 }
4098
4099 StringBundler msg = new StringBundler(6);
4100
4101 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4102
4103 msg.append("companyId=");
4104 msg.append(companyId);
4105
4106 msg.append(", status=");
4107 msg.append(status);
4108
4109 msg.append(StringPool.CLOSE_CURLY_BRACE);
4110
4111 throw new NoSuchNodeException(msg.toString());
4112 }
4113
4114
4123 public WikiNode fetchByC_S_Last(long companyId, int status,
4124 OrderByComparator orderByComparator) throws SystemException {
4125 int count = countByC_S(companyId, status);
4126
4127 List<WikiNode> list = findByC_S(companyId, status, count - 1, count,
4128 orderByComparator);
4129
4130 if (!list.isEmpty()) {
4131 return list.get(0);
4132 }
4133
4134 return null;
4135 }
4136
4137
4148 public WikiNode[] findByC_S_PrevAndNext(long nodeId, long companyId,
4149 int status, OrderByComparator orderByComparator)
4150 throws NoSuchNodeException, SystemException {
4151 WikiNode wikiNode = findByPrimaryKey(nodeId);
4152
4153 Session session = null;
4154
4155 try {
4156 session = openSession();
4157
4158 WikiNode[] array = new WikiNodeImpl[3];
4159
4160 array[0] = getByC_S_PrevAndNext(session, wikiNode, companyId,
4161 status, orderByComparator, true);
4162
4163 array[1] = wikiNode;
4164
4165 array[2] = getByC_S_PrevAndNext(session, wikiNode, companyId,
4166 status, orderByComparator, false);
4167
4168 return array;
4169 }
4170 catch (Exception e) {
4171 throw processException(e);
4172 }
4173 finally {
4174 closeSession(session);
4175 }
4176 }
4177
4178 protected WikiNode getByC_S_PrevAndNext(Session session, WikiNode wikiNode,
4179 long companyId, int status, OrderByComparator orderByComparator,
4180 boolean previous) {
4181 StringBundler query = null;
4182
4183 if (orderByComparator != null) {
4184 query = new StringBundler(6 +
4185 (orderByComparator.getOrderByFields().length * 6));
4186 }
4187 else {
4188 query = new StringBundler(3);
4189 }
4190
4191 query.append(_SQL_SELECT_WIKINODE_WHERE);
4192
4193 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4194
4195 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4196
4197 if (orderByComparator != null) {
4198 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4199
4200 if (orderByConditionFields.length > 0) {
4201 query.append(WHERE_AND);
4202 }
4203
4204 for (int i = 0; i < orderByConditionFields.length; i++) {
4205 query.append(_ORDER_BY_ENTITY_ALIAS);
4206 query.append(orderByConditionFields[i]);
4207
4208 if ((i + 1) < orderByConditionFields.length) {
4209 if (orderByComparator.isAscending() ^ previous) {
4210 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4211 }
4212 else {
4213 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4214 }
4215 }
4216 else {
4217 if (orderByComparator.isAscending() ^ previous) {
4218 query.append(WHERE_GREATER_THAN);
4219 }
4220 else {
4221 query.append(WHERE_LESSER_THAN);
4222 }
4223 }
4224 }
4225
4226 query.append(ORDER_BY_CLAUSE);
4227
4228 String[] orderByFields = orderByComparator.getOrderByFields();
4229
4230 for (int i = 0; i < orderByFields.length; i++) {
4231 query.append(_ORDER_BY_ENTITY_ALIAS);
4232 query.append(orderByFields[i]);
4233
4234 if ((i + 1) < orderByFields.length) {
4235 if (orderByComparator.isAscending() ^ previous) {
4236 query.append(ORDER_BY_ASC_HAS_NEXT);
4237 }
4238 else {
4239 query.append(ORDER_BY_DESC_HAS_NEXT);
4240 }
4241 }
4242 else {
4243 if (orderByComparator.isAscending() ^ previous) {
4244 query.append(ORDER_BY_ASC);
4245 }
4246 else {
4247 query.append(ORDER_BY_DESC);
4248 }
4249 }
4250 }
4251 }
4252 else {
4253 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
4254 }
4255
4256 String sql = query.toString();
4257
4258 Query q = session.createQuery(sql);
4259
4260 q.setFirstResult(0);
4261 q.setMaxResults(2);
4262
4263 QueryPos qPos = QueryPos.getInstance(q);
4264
4265 qPos.add(companyId);
4266
4267 qPos.add(status);
4268
4269 if (orderByComparator != null) {
4270 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
4271
4272 for (Object value : values) {
4273 qPos.add(value);
4274 }
4275 }
4276
4277 List<WikiNode> list = q.list();
4278
4279 if (list.size() == 2) {
4280 return list.get(1);
4281 }
4282 else {
4283 return null;
4284 }
4285 }
4286
4287
4294 public void removeByC_S(long companyId, int status)
4295 throws SystemException {
4296 for (WikiNode wikiNode : findByC_S(companyId, status,
4297 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4298 remove(wikiNode);
4299 }
4300 }
4301
4302
4310 public int countByC_S(long companyId, int status) throws SystemException {
4311 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
4312
4313 Object[] finderArgs = new Object[] { companyId, status };
4314
4315 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4316 this);
4317
4318 if (count == null) {
4319 StringBundler query = new StringBundler(3);
4320
4321 query.append(_SQL_COUNT_WIKINODE_WHERE);
4322
4323 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4324
4325 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4326
4327 String sql = query.toString();
4328
4329 Session session = null;
4330
4331 try {
4332 session = openSession();
4333
4334 Query q = session.createQuery(sql);
4335
4336 QueryPos qPos = QueryPos.getInstance(q);
4337
4338 qPos.add(companyId);
4339
4340 qPos.add(status);
4341
4342 count = (Long)q.uniqueResult();
4343
4344 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4345 }
4346 catch (Exception e) {
4347 FinderCacheUtil.removeResult(finderPath, finderArgs);
4348
4349 throw processException(e);
4350 }
4351 finally {
4352 closeSession(session);
4353 }
4354 }
4355
4356 return count.intValue();
4357 }
4358
4359 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "wikiNode.companyId = ? AND ";
4360 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "wikiNode.status = ?";
4361
4362
4367 public void cacheResult(WikiNode wikiNode) {
4368 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4369 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
4370
4371 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
4372 new Object[] { wikiNode.getUuid(), Long.valueOf(
4373 wikiNode.getGroupId()) }, wikiNode);
4374
4375 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
4376 new Object[] { Long.valueOf(wikiNode.getGroupId()), wikiNode.getName() },
4377 wikiNode);
4378
4379 wikiNode.resetOriginalValues();
4380 }
4381
4382
4387 public void cacheResult(List<WikiNode> wikiNodes) {
4388 for (WikiNode wikiNode : wikiNodes) {
4389 if (EntityCacheUtil.getResult(
4390 WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4391 WikiNodeImpl.class, wikiNode.getPrimaryKey()) == null) {
4392 cacheResult(wikiNode);
4393 }
4394 else {
4395 wikiNode.resetOriginalValues();
4396 }
4397 }
4398 }
4399
4400
4407 @Override
4408 public void clearCache() {
4409 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4410 CacheRegistryUtil.clear(WikiNodeImpl.class.getName());
4411 }
4412
4413 EntityCacheUtil.clearCache(WikiNodeImpl.class.getName());
4414
4415 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4416 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4417 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4418 }
4419
4420
4427 @Override
4428 public void clearCache(WikiNode wikiNode) {
4429 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4430 WikiNodeImpl.class, wikiNode.getPrimaryKey());
4431
4432 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4433 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4434
4435 clearUniqueFindersCache(wikiNode);
4436 }
4437
4438 @Override
4439 public void clearCache(List<WikiNode> wikiNodes) {
4440 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4441 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4442
4443 for (WikiNode wikiNode : wikiNodes) {
4444 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4445 WikiNodeImpl.class, wikiNode.getPrimaryKey());
4446
4447 clearUniqueFindersCache(wikiNode);
4448 }
4449 }
4450
4451 protected void cacheUniqueFindersCache(WikiNode wikiNode) {
4452 if (wikiNode.isNew()) {
4453 Object[] args = new Object[] {
4454 wikiNode.getUuid(), Long.valueOf(wikiNode.getGroupId())
4455 };
4456
4457 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
4458 Long.valueOf(1));
4459 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
4460 wikiNode);
4461
4462 args = new Object[] {
4463 Long.valueOf(wikiNode.getGroupId()),
4464
4465 wikiNode.getName()
4466 };
4467
4468 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
4469 Long.valueOf(1));
4470 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args, wikiNode);
4471 }
4472 else {
4473 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
4474
4475 if ((wikiNodeModelImpl.getColumnBitmask() &
4476 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
4477 Object[] args = new Object[] {
4478 wikiNode.getUuid(), Long.valueOf(wikiNode.getGroupId())
4479 };
4480
4481 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
4482 Long.valueOf(1));
4483 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
4484 wikiNode);
4485 }
4486
4487 if ((wikiNodeModelImpl.getColumnBitmask() &
4488 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
4489 Object[] args = new Object[] {
4490 Long.valueOf(wikiNode.getGroupId()),
4491
4492 wikiNode.getName()
4493 };
4494
4495 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
4496 Long.valueOf(1));
4497 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
4498 wikiNode);
4499 }
4500 }
4501 }
4502
4503 protected void clearUniqueFindersCache(WikiNode wikiNode) {
4504 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
4505
4506 Object[] args = new Object[] {
4507 wikiNode.getUuid(), Long.valueOf(wikiNode.getGroupId())
4508 };
4509
4510 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
4511 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
4512
4513 if ((wikiNodeModelImpl.getColumnBitmask() &
4514 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
4515 args = new Object[] {
4516 wikiNodeModelImpl.getOriginalUuid(),
4517 Long.valueOf(wikiNodeModelImpl.getOriginalGroupId())
4518 };
4519
4520 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
4521 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
4522 }
4523
4524 args = new Object[] {
4525 Long.valueOf(wikiNode.getGroupId()),
4526
4527 wikiNode.getName()
4528 };
4529
4530 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
4531 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
4532
4533 if ((wikiNodeModelImpl.getColumnBitmask() &
4534 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
4535 args = new Object[] {
4536 Long.valueOf(wikiNodeModelImpl.getOriginalGroupId()),
4537
4538 wikiNodeModelImpl.getOriginalName()
4539 };
4540
4541 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
4542 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
4543 }
4544 }
4545
4546
4552 public WikiNode create(long nodeId) {
4553 WikiNode wikiNode = new WikiNodeImpl();
4554
4555 wikiNode.setNew(true);
4556 wikiNode.setPrimaryKey(nodeId);
4557
4558 String uuid = PortalUUIDUtil.generate();
4559
4560 wikiNode.setUuid(uuid);
4561
4562 return wikiNode;
4563 }
4564
4565
4573 public WikiNode remove(long nodeId)
4574 throws NoSuchNodeException, SystemException {
4575 return remove(Long.valueOf(nodeId));
4576 }
4577
4578
4586 @Override
4587 public WikiNode remove(Serializable primaryKey)
4588 throws NoSuchNodeException, SystemException {
4589 Session session = null;
4590
4591 try {
4592 session = openSession();
4593
4594 WikiNode wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
4595 primaryKey);
4596
4597 if (wikiNode == null) {
4598 if (_log.isWarnEnabled()) {
4599 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4600 }
4601
4602 throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4603 primaryKey);
4604 }
4605
4606 return remove(wikiNode);
4607 }
4608 catch (NoSuchNodeException nsee) {
4609 throw nsee;
4610 }
4611 catch (Exception e) {
4612 throw processException(e);
4613 }
4614 finally {
4615 closeSession(session);
4616 }
4617 }
4618
4619 @Override
4620 protected WikiNode removeImpl(WikiNode wikiNode) throws SystemException {
4621 wikiNode = toUnwrappedModel(wikiNode);
4622
4623 Session session = null;
4624
4625 try {
4626 session = openSession();
4627
4628 if (!session.contains(wikiNode)) {
4629 wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
4630 wikiNode.getPrimaryKeyObj());
4631 }
4632
4633 if (wikiNode != null) {
4634 session.delete(wikiNode);
4635 }
4636 }
4637 catch (Exception e) {
4638 throw processException(e);
4639 }
4640 finally {
4641 closeSession(session);
4642 }
4643
4644 if (wikiNode != null) {
4645 clearCache(wikiNode);
4646 }
4647
4648 return wikiNode;
4649 }
4650
4651 @Override
4652 public WikiNode updateImpl(com.liferay.portlet.wiki.model.WikiNode wikiNode)
4653 throws SystemException {
4654 wikiNode = toUnwrappedModel(wikiNode);
4655
4656 boolean isNew = wikiNode.isNew();
4657
4658 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
4659
4660 if (Validator.isNull(wikiNode.getUuid())) {
4661 String uuid = PortalUUIDUtil.generate();
4662
4663 wikiNode.setUuid(uuid);
4664 }
4665
4666 Session session = null;
4667
4668 try {
4669 session = openSession();
4670
4671 if (wikiNode.isNew()) {
4672 session.save(wikiNode);
4673
4674 wikiNode.setNew(false);
4675 }
4676 else {
4677 session.merge(wikiNode);
4678 }
4679 }
4680 catch (Exception e) {
4681 throw processException(e);
4682 }
4683 finally {
4684 closeSession(session);
4685 }
4686
4687 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4688
4689 if (isNew || !WikiNodeModelImpl.COLUMN_BITMASK_ENABLED) {
4690 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4691 }
4692
4693 else {
4694 if ((wikiNodeModelImpl.getColumnBitmask() &
4695 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
4696 Object[] args = new Object[] { wikiNodeModelImpl.getOriginalUuid() };
4697
4698 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4699 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4700 args);
4701
4702 args = new Object[] { wikiNodeModelImpl.getUuid() };
4703
4704 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4705 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4706 args);
4707 }
4708
4709 if ((wikiNodeModelImpl.getColumnBitmask() &
4710 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
4711 Object[] args = new Object[] {
4712 wikiNodeModelImpl.getOriginalUuid(),
4713 Long.valueOf(wikiNodeModelImpl.getOriginalCompanyId())
4714 };
4715
4716 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4717 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4718 args);
4719
4720 args = new Object[] {
4721 wikiNodeModelImpl.getUuid(),
4722 Long.valueOf(wikiNodeModelImpl.getCompanyId())
4723 };
4724
4725 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4726 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4727 args);
4728 }
4729
4730 if ((wikiNodeModelImpl.getColumnBitmask() &
4731 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
4732 Object[] args = new Object[] {
4733 Long.valueOf(wikiNodeModelImpl.getOriginalGroupId())
4734 };
4735
4736 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
4737 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
4738 args);
4739
4740 args = new Object[] { Long.valueOf(wikiNodeModelImpl.getGroupId()) };
4741
4742 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
4743 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
4744 args);
4745 }
4746
4747 if ((wikiNodeModelImpl.getColumnBitmask() &
4748 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
4749 Object[] args = new Object[] {
4750 Long.valueOf(wikiNodeModelImpl.getOriginalCompanyId())
4751 };
4752
4753 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
4754 args);
4755 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4756 args);
4757
4758 args = new Object[] {
4759 Long.valueOf(wikiNodeModelImpl.getCompanyId())
4760 };
4761
4762 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
4763 args);
4764 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4765 args);
4766 }
4767
4768 if ((wikiNodeModelImpl.getColumnBitmask() &
4769 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
4770 Object[] args = new Object[] {
4771 Long.valueOf(wikiNodeModelImpl.getOriginalGroupId()),
4772 Integer.valueOf(wikiNodeModelImpl.getOriginalStatus())
4773 };
4774
4775 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
4776 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
4777 args);
4778
4779 args = new Object[] {
4780 Long.valueOf(wikiNodeModelImpl.getGroupId()),
4781 Integer.valueOf(wikiNodeModelImpl.getStatus())
4782 };
4783
4784 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
4785 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
4786 args);
4787 }
4788
4789 if ((wikiNodeModelImpl.getColumnBitmask() &
4790 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
4791 Object[] args = new Object[] {
4792 Long.valueOf(wikiNodeModelImpl.getOriginalCompanyId()),
4793 Integer.valueOf(wikiNodeModelImpl.getOriginalStatus())
4794 };
4795
4796 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
4797 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
4798 args);
4799
4800 args = new Object[] {
4801 Long.valueOf(wikiNodeModelImpl.getCompanyId()),
4802 Integer.valueOf(wikiNodeModelImpl.getStatus())
4803 };
4804
4805 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
4806 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
4807 args);
4808 }
4809 }
4810
4811 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4812 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
4813
4814 clearUniqueFindersCache(wikiNode);
4815 cacheUniqueFindersCache(wikiNode);
4816
4817 return wikiNode;
4818 }
4819
4820 protected WikiNode toUnwrappedModel(WikiNode wikiNode) {
4821 if (wikiNode instanceof WikiNodeImpl) {
4822 return wikiNode;
4823 }
4824
4825 WikiNodeImpl wikiNodeImpl = new WikiNodeImpl();
4826
4827 wikiNodeImpl.setNew(wikiNode.isNew());
4828 wikiNodeImpl.setPrimaryKey(wikiNode.getPrimaryKey());
4829
4830 wikiNodeImpl.setUuid(wikiNode.getUuid());
4831 wikiNodeImpl.setNodeId(wikiNode.getNodeId());
4832 wikiNodeImpl.setGroupId(wikiNode.getGroupId());
4833 wikiNodeImpl.setCompanyId(wikiNode.getCompanyId());
4834 wikiNodeImpl.setUserId(wikiNode.getUserId());
4835 wikiNodeImpl.setUserName(wikiNode.getUserName());
4836 wikiNodeImpl.setCreateDate(wikiNode.getCreateDate());
4837 wikiNodeImpl.setModifiedDate(wikiNode.getModifiedDate());
4838 wikiNodeImpl.setName(wikiNode.getName());
4839 wikiNodeImpl.setDescription(wikiNode.getDescription());
4840 wikiNodeImpl.setLastPostDate(wikiNode.getLastPostDate());
4841 wikiNodeImpl.setStatus(wikiNode.getStatus());
4842 wikiNodeImpl.setStatusByUserId(wikiNode.getStatusByUserId());
4843 wikiNodeImpl.setStatusByUserName(wikiNode.getStatusByUserName());
4844 wikiNodeImpl.setStatusDate(wikiNode.getStatusDate());
4845
4846 return wikiNodeImpl;
4847 }
4848
4849
4857 @Override
4858 public WikiNode findByPrimaryKey(Serializable primaryKey)
4859 throws NoSuchModelException, SystemException {
4860 return findByPrimaryKey(((Long)primaryKey).longValue());
4861 }
4862
4863
4871 public WikiNode findByPrimaryKey(long nodeId)
4872 throws NoSuchNodeException, SystemException {
4873 WikiNode wikiNode = fetchByPrimaryKey(nodeId);
4874
4875 if (wikiNode == null) {
4876 if (_log.isWarnEnabled()) {
4877 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + nodeId);
4878 }
4879
4880 throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4881 nodeId);
4882 }
4883
4884 return wikiNode;
4885 }
4886
4887
4894 @Override
4895 public WikiNode fetchByPrimaryKey(Serializable primaryKey)
4896 throws SystemException {
4897 return fetchByPrimaryKey(((Long)primaryKey).longValue());
4898 }
4899
4900
4907 public WikiNode fetchByPrimaryKey(long nodeId) throws SystemException {
4908 WikiNode wikiNode = (WikiNode)EntityCacheUtil.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4909 WikiNodeImpl.class, nodeId);
4910
4911 if (wikiNode == _nullWikiNode) {
4912 return null;
4913 }
4914
4915 if (wikiNode == null) {
4916 Session session = null;
4917
4918 try {
4919 session = openSession();
4920
4921 wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
4922 Long.valueOf(nodeId));
4923
4924 if (wikiNode != null) {
4925 cacheResult(wikiNode);
4926 }
4927 else {
4928 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4929 WikiNodeImpl.class, nodeId, _nullWikiNode);
4930 }
4931 }
4932 catch (Exception e) {
4933 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4934 WikiNodeImpl.class, nodeId);
4935
4936 throw processException(e);
4937 }
4938 finally {
4939 closeSession(session);
4940 }
4941 }
4942
4943 return wikiNode;
4944 }
4945
4946
4952 public List<WikiNode> findAll() throws SystemException {
4953 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4954 }
4955
4956
4968 public List<WikiNode> findAll(int start, int end) throws SystemException {
4969 return findAll(start, end, null);
4970 }
4971
4972
4985 public List<WikiNode> findAll(int start, int end,
4986 OrderByComparator orderByComparator) throws SystemException {
4987 boolean pagination = true;
4988 FinderPath finderPath = null;
4989 Object[] finderArgs = null;
4990
4991 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4992 (orderByComparator == null)) {
4993 pagination = false;
4994 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4995 finderArgs = FINDER_ARGS_EMPTY;
4996 }
4997 else {
4998 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4999 finderArgs = new Object[] { start, end, orderByComparator };
5000 }
5001
5002 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
5003 finderArgs, this);
5004
5005 if (list == null) {
5006 StringBundler query = null;
5007 String sql = null;
5008
5009 if (orderByComparator != null) {
5010 query = new StringBundler(2 +
5011 (orderByComparator.getOrderByFields().length * 3));
5012
5013 query.append(_SQL_SELECT_WIKINODE);
5014
5015 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5016 orderByComparator);
5017
5018 sql = query.toString();
5019 }
5020 else {
5021 sql = _SQL_SELECT_WIKINODE;
5022
5023 if (pagination) {
5024 sql = sql.concat(WikiNodeModelImpl.ORDER_BY_JPQL);
5025 }
5026 }
5027
5028 Session session = null;
5029
5030 try {
5031 session = openSession();
5032
5033 Query q = session.createQuery(sql);
5034
5035 if (!pagination) {
5036 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
5037 start, end, false);
5038
5039 Collections.sort(list);
5040
5041 list = new UnmodifiableList<WikiNode>(list);
5042 }
5043 else {
5044 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
5045 start, end);
5046 }
5047
5048 cacheResult(list);
5049
5050 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5051 }
5052 catch (Exception e) {
5053 FinderCacheUtil.removeResult(finderPath, finderArgs);
5054
5055 throw processException(e);
5056 }
5057 finally {
5058 closeSession(session);
5059 }
5060 }
5061
5062 return list;
5063 }
5064
5065
5070 public void removeAll() throws SystemException {
5071 for (WikiNode wikiNode : findAll()) {
5072 remove(wikiNode);
5073 }
5074 }
5075
5076
5082 public int countAll() throws SystemException {
5083 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5084 FINDER_ARGS_EMPTY, this);
5085
5086 if (count == null) {
5087 Session session = null;
5088
5089 try {
5090 session = openSession();
5091
5092 Query q = session.createQuery(_SQL_COUNT_WIKINODE);
5093
5094 count = (Long)q.uniqueResult();
5095
5096 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5097 FINDER_ARGS_EMPTY, count);
5098 }
5099 catch (Exception e) {
5100 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5101 FINDER_ARGS_EMPTY);
5102
5103 throw processException(e);
5104 }
5105 finally {
5106 closeSession(session);
5107 }
5108 }
5109
5110 return count.intValue();
5111 }
5112
5113
5116 public void afterPropertiesSet() {
5117 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5118 com.liferay.portal.util.PropsUtil.get(
5119 "value.object.listener.com.liferay.portlet.wiki.model.WikiNode")));
5120
5121 if (listenerClassNames.length > 0) {
5122 try {
5123 List<ModelListener<WikiNode>> listenersList = new ArrayList<ModelListener<WikiNode>>();
5124
5125 for (String listenerClassName : listenerClassNames) {
5126 listenersList.add((ModelListener<WikiNode>)InstanceFactory.newInstance(
5127 listenerClassName));
5128 }
5129
5130 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5131 }
5132 catch (Exception e) {
5133 _log.error(e);
5134 }
5135 }
5136 }
5137
5138 public void destroy() {
5139 EntityCacheUtil.removeCache(WikiNodeImpl.class.getName());
5140 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5141 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5142 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5143 }
5144
5145 private static final String _SQL_SELECT_WIKINODE = "SELECT wikiNode FROM WikiNode wikiNode";
5146 private static final String _SQL_SELECT_WIKINODE_WHERE = "SELECT wikiNode FROM WikiNode wikiNode WHERE ";
5147 private static final String _SQL_COUNT_WIKINODE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode";
5148 private static final String _SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode WHERE ";
5149 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "wikiNode.nodeId";
5150 private static final String _FILTER_SQL_SELECT_WIKINODE_WHERE = "SELECT DISTINCT {wikiNode.*} FROM WikiNode wikiNode WHERE ";
5151 private static final String _FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1 =
5152 "SELECT {WikiNode.*} FROM (SELECT DISTINCT wikiNode.nodeId FROM WikiNode wikiNode WHERE ";
5153 private static final String _FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2 =
5154 ") TEMP_TABLE INNER JOIN WikiNode ON TEMP_TABLE.nodeId = WikiNode.nodeId";
5155 private static final String _FILTER_SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(DISTINCT wikiNode.nodeId) AS COUNT_VALUE FROM WikiNode wikiNode WHERE ";
5156 private static final String _FILTER_ENTITY_ALIAS = "wikiNode";
5157 private static final String _FILTER_ENTITY_TABLE = "WikiNode";
5158 private static final String _ORDER_BY_ENTITY_ALIAS = "wikiNode.";
5159 private static final String _ORDER_BY_ENTITY_TABLE = "WikiNode.";
5160 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiNode exists with the primary key ";
5161 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiNode exists with the key {";
5162 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5163 private static Log _log = LogFactoryUtil.getLog(WikiNodePersistenceImpl.class);
5164 private static WikiNode _nullWikiNode = new WikiNodeImpl() {
5165 @Override
5166 public Object clone() {
5167 return this;
5168 }
5169
5170 @Override
5171 public CacheModel<WikiNode> toCacheModel() {
5172 return _nullWikiNodeCacheModel;
5173 }
5174 };
5175
5176 private static CacheModel<WikiNode> _nullWikiNodeCacheModel = new CacheModel<WikiNode>() {
5177 public WikiNode toEntityModel() {
5178 return _nullWikiNode;
5179 }
5180 };
5181 }