001
014
015 package com.liferay.portlet.wiki.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.SetUtil;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.Validator;
035 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
038 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
039
040 import com.liferay.portlet.wiki.NoSuchNodeException;
041 import com.liferay.portlet.wiki.model.WikiNode;
042 import com.liferay.portlet.wiki.model.impl.WikiNodeImpl;
043 import com.liferay.portlet.wiki.model.impl.WikiNodeModelImpl;
044 import com.liferay.portlet.wiki.service.persistence.WikiNodePersistence;
045
046 import java.io.Serializable;
047
048 import java.util.Collections;
049 import java.util.HashMap;
050 import java.util.HashSet;
051 import java.util.Iterator;
052 import java.util.List;
053 import java.util.Map;
054 import java.util.Set;
055
056
068 @ProviderType
069 public class WikiNodePersistenceImpl extends BasePersistenceImpl<WikiNode>
070 implements WikiNodePersistence {
071
076 public static final String FINDER_CLASS_NAME_ENTITY = WikiNodeImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List1";
079 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List2";
081 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
082 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
083 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
085 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
088 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
091 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
092 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
100 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
102 new String[] { String.class.getName() },
103 WikiNodeModelImpl.UUID_COLUMN_BITMASK |
104 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
106 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
108 new String[] { String.class.getName() });
109
110
116 @Override
117 public List<WikiNode> findByUuid(String uuid) {
118 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
119 }
120
121
133 @Override
134 public List<WikiNode> findByUuid(String uuid, int start, int end) {
135 return findByUuid(uuid, start, end, null);
136 }
137
138
151 @Override
152 public List<WikiNode> findByUuid(String uuid, int start, int end,
153 OrderByComparator<WikiNode> orderByComparator) {
154 boolean pagination = true;
155 FinderPath finderPath = null;
156 Object[] finderArgs = null;
157
158 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
159 (orderByComparator == null)) {
160 pagination = false;
161 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
162 finderArgs = new Object[] { uuid };
163 }
164 else {
165 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
166 finderArgs = new Object[] { uuid, start, end, orderByComparator };
167 }
168
169 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
170 finderArgs, this);
171
172 if ((list != null) && !list.isEmpty()) {
173 for (WikiNode wikiNode : list) {
174 if (!Validator.equals(uuid, wikiNode.getUuid())) {
175 list = null;
176
177 break;
178 }
179 }
180 }
181
182 if (list == null) {
183 StringBundler query = null;
184
185 if (orderByComparator != null) {
186 query = new StringBundler(3 +
187 (orderByComparator.getOrderByFields().length * 3));
188 }
189 else {
190 query = new StringBundler(3);
191 }
192
193 query.append(_SQL_SELECT_WIKINODE_WHERE);
194
195 boolean bindUuid = false;
196
197 if (uuid == null) {
198 query.append(_FINDER_COLUMN_UUID_UUID_1);
199 }
200 else if (uuid.equals(StringPool.BLANK)) {
201 query.append(_FINDER_COLUMN_UUID_UUID_3);
202 }
203 else {
204 bindUuid = true;
205
206 query.append(_FINDER_COLUMN_UUID_UUID_2);
207 }
208
209 if (orderByComparator != null) {
210 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
211 orderByComparator);
212 }
213 else
214 if (pagination) {
215 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
216 }
217
218 String sql = query.toString();
219
220 Session session = null;
221
222 try {
223 session = openSession();
224
225 Query q = session.createQuery(sql);
226
227 QueryPos qPos = QueryPos.getInstance(q);
228
229 if (bindUuid) {
230 qPos.add(uuid);
231 }
232
233 if (!pagination) {
234 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
235 start, end, false);
236
237 Collections.sort(list);
238
239 list = Collections.unmodifiableList(list);
240 }
241 else {
242 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
243 start, end);
244 }
245
246 cacheResult(list);
247
248 FinderCacheUtil.putResult(finderPath, finderArgs, list);
249 }
250 catch (Exception e) {
251 FinderCacheUtil.removeResult(finderPath, finderArgs);
252
253 throw processException(e);
254 }
255 finally {
256 closeSession(session);
257 }
258 }
259
260 return list;
261 }
262
263
271 @Override
272 public WikiNode findByUuid_First(String uuid,
273 OrderByComparator<WikiNode> orderByComparator)
274 throws NoSuchNodeException {
275 WikiNode wikiNode = fetchByUuid_First(uuid, orderByComparator);
276
277 if (wikiNode != null) {
278 return wikiNode;
279 }
280
281 StringBundler msg = new StringBundler(4);
282
283 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
284
285 msg.append("uuid=");
286 msg.append(uuid);
287
288 msg.append(StringPool.CLOSE_CURLY_BRACE);
289
290 throw new NoSuchNodeException(msg.toString());
291 }
292
293
300 @Override
301 public WikiNode fetchByUuid_First(String uuid,
302 OrderByComparator<WikiNode> orderByComparator) {
303 List<WikiNode> list = findByUuid(uuid, 0, 1, orderByComparator);
304
305 if (!list.isEmpty()) {
306 return list.get(0);
307 }
308
309 return null;
310 }
311
312
320 @Override
321 public WikiNode findByUuid_Last(String uuid,
322 OrderByComparator<WikiNode> orderByComparator)
323 throws NoSuchNodeException {
324 WikiNode wikiNode = fetchByUuid_Last(uuid, orderByComparator);
325
326 if (wikiNode != null) {
327 return wikiNode;
328 }
329
330 StringBundler msg = new StringBundler(4);
331
332 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
333
334 msg.append("uuid=");
335 msg.append(uuid);
336
337 msg.append(StringPool.CLOSE_CURLY_BRACE);
338
339 throw new NoSuchNodeException(msg.toString());
340 }
341
342
349 @Override
350 public WikiNode fetchByUuid_Last(String uuid,
351 OrderByComparator<WikiNode> orderByComparator) {
352 int count = countByUuid(uuid);
353
354 if (count == 0) {
355 return null;
356 }
357
358 List<WikiNode> list = findByUuid(uuid, count - 1, count,
359 orderByComparator);
360
361 if (!list.isEmpty()) {
362 return list.get(0);
363 }
364
365 return null;
366 }
367
368
377 @Override
378 public WikiNode[] findByUuid_PrevAndNext(long nodeId, String uuid,
379 OrderByComparator<WikiNode> orderByComparator)
380 throws NoSuchNodeException {
381 WikiNode wikiNode = findByPrimaryKey(nodeId);
382
383 Session session = null;
384
385 try {
386 session = openSession();
387
388 WikiNode[] array = new WikiNodeImpl[3];
389
390 array[0] = getByUuid_PrevAndNext(session, wikiNode, uuid,
391 orderByComparator, true);
392
393 array[1] = wikiNode;
394
395 array[2] = getByUuid_PrevAndNext(session, wikiNode, uuid,
396 orderByComparator, false);
397
398 return array;
399 }
400 catch (Exception e) {
401 throw processException(e);
402 }
403 finally {
404 closeSession(session);
405 }
406 }
407
408 protected WikiNode getByUuid_PrevAndNext(Session session,
409 WikiNode wikiNode, String uuid,
410 OrderByComparator<WikiNode> orderByComparator, boolean previous) {
411 StringBundler query = null;
412
413 if (orderByComparator != null) {
414 query = new StringBundler(6 +
415 (orderByComparator.getOrderByFields().length * 6));
416 }
417 else {
418 query = new StringBundler(3);
419 }
420
421 query.append(_SQL_SELECT_WIKINODE_WHERE);
422
423 boolean bindUuid = false;
424
425 if (uuid == null) {
426 query.append(_FINDER_COLUMN_UUID_UUID_1);
427 }
428 else if (uuid.equals(StringPool.BLANK)) {
429 query.append(_FINDER_COLUMN_UUID_UUID_3);
430 }
431 else {
432 bindUuid = true;
433
434 query.append(_FINDER_COLUMN_UUID_UUID_2);
435 }
436
437 if (orderByComparator != null) {
438 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
439
440 if (orderByConditionFields.length > 0) {
441 query.append(WHERE_AND);
442 }
443
444 for (int i = 0; i < orderByConditionFields.length; i++) {
445 query.append(_ORDER_BY_ENTITY_ALIAS);
446 query.append(orderByConditionFields[i]);
447
448 if ((i + 1) < orderByConditionFields.length) {
449 if (orderByComparator.isAscending() ^ previous) {
450 query.append(WHERE_GREATER_THAN_HAS_NEXT);
451 }
452 else {
453 query.append(WHERE_LESSER_THAN_HAS_NEXT);
454 }
455 }
456 else {
457 if (orderByComparator.isAscending() ^ previous) {
458 query.append(WHERE_GREATER_THAN);
459 }
460 else {
461 query.append(WHERE_LESSER_THAN);
462 }
463 }
464 }
465
466 query.append(ORDER_BY_CLAUSE);
467
468 String[] orderByFields = orderByComparator.getOrderByFields();
469
470 for (int i = 0; i < orderByFields.length; i++) {
471 query.append(_ORDER_BY_ENTITY_ALIAS);
472 query.append(orderByFields[i]);
473
474 if ((i + 1) < orderByFields.length) {
475 if (orderByComparator.isAscending() ^ previous) {
476 query.append(ORDER_BY_ASC_HAS_NEXT);
477 }
478 else {
479 query.append(ORDER_BY_DESC_HAS_NEXT);
480 }
481 }
482 else {
483 if (orderByComparator.isAscending() ^ previous) {
484 query.append(ORDER_BY_ASC);
485 }
486 else {
487 query.append(ORDER_BY_DESC);
488 }
489 }
490 }
491 }
492 else {
493 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
494 }
495
496 String sql = query.toString();
497
498 Query q = session.createQuery(sql);
499
500 q.setFirstResult(0);
501 q.setMaxResults(2);
502
503 QueryPos qPos = QueryPos.getInstance(q);
504
505 if (bindUuid) {
506 qPos.add(uuid);
507 }
508
509 if (orderByComparator != null) {
510 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
511
512 for (Object value : values) {
513 qPos.add(value);
514 }
515 }
516
517 List<WikiNode> list = q.list();
518
519 if (list.size() == 2) {
520 return list.get(1);
521 }
522 else {
523 return null;
524 }
525 }
526
527
532 @Override
533 public void removeByUuid(String uuid) {
534 for (WikiNode wikiNode : findByUuid(uuid, QueryUtil.ALL_POS,
535 QueryUtil.ALL_POS, null)) {
536 remove(wikiNode);
537 }
538 }
539
540
546 @Override
547 public int countByUuid(String uuid) {
548 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
549
550 Object[] finderArgs = new Object[] { uuid };
551
552 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
553 this);
554
555 if (count == null) {
556 StringBundler query = new StringBundler(2);
557
558 query.append(_SQL_COUNT_WIKINODE_WHERE);
559
560 boolean bindUuid = false;
561
562 if (uuid == null) {
563 query.append(_FINDER_COLUMN_UUID_UUID_1);
564 }
565 else if (uuid.equals(StringPool.BLANK)) {
566 query.append(_FINDER_COLUMN_UUID_UUID_3);
567 }
568 else {
569 bindUuid = true;
570
571 query.append(_FINDER_COLUMN_UUID_UUID_2);
572 }
573
574 String sql = query.toString();
575
576 Session session = null;
577
578 try {
579 session = openSession();
580
581 Query q = session.createQuery(sql);
582
583 QueryPos qPos = QueryPos.getInstance(q);
584
585 if (bindUuid) {
586 qPos.add(uuid);
587 }
588
589 count = (Long)q.uniqueResult();
590
591 FinderCacheUtil.putResult(finderPath, finderArgs, count);
592 }
593 catch (Exception e) {
594 FinderCacheUtil.removeResult(finderPath, finderArgs);
595
596 throw processException(e);
597 }
598 finally {
599 closeSession(session);
600 }
601 }
602
603 return count.intValue();
604 }
605
606 private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiNode.uuid IS NULL";
607 private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiNode.uuid = ?";
608 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = '')";
609 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
610 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
611 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
612 new String[] { String.class.getName(), Long.class.getName() },
613 WikiNodeModelImpl.UUID_COLUMN_BITMASK |
614 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK);
615 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
616 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
617 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
618 new String[] { String.class.getName(), Long.class.getName() });
619
620
628 @Override
629 public WikiNode findByUUID_G(String uuid, long groupId)
630 throws NoSuchNodeException {
631 WikiNode wikiNode = fetchByUUID_G(uuid, groupId);
632
633 if (wikiNode == null) {
634 StringBundler msg = new StringBundler(6);
635
636 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
637
638 msg.append("uuid=");
639 msg.append(uuid);
640
641 msg.append(", groupId=");
642 msg.append(groupId);
643
644 msg.append(StringPool.CLOSE_CURLY_BRACE);
645
646 if (_log.isWarnEnabled()) {
647 _log.warn(msg.toString());
648 }
649
650 throw new NoSuchNodeException(msg.toString());
651 }
652
653 return wikiNode;
654 }
655
656
663 @Override
664 public WikiNode fetchByUUID_G(String uuid, long groupId) {
665 return fetchByUUID_G(uuid, groupId, true);
666 }
667
668
676 @Override
677 public WikiNode fetchByUUID_G(String uuid, long groupId,
678 boolean retrieveFromCache) {
679 Object[] finderArgs = new Object[] { uuid, groupId };
680
681 Object result = null;
682
683 if (retrieveFromCache) {
684 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
685 finderArgs, this);
686 }
687
688 if (result instanceof WikiNode) {
689 WikiNode wikiNode = (WikiNode)result;
690
691 if (!Validator.equals(uuid, wikiNode.getUuid()) ||
692 (groupId != wikiNode.getGroupId())) {
693 result = null;
694 }
695 }
696
697 if (result == null) {
698 StringBundler query = new StringBundler(4);
699
700 query.append(_SQL_SELECT_WIKINODE_WHERE);
701
702 boolean bindUuid = false;
703
704 if (uuid == null) {
705 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
706 }
707 else if (uuid.equals(StringPool.BLANK)) {
708 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
709 }
710 else {
711 bindUuid = true;
712
713 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
714 }
715
716 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
717
718 String sql = query.toString();
719
720 Session session = null;
721
722 try {
723 session = openSession();
724
725 Query q = session.createQuery(sql);
726
727 QueryPos qPos = QueryPos.getInstance(q);
728
729 if (bindUuid) {
730 qPos.add(uuid);
731 }
732
733 qPos.add(groupId);
734
735 List<WikiNode> list = q.list();
736
737 if (list.isEmpty()) {
738 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
739 finderArgs, list);
740 }
741 else {
742 WikiNode wikiNode = list.get(0);
743
744 result = wikiNode;
745
746 cacheResult(wikiNode);
747
748 if ((wikiNode.getUuid() == null) ||
749 !wikiNode.getUuid().equals(uuid) ||
750 (wikiNode.getGroupId() != groupId)) {
751 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
752 finderArgs, wikiNode);
753 }
754 }
755 }
756 catch (Exception e) {
757 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
758 finderArgs);
759
760 throw processException(e);
761 }
762 finally {
763 closeSession(session);
764 }
765 }
766
767 if (result instanceof List<?>) {
768 return null;
769 }
770 else {
771 return (WikiNode)result;
772 }
773 }
774
775
782 @Override
783 public WikiNode removeByUUID_G(String uuid, long groupId)
784 throws NoSuchNodeException {
785 WikiNode wikiNode = findByUUID_G(uuid, groupId);
786
787 return remove(wikiNode);
788 }
789
790
797 @Override
798 public int countByUUID_G(String uuid, long groupId) {
799 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
800
801 Object[] finderArgs = new Object[] { uuid, groupId };
802
803 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
804 this);
805
806 if (count == null) {
807 StringBundler query = new StringBundler(3);
808
809 query.append(_SQL_COUNT_WIKINODE_WHERE);
810
811 boolean bindUuid = false;
812
813 if (uuid == null) {
814 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
815 }
816 else if (uuid.equals(StringPool.BLANK)) {
817 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
818 }
819 else {
820 bindUuid = true;
821
822 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
823 }
824
825 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
826
827 String sql = query.toString();
828
829 Session session = null;
830
831 try {
832 session = openSession();
833
834 Query q = session.createQuery(sql);
835
836 QueryPos qPos = QueryPos.getInstance(q);
837
838 if (bindUuid) {
839 qPos.add(uuid);
840 }
841
842 qPos.add(groupId);
843
844 count = (Long)q.uniqueResult();
845
846 FinderCacheUtil.putResult(finderPath, finderArgs, count);
847 }
848 catch (Exception e) {
849 FinderCacheUtil.removeResult(finderPath, finderArgs);
850
851 throw processException(e);
852 }
853 finally {
854 closeSession(session);
855 }
856 }
857
858 return count.intValue();
859 }
860
861 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiNode.uuid IS NULL AND ";
862 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiNode.uuid = ? AND ";
863 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = '') AND ";
864 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiNode.groupId = ?";
865 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
866 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
867 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
868 new String[] {
869 String.class.getName(), Long.class.getName(),
870
871 Integer.class.getName(), Integer.class.getName(),
872 OrderByComparator.class.getName()
873 });
874 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
875 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
876 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
877 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
878 new String[] { String.class.getName(), Long.class.getName() },
879 WikiNodeModelImpl.UUID_COLUMN_BITMASK |
880 WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK |
881 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
882 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
883 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
884 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
885 new String[] { String.class.getName(), Long.class.getName() });
886
887
894 @Override
895 public List<WikiNode> findByUuid_C(String uuid, long companyId) {
896 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
897 QueryUtil.ALL_POS, null);
898 }
899
900
913 @Override
914 public List<WikiNode> findByUuid_C(String uuid, long companyId, int start,
915 int end) {
916 return findByUuid_C(uuid, companyId, start, end, null);
917 }
918
919
933 @Override
934 public List<WikiNode> findByUuid_C(String uuid, long companyId, int start,
935 int end, OrderByComparator<WikiNode> orderByComparator) {
936 boolean pagination = true;
937 FinderPath finderPath = null;
938 Object[] finderArgs = null;
939
940 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
941 (orderByComparator == null)) {
942 pagination = false;
943 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
944 finderArgs = new Object[] { uuid, companyId };
945 }
946 else {
947 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
948 finderArgs = new Object[] {
949 uuid, companyId,
950
951 start, end, orderByComparator
952 };
953 }
954
955 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
956 finderArgs, this);
957
958 if ((list != null) && !list.isEmpty()) {
959 for (WikiNode wikiNode : list) {
960 if (!Validator.equals(uuid, wikiNode.getUuid()) ||
961 (companyId != wikiNode.getCompanyId())) {
962 list = null;
963
964 break;
965 }
966 }
967 }
968
969 if (list == null) {
970 StringBundler query = null;
971
972 if (orderByComparator != null) {
973 query = new StringBundler(4 +
974 (orderByComparator.getOrderByFields().length * 3));
975 }
976 else {
977 query = new StringBundler(4);
978 }
979
980 query.append(_SQL_SELECT_WIKINODE_WHERE);
981
982 boolean bindUuid = false;
983
984 if (uuid == null) {
985 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
986 }
987 else if (uuid.equals(StringPool.BLANK)) {
988 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
989 }
990 else {
991 bindUuid = true;
992
993 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
994 }
995
996 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
997
998 if (orderByComparator != null) {
999 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1000 orderByComparator);
1001 }
1002 else
1003 if (pagination) {
1004 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1005 }
1006
1007 String sql = query.toString();
1008
1009 Session session = null;
1010
1011 try {
1012 session = openSession();
1013
1014 Query q = session.createQuery(sql);
1015
1016 QueryPos qPos = QueryPos.getInstance(q);
1017
1018 if (bindUuid) {
1019 qPos.add(uuid);
1020 }
1021
1022 qPos.add(companyId);
1023
1024 if (!pagination) {
1025 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1026 start, end, false);
1027
1028 Collections.sort(list);
1029
1030 list = Collections.unmodifiableList(list);
1031 }
1032 else {
1033 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1034 start, end);
1035 }
1036
1037 cacheResult(list);
1038
1039 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1040 }
1041 catch (Exception e) {
1042 FinderCacheUtil.removeResult(finderPath, finderArgs);
1043
1044 throw processException(e);
1045 }
1046 finally {
1047 closeSession(session);
1048 }
1049 }
1050
1051 return list;
1052 }
1053
1054
1063 @Override
1064 public WikiNode findByUuid_C_First(String uuid, long companyId,
1065 OrderByComparator<WikiNode> orderByComparator)
1066 throws NoSuchNodeException {
1067 WikiNode wikiNode = fetchByUuid_C_First(uuid, companyId,
1068 orderByComparator);
1069
1070 if (wikiNode != null) {
1071 return wikiNode;
1072 }
1073
1074 StringBundler msg = new StringBundler(6);
1075
1076 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1077
1078 msg.append("uuid=");
1079 msg.append(uuid);
1080
1081 msg.append(", companyId=");
1082 msg.append(companyId);
1083
1084 msg.append(StringPool.CLOSE_CURLY_BRACE);
1085
1086 throw new NoSuchNodeException(msg.toString());
1087 }
1088
1089
1097 @Override
1098 public WikiNode fetchByUuid_C_First(String uuid, long companyId,
1099 OrderByComparator<WikiNode> orderByComparator) {
1100 List<WikiNode> list = findByUuid_C(uuid, companyId, 0, 1,
1101 orderByComparator);
1102
1103 if (!list.isEmpty()) {
1104 return list.get(0);
1105 }
1106
1107 return null;
1108 }
1109
1110
1119 @Override
1120 public WikiNode findByUuid_C_Last(String uuid, long companyId,
1121 OrderByComparator<WikiNode> orderByComparator)
1122 throws NoSuchNodeException {
1123 WikiNode wikiNode = fetchByUuid_C_Last(uuid, companyId,
1124 orderByComparator);
1125
1126 if (wikiNode != null) {
1127 return wikiNode;
1128 }
1129
1130 StringBundler msg = new StringBundler(6);
1131
1132 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1133
1134 msg.append("uuid=");
1135 msg.append(uuid);
1136
1137 msg.append(", companyId=");
1138 msg.append(companyId);
1139
1140 msg.append(StringPool.CLOSE_CURLY_BRACE);
1141
1142 throw new NoSuchNodeException(msg.toString());
1143 }
1144
1145
1153 @Override
1154 public WikiNode fetchByUuid_C_Last(String uuid, long companyId,
1155 OrderByComparator<WikiNode> orderByComparator) {
1156 int count = countByUuid_C(uuid, companyId);
1157
1158 if (count == 0) {
1159 return null;
1160 }
1161
1162 List<WikiNode> list = findByUuid_C(uuid, companyId, count - 1, count,
1163 orderByComparator);
1164
1165 if (!list.isEmpty()) {
1166 return list.get(0);
1167 }
1168
1169 return null;
1170 }
1171
1172
1182 @Override
1183 public WikiNode[] findByUuid_C_PrevAndNext(long nodeId, String uuid,
1184 long companyId, OrderByComparator<WikiNode> orderByComparator)
1185 throws NoSuchNodeException {
1186 WikiNode wikiNode = findByPrimaryKey(nodeId);
1187
1188 Session session = null;
1189
1190 try {
1191 session = openSession();
1192
1193 WikiNode[] array = new WikiNodeImpl[3];
1194
1195 array[0] = getByUuid_C_PrevAndNext(session, wikiNode, uuid,
1196 companyId, orderByComparator, true);
1197
1198 array[1] = wikiNode;
1199
1200 array[2] = getByUuid_C_PrevAndNext(session, wikiNode, uuid,
1201 companyId, orderByComparator, false);
1202
1203 return array;
1204 }
1205 catch (Exception e) {
1206 throw processException(e);
1207 }
1208 finally {
1209 closeSession(session);
1210 }
1211 }
1212
1213 protected WikiNode getByUuid_C_PrevAndNext(Session session,
1214 WikiNode wikiNode, String uuid, long companyId,
1215 OrderByComparator<WikiNode> orderByComparator, boolean previous) {
1216 StringBundler query = null;
1217
1218 if (orderByComparator != null) {
1219 query = new StringBundler(6 +
1220 (orderByComparator.getOrderByFields().length * 6));
1221 }
1222 else {
1223 query = new StringBundler(3);
1224 }
1225
1226 query.append(_SQL_SELECT_WIKINODE_WHERE);
1227
1228 boolean bindUuid = false;
1229
1230 if (uuid == null) {
1231 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1232 }
1233 else if (uuid.equals(StringPool.BLANK)) {
1234 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1235 }
1236 else {
1237 bindUuid = true;
1238
1239 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1240 }
1241
1242 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1243
1244 if (orderByComparator != null) {
1245 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1246
1247 if (orderByConditionFields.length > 0) {
1248 query.append(WHERE_AND);
1249 }
1250
1251 for (int i = 0; i < orderByConditionFields.length; i++) {
1252 query.append(_ORDER_BY_ENTITY_ALIAS);
1253 query.append(orderByConditionFields[i]);
1254
1255 if ((i + 1) < orderByConditionFields.length) {
1256 if (orderByComparator.isAscending() ^ previous) {
1257 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1258 }
1259 else {
1260 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1261 }
1262 }
1263 else {
1264 if (orderByComparator.isAscending() ^ previous) {
1265 query.append(WHERE_GREATER_THAN);
1266 }
1267 else {
1268 query.append(WHERE_LESSER_THAN);
1269 }
1270 }
1271 }
1272
1273 query.append(ORDER_BY_CLAUSE);
1274
1275 String[] orderByFields = orderByComparator.getOrderByFields();
1276
1277 for (int i = 0; i < orderByFields.length; i++) {
1278 query.append(_ORDER_BY_ENTITY_ALIAS);
1279 query.append(orderByFields[i]);
1280
1281 if ((i + 1) < orderByFields.length) {
1282 if (orderByComparator.isAscending() ^ previous) {
1283 query.append(ORDER_BY_ASC_HAS_NEXT);
1284 }
1285 else {
1286 query.append(ORDER_BY_DESC_HAS_NEXT);
1287 }
1288 }
1289 else {
1290 if (orderByComparator.isAscending() ^ previous) {
1291 query.append(ORDER_BY_ASC);
1292 }
1293 else {
1294 query.append(ORDER_BY_DESC);
1295 }
1296 }
1297 }
1298 }
1299 else {
1300 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1301 }
1302
1303 String sql = query.toString();
1304
1305 Query q = session.createQuery(sql);
1306
1307 q.setFirstResult(0);
1308 q.setMaxResults(2);
1309
1310 QueryPos qPos = QueryPos.getInstance(q);
1311
1312 if (bindUuid) {
1313 qPos.add(uuid);
1314 }
1315
1316 qPos.add(companyId);
1317
1318 if (orderByComparator != null) {
1319 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1320
1321 for (Object value : values) {
1322 qPos.add(value);
1323 }
1324 }
1325
1326 List<WikiNode> list = q.list();
1327
1328 if (list.size() == 2) {
1329 return list.get(1);
1330 }
1331 else {
1332 return null;
1333 }
1334 }
1335
1336
1342 @Override
1343 public void removeByUuid_C(String uuid, long companyId) {
1344 for (WikiNode wikiNode : findByUuid_C(uuid, companyId,
1345 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1346 remove(wikiNode);
1347 }
1348 }
1349
1350
1357 @Override
1358 public int countByUuid_C(String uuid, long companyId) {
1359 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1360
1361 Object[] finderArgs = new Object[] { uuid, companyId };
1362
1363 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1364 this);
1365
1366 if (count == null) {
1367 StringBundler query = new StringBundler(3);
1368
1369 query.append(_SQL_COUNT_WIKINODE_WHERE);
1370
1371 boolean bindUuid = false;
1372
1373 if (uuid == null) {
1374 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1375 }
1376 else if (uuid.equals(StringPool.BLANK)) {
1377 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1378 }
1379 else {
1380 bindUuid = true;
1381
1382 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1383 }
1384
1385 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1386
1387 String sql = query.toString();
1388
1389 Session session = null;
1390
1391 try {
1392 session = openSession();
1393
1394 Query q = session.createQuery(sql);
1395
1396 QueryPos qPos = QueryPos.getInstance(q);
1397
1398 if (bindUuid) {
1399 qPos.add(uuid);
1400 }
1401
1402 qPos.add(companyId);
1403
1404 count = (Long)q.uniqueResult();
1405
1406 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1407 }
1408 catch (Exception e) {
1409 FinderCacheUtil.removeResult(finderPath, finderArgs);
1410
1411 throw processException(e);
1412 }
1413 finally {
1414 closeSession(session);
1415 }
1416 }
1417
1418 return count.intValue();
1419 }
1420
1421 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "wikiNode.uuid IS NULL AND ";
1422 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "wikiNode.uuid = ? AND ";
1423 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = '') AND ";
1424 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "wikiNode.companyId = ?";
1425 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
1426 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
1427 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1428 new String[] {
1429 Long.class.getName(),
1430
1431 Integer.class.getName(), Integer.class.getName(),
1432 OrderByComparator.class.getName()
1433 });
1434 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1435 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
1436 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
1437 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1438 new String[] { Long.class.getName() },
1439 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
1440 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
1441 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
1442 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
1443 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1444 new String[] { Long.class.getName() });
1445
1446
1452 @Override
1453 public List<WikiNode> findByGroupId(long groupId) {
1454 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1455 }
1456
1457
1469 @Override
1470 public List<WikiNode> findByGroupId(long groupId, int start, int end) {
1471 return findByGroupId(groupId, start, end, null);
1472 }
1473
1474
1487 @Override
1488 public List<WikiNode> findByGroupId(long groupId, int start, int end,
1489 OrderByComparator<WikiNode> orderByComparator) {
1490 boolean pagination = true;
1491 FinderPath finderPath = null;
1492 Object[] finderArgs = null;
1493
1494 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1495 (orderByComparator == null)) {
1496 pagination = false;
1497 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1498 finderArgs = new Object[] { groupId };
1499 }
1500 else {
1501 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1502 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1503 }
1504
1505 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
1506 finderArgs, this);
1507
1508 if ((list != null) && !list.isEmpty()) {
1509 for (WikiNode wikiNode : list) {
1510 if ((groupId != wikiNode.getGroupId())) {
1511 list = null;
1512
1513 break;
1514 }
1515 }
1516 }
1517
1518 if (list == null) {
1519 StringBundler query = null;
1520
1521 if (orderByComparator != null) {
1522 query = new StringBundler(3 +
1523 (orderByComparator.getOrderByFields().length * 3));
1524 }
1525 else {
1526 query = new StringBundler(3);
1527 }
1528
1529 query.append(_SQL_SELECT_WIKINODE_WHERE);
1530
1531 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1532
1533 if (orderByComparator != null) {
1534 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1535 orderByComparator);
1536 }
1537 else
1538 if (pagination) {
1539 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1540 }
1541
1542 String sql = query.toString();
1543
1544 Session session = null;
1545
1546 try {
1547 session = openSession();
1548
1549 Query q = session.createQuery(sql);
1550
1551 QueryPos qPos = QueryPos.getInstance(q);
1552
1553 qPos.add(groupId);
1554
1555 if (!pagination) {
1556 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1557 start, end, false);
1558
1559 Collections.sort(list);
1560
1561 list = Collections.unmodifiableList(list);
1562 }
1563 else {
1564 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1565 start, end);
1566 }
1567
1568 cacheResult(list);
1569
1570 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1571 }
1572 catch (Exception e) {
1573 FinderCacheUtil.removeResult(finderPath, finderArgs);
1574
1575 throw processException(e);
1576 }
1577 finally {
1578 closeSession(session);
1579 }
1580 }
1581
1582 return list;
1583 }
1584
1585
1593 @Override
1594 public WikiNode findByGroupId_First(long groupId,
1595 OrderByComparator<WikiNode> orderByComparator)
1596 throws NoSuchNodeException {
1597 WikiNode wikiNode = fetchByGroupId_First(groupId, orderByComparator);
1598
1599 if (wikiNode != null) {
1600 return wikiNode;
1601 }
1602
1603 StringBundler msg = new StringBundler(4);
1604
1605 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1606
1607 msg.append("groupId=");
1608 msg.append(groupId);
1609
1610 msg.append(StringPool.CLOSE_CURLY_BRACE);
1611
1612 throw new NoSuchNodeException(msg.toString());
1613 }
1614
1615
1622 @Override
1623 public WikiNode fetchByGroupId_First(long groupId,
1624 OrderByComparator<WikiNode> orderByComparator) {
1625 List<WikiNode> list = findByGroupId(groupId, 0, 1, orderByComparator);
1626
1627 if (!list.isEmpty()) {
1628 return list.get(0);
1629 }
1630
1631 return null;
1632 }
1633
1634
1642 @Override
1643 public WikiNode findByGroupId_Last(long groupId,
1644 OrderByComparator<WikiNode> orderByComparator)
1645 throws NoSuchNodeException {
1646 WikiNode wikiNode = fetchByGroupId_Last(groupId, orderByComparator);
1647
1648 if (wikiNode != null) {
1649 return wikiNode;
1650 }
1651
1652 StringBundler msg = new StringBundler(4);
1653
1654 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1655
1656 msg.append("groupId=");
1657 msg.append(groupId);
1658
1659 msg.append(StringPool.CLOSE_CURLY_BRACE);
1660
1661 throw new NoSuchNodeException(msg.toString());
1662 }
1663
1664
1671 @Override
1672 public WikiNode fetchByGroupId_Last(long groupId,
1673 OrderByComparator<WikiNode> orderByComparator) {
1674 int count = countByGroupId(groupId);
1675
1676 if (count == 0) {
1677 return null;
1678 }
1679
1680 List<WikiNode> list = findByGroupId(groupId, count - 1, count,
1681 orderByComparator);
1682
1683 if (!list.isEmpty()) {
1684 return list.get(0);
1685 }
1686
1687 return null;
1688 }
1689
1690
1699 @Override
1700 public WikiNode[] findByGroupId_PrevAndNext(long nodeId, long groupId,
1701 OrderByComparator<WikiNode> orderByComparator)
1702 throws NoSuchNodeException {
1703 WikiNode wikiNode = findByPrimaryKey(nodeId);
1704
1705 Session session = null;
1706
1707 try {
1708 session = openSession();
1709
1710 WikiNode[] array = new WikiNodeImpl[3];
1711
1712 array[0] = getByGroupId_PrevAndNext(session, wikiNode, groupId,
1713 orderByComparator, true);
1714
1715 array[1] = wikiNode;
1716
1717 array[2] = getByGroupId_PrevAndNext(session, wikiNode, groupId,
1718 orderByComparator, false);
1719
1720 return array;
1721 }
1722 catch (Exception e) {
1723 throw processException(e);
1724 }
1725 finally {
1726 closeSession(session);
1727 }
1728 }
1729
1730 protected WikiNode getByGroupId_PrevAndNext(Session session,
1731 WikiNode wikiNode, long groupId,
1732 OrderByComparator<WikiNode> orderByComparator, boolean previous) {
1733 StringBundler query = null;
1734
1735 if (orderByComparator != null) {
1736 query = new StringBundler(6 +
1737 (orderByComparator.getOrderByFields().length * 6));
1738 }
1739 else {
1740 query = new StringBundler(3);
1741 }
1742
1743 query.append(_SQL_SELECT_WIKINODE_WHERE);
1744
1745 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1746
1747 if (orderByComparator != null) {
1748 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1749
1750 if (orderByConditionFields.length > 0) {
1751 query.append(WHERE_AND);
1752 }
1753
1754 for (int i = 0; i < orderByConditionFields.length; i++) {
1755 query.append(_ORDER_BY_ENTITY_ALIAS);
1756 query.append(orderByConditionFields[i]);
1757
1758 if ((i + 1) < orderByConditionFields.length) {
1759 if (orderByComparator.isAscending() ^ previous) {
1760 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1761 }
1762 else {
1763 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1764 }
1765 }
1766 else {
1767 if (orderByComparator.isAscending() ^ previous) {
1768 query.append(WHERE_GREATER_THAN);
1769 }
1770 else {
1771 query.append(WHERE_LESSER_THAN);
1772 }
1773 }
1774 }
1775
1776 query.append(ORDER_BY_CLAUSE);
1777
1778 String[] orderByFields = orderByComparator.getOrderByFields();
1779
1780 for (int i = 0; i < orderByFields.length; i++) {
1781 query.append(_ORDER_BY_ENTITY_ALIAS);
1782 query.append(orderByFields[i]);
1783
1784 if ((i + 1) < orderByFields.length) {
1785 if (orderByComparator.isAscending() ^ previous) {
1786 query.append(ORDER_BY_ASC_HAS_NEXT);
1787 }
1788 else {
1789 query.append(ORDER_BY_DESC_HAS_NEXT);
1790 }
1791 }
1792 else {
1793 if (orderByComparator.isAscending() ^ previous) {
1794 query.append(ORDER_BY_ASC);
1795 }
1796 else {
1797 query.append(ORDER_BY_DESC);
1798 }
1799 }
1800 }
1801 }
1802 else {
1803 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1804 }
1805
1806 String sql = query.toString();
1807
1808 Query q = session.createQuery(sql);
1809
1810 q.setFirstResult(0);
1811 q.setMaxResults(2);
1812
1813 QueryPos qPos = QueryPos.getInstance(q);
1814
1815 qPos.add(groupId);
1816
1817 if (orderByComparator != null) {
1818 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1819
1820 for (Object value : values) {
1821 qPos.add(value);
1822 }
1823 }
1824
1825 List<WikiNode> list = q.list();
1826
1827 if (list.size() == 2) {
1828 return list.get(1);
1829 }
1830 else {
1831 return null;
1832 }
1833 }
1834
1835
1841 @Override
1842 public List<WikiNode> filterFindByGroupId(long groupId) {
1843 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1844 QueryUtil.ALL_POS, null);
1845 }
1846
1847
1859 @Override
1860 public List<WikiNode> filterFindByGroupId(long groupId, int start, int end) {
1861 return filterFindByGroupId(groupId, start, end, null);
1862 }
1863
1864
1877 @Override
1878 public List<WikiNode> filterFindByGroupId(long groupId, int start, int end,
1879 OrderByComparator<WikiNode> orderByComparator) {
1880 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1881 return findByGroupId(groupId, start, end, orderByComparator);
1882 }
1883
1884 StringBundler query = null;
1885
1886 if (orderByComparator != null) {
1887 query = new StringBundler(3 +
1888 (orderByComparator.getOrderByFields().length * 3));
1889 }
1890 else {
1891 query = new StringBundler(3);
1892 }
1893
1894 if (getDB().isSupportsInlineDistinct()) {
1895 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
1896 }
1897 else {
1898 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
1899 }
1900
1901 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1902
1903 if (!getDB().isSupportsInlineDistinct()) {
1904 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
1905 }
1906
1907 if (orderByComparator != null) {
1908 if (getDB().isSupportsInlineDistinct()) {
1909 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1910 orderByComparator, true);
1911 }
1912 else {
1913 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1914 orderByComparator, true);
1915 }
1916 }
1917 else {
1918 if (getDB().isSupportsInlineDistinct()) {
1919 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1920 }
1921 else {
1922 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
1923 }
1924 }
1925
1926 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1927 WikiNode.class.getName(),
1928 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1929
1930 Session session = null;
1931
1932 try {
1933 session = openSession();
1934
1935 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1936
1937 if (getDB().isSupportsInlineDistinct()) {
1938 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
1939 }
1940 else {
1941 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
1942 }
1943
1944 QueryPos qPos = QueryPos.getInstance(q);
1945
1946 qPos.add(groupId);
1947
1948 return (List<WikiNode>)QueryUtil.list(q, getDialect(), start, end);
1949 }
1950 catch (Exception e) {
1951 throw processException(e);
1952 }
1953 finally {
1954 closeSession(session);
1955 }
1956 }
1957
1958
1967 @Override
1968 public WikiNode[] filterFindByGroupId_PrevAndNext(long nodeId,
1969 long groupId, OrderByComparator<WikiNode> orderByComparator)
1970 throws NoSuchNodeException {
1971 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1972 return findByGroupId_PrevAndNext(nodeId, groupId, orderByComparator);
1973 }
1974
1975 WikiNode wikiNode = findByPrimaryKey(nodeId);
1976
1977 Session session = null;
1978
1979 try {
1980 session = openSession();
1981
1982 WikiNode[] array = new WikiNodeImpl[3];
1983
1984 array[0] = filterGetByGroupId_PrevAndNext(session, wikiNode,
1985 groupId, orderByComparator, true);
1986
1987 array[1] = wikiNode;
1988
1989 array[2] = filterGetByGroupId_PrevAndNext(session, wikiNode,
1990 groupId, orderByComparator, false);
1991
1992 return array;
1993 }
1994 catch (Exception e) {
1995 throw processException(e);
1996 }
1997 finally {
1998 closeSession(session);
1999 }
2000 }
2001
2002 protected WikiNode filterGetByGroupId_PrevAndNext(Session session,
2003 WikiNode wikiNode, long groupId,
2004 OrderByComparator<WikiNode> orderByComparator, boolean previous) {
2005 StringBundler query = null;
2006
2007 if (orderByComparator != null) {
2008 query = new StringBundler(6 +
2009 (orderByComparator.getOrderByFields().length * 6));
2010 }
2011 else {
2012 query = new StringBundler(3);
2013 }
2014
2015 if (getDB().isSupportsInlineDistinct()) {
2016 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
2017 }
2018 else {
2019 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
2020 }
2021
2022 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2023
2024 if (!getDB().isSupportsInlineDistinct()) {
2025 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
2026 }
2027
2028 if (orderByComparator != null) {
2029 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2030
2031 if (orderByConditionFields.length > 0) {
2032 query.append(WHERE_AND);
2033 }
2034
2035 for (int i = 0; i < orderByConditionFields.length; i++) {
2036 if (getDB().isSupportsInlineDistinct()) {
2037 query.append(_ORDER_BY_ENTITY_ALIAS);
2038 }
2039 else {
2040 query.append(_ORDER_BY_ENTITY_TABLE);
2041 }
2042
2043 query.append(orderByConditionFields[i]);
2044
2045 if ((i + 1) < orderByConditionFields.length) {
2046 if (orderByComparator.isAscending() ^ previous) {
2047 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2048 }
2049 else {
2050 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2051 }
2052 }
2053 else {
2054 if (orderByComparator.isAscending() ^ previous) {
2055 query.append(WHERE_GREATER_THAN);
2056 }
2057 else {
2058 query.append(WHERE_LESSER_THAN);
2059 }
2060 }
2061 }
2062
2063 query.append(ORDER_BY_CLAUSE);
2064
2065 String[] orderByFields = orderByComparator.getOrderByFields();
2066
2067 for (int i = 0; i < orderByFields.length; i++) {
2068 if (getDB().isSupportsInlineDistinct()) {
2069 query.append(_ORDER_BY_ENTITY_ALIAS);
2070 }
2071 else {
2072 query.append(_ORDER_BY_ENTITY_TABLE);
2073 }
2074
2075 query.append(orderByFields[i]);
2076
2077 if ((i + 1) < orderByFields.length) {
2078 if (orderByComparator.isAscending() ^ previous) {
2079 query.append(ORDER_BY_ASC_HAS_NEXT);
2080 }
2081 else {
2082 query.append(ORDER_BY_DESC_HAS_NEXT);
2083 }
2084 }
2085 else {
2086 if (orderByComparator.isAscending() ^ previous) {
2087 query.append(ORDER_BY_ASC);
2088 }
2089 else {
2090 query.append(ORDER_BY_DESC);
2091 }
2092 }
2093 }
2094 }
2095 else {
2096 if (getDB().isSupportsInlineDistinct()) {
2097 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2098 }
2099 else {
2100 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
2101 }
2102 }
2103
2104 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2105 WikiNode.class.getName(),
2106 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2107
2108 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2109
2110 q.setFirstResult(0);
2111 q.setMaxResults(2);
2112
2113 if (getDB().isSupportsInlineDistinct()) {
2114 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
2115 }
2116 else {
2117 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
2118 }
2119
2120 QueryPos qPos = QueryPos.getInstance(q);
2121
2122 qPos.add(groupId);
2123
2124 if (orderByComparator != null) {
2125 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
2126
2127 for (Object value : values) {
2128 qPos.add(value);
2129 }
2130 }
2131
2132 List<WikiNode> list = q.list();
2133
2134 if (list.size() == 2) {
2135 return list.get(1);
2136 }
2137 else {
2138 return null;
2139 }
2140 }
2141
2142
2147 @Override
2148 public void removeByGroupId(long groupId) {
2149 for (WikiNode wikiNode : findByGroupId(groupId, QueryUtil.ALL_POS,
2150 QueryUtil.ALL_POS, null)) {
2151 remove(wikiNode);
2152 }
2153 }
2154
2155
2161 @Override
2162 public int countByGroupId(long groupId) {
2163 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2164
2165 Object[] finderArgs = new Object[] { groupId };
2166
2167 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2168 this);
2169
2170 if (count == null) {
2171 StringBundler query = new StringBundler(2);
2172
2173 query.append(_SQL_COUNT_WIKINODE_WHERE);
2174
2175 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2176
2177 String sql = query.toString();
2178
2179 Session session = null;
2180
2181 try {
2182 session = openSession();
2183
2184 Query q = session.createQuery(sql);
2185
2186 QueryPos qPos = QueryPos.getInstance(q);
2187
2188 qPos.add(groupId);
2189
2190 count = (Long)q.uniqueResult();
2191
2192 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2193 }
2194 catch (Exception e) {
2195 FinderCacheUtil.removeResult(finderPath, finderArgs);
2196
2197 throw processException(e);
2198 }
2199 finally {
2200 closeSession(session);
2201 }
2202 }
2203
2204 return count.intValue();
2205 }
2206
2207
2213 @Override
2214 public int filterCountByGroupId(long groupId) {
2215 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2216 return countByGroupId(groupId);
2217 }
2218
2219 StringBundler query = new StringBundler(2);
2220
2221 query.append(_FILTER_SQL_COUNT_WIKINODE_WHERE);
2222
2223 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2224
2225 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2226 WikiNode.class.getName(),
2227 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2228
2229 Session session = null;
2230
2231 try {
2232 session = openSession();
2233
2234 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2235
2236 q.addScalar(COUNT_COLUMN_NAME,
2237 com.liferay.portal.kernel.dao.orm.Type.LONG);
2238
2239 QueryPos qPos = QueryPos.getInstance(q);
2240
2241 qPos.add(groupId);
2242
2243 Long count = (Long)q.uniqueResult();
2244
2245 return count.intValue();
2246 }
2247 catch (Exception e) {
2248 throw processException(e);
2249 }
2250 finally {
2251 closeSession(session);
2252 }
2253 }
2254
2255 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "wikiNode.groupId = ?";
2256 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2257 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2258 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2259 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2260 new String[] {
2261 Long.class.getName(),
2262
2263 Integer.class.getName(), Integer.class.getName(),
2264 OrderByComparator.class.getName()
2265 });
2266 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2267 new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2268 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2269 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2270 new String[] { Long.class.getName() },
2271 WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK |
2272 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
2273 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2274 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2275 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2276 new String[] { Long.class.getName() });
2277
2278
2284 @Override
2285 public List<WikiNode> findByCompanyId(long companyId) {
2286 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2287 null);
2288 }
2289
2290
2302 @Override
2303 public List<WikiNode> findByCompanyId(long companyId, int start, int end) {
2304 return findByCompanyId(companyId, start, end, null);
2305 }
2306
2307
2320 @Override
2321 public List<WikiNode> findByCompanyId(long companyId, int start, int end,
2322 OrderByComparator<WikiNode> orderByComparator) {
2323 boolean pagination = true;
2324 FinderPath finderPath = null;
2325 Object[] finderArgs = null;
2326
2327 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2328 (orderByComparator == null)) {
2329 pagination = false;
2330 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2331 finderArgs = new Object[] { companyId };
2332 }
2333 else {
2334 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2335 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2336 }
2337
2338 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
2339 finderArgs, this);
2340
2341 if ((list != null) && !list.isEmpty()) {
2342 for (WikiNode wikiNode : list) {
2343 if ((companyId != wikiNode.getCompanyId())) {
2344 list = null;
2345
2346 break;
2347 }
2348 }
2349 }
2350
2351 if (list == null) {
2352 StringBundler query = null;
2353
2354 if (orderByComparator != null) {
2355 query = new StringBundler(3 +
2356 (orderByComparator.getOrderByFields().length * 3));
2357 }
2358 else {
2359 query = new StringBundler(3);
2360 }
2361
2362 query.append(_SQL_SELECT_WIKINODE_WHERE);
2363
2364 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2365
2366 if (orderByComparator != null) {
2367 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2368 orderByComparator);
2369 }
2370 else
2371 if (pagination) {
2372 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2373 }
2374
2375 String sql = query.toString();
2376
2377 Session session = null;
2378
2379 try {
2380 session = openSession();
2381
2382 Query q = session.createQuery(sql);
2383
2384 QueryPos qPos = QueryPos.getInstance(q);
2385
2386 qPos.add(companyId);
2387
2388 if (!pagination) {
2389 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
2390 start, end, false);
2391
2392 Collections.sort(list);
2393
2394 list = Collections.unmodifiableList(list);
2395 }
2396 else {
2397 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
2398 start, end);
2399 }
2400
2401 cacheResult(list);
2402
2403 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2404 }
2405 catch (Exception e) {
2406 FinderCacheUtil.removeResult(finderPath, finderArgs);
2407
2408 throw processException(e);
2409 }
2410 finally {
2411 closeSession(session);
2412 }
2413 }
2414
2415 return list;
2416 }
2417
2418
2426 @Override
2427 public WikiNode findByCompanyId_First(long companyId,
2428 OrderByComparator<WikiNode> orderByComparator)
2429 throws NoSuchNodeException {
2430 WikiNode wikiNode = fetchByCompanyId_First(companyId, orderByComparator);
2431
2432 if (wikiNode != null) {
2433 return wikiNode;
2434 }
2435
2436 StringBundler msg = new StringBundler(4);
2437
2438 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2439
2440 msg.append("companyId=");
2441 msg.append(companyId);
2442
2443 msg.append(StringPool.CLOSE_CURLY_BRACE);
2444
2445 throw new NoSuchNodeException(msg.toString());
2446 }
2447
2448
2455 @Override
2456 public WikiNode fetchByCompanyId_First(long companyId,
2457 OrderByComparator<WikiNode> orderByComparator) {
2458 List<WikiNode> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2459
2460 if (!list.isEmpty()) {
2461 return list.get(0);
2462 }
2463
2464 return null;
2465 }
2466
2467
2475 @Override
2476 public WikiNode findByCompanyId_Last(long companyId,
2477 OrderByComparator<WikiNode> orderByComparator)
2478 throws NoSuchNodeException {
2479 WikiNode wikiNode = fetchByCompanyId_Last(companyId, orderByComparator);
2480
2481 if (wikiNode != null) {
2482 return wikiNode;
2483 }
2484
2485 StringBundler msg = new StringBundler(4);
2486
2487 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2488
2489 msg.append("companyId=");
2490 msg.append(companyId);
2491
2492 msg.append(StringPool.CLOSE_CURLY_BRACE);
2493
2494 throw new NoSuchNodeException(msg.toString());
2495 }
2496
2497
2504 @Override
2505 public WikiNode fetchByCompanyId_Last(long companyId,
2506 OrderByComparator<WikiNode> orderByComparator) {
2507 int count = countByCompanyId(companyId);
2508
2509 if (count == 0) {
2510 return null;
2511 }
2512
2513 List<WikiNode> list = findByCompanyId(companyId, count - 1, count,
2514 orderByComparator);
2515
2516 if (!list.isEmpty()) {
2517 return list.get(0);
2518 }
2519
2520 return null;
2521 }
2522
2523
2532 @Override
2533 public WikiNode[] findByCompanyId_PrevAndNext(long nodeId, long companyId,
2534 OrderByComparator<WikiNode> orderByComparator)
2535 throws NoSuchNodeException {
2536 WikiNode wikiNode = findByPrimaryKey(nodeId);
2537
2538 Session session = null;
2539
2540 try {
2541 session = openSession();
2542
2543 WikiNode[] array = new WikiNodeImpl[3];
2544
2545 array[0] = getByCompanyId_PrevAndNext(session, wikiNode, companyId,
2546 orderByComparator, true);
2547
2548 array[1] = wikiNode;
2549
2550 array[2] = getByCompanyId_PrevAndNext(session, wikiNode, companyId,
2551 orderByComparator, false);
2552
2553 return array;
2554 }
2555 catch (Exception e) {
2556 throw processException(e);
2557 }
2558 finally {
2559 closeSession(session);
2560 }
2561 }
2562
2563 protected WikiNode getByCompanyId_PrevAndNext(Session session,
2564 WikiNode wikiNode, long companyId,
2565 OrderByComparator<WikiNode> orderByComparator, boolean previous) {
2566 StringBundler query = null;
2567
2568 if (orderByComparator != null) {
2569 query = new StringBundler(6 +
2570 (orderByComparator.getOrderByFields().length * 6));
2571 }
2572 else {
2573 query = new StringBundler(3);
2574 }
2575
2576 query.append(_SQL_SELECT_WIKINODE_WHERE);
2577
2578 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2579
2580 if (orderByComparator != null) {
2581 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2582
2583 if (orderByConditionFields.length > 0) {
2584 query.append(WHERE_AND);
2585 }
2586
2587 for (int i = 0; i < orderByConditionFields.length; i++) {
2588 query.append(_ORDER_BY_ENTITY_ALIAS);
2589 query.append(orderByConditionFields[i]);
2590
2591 if ((i + 1) < orderByConditionFields.length) {
2592 if (orderByComparator.isAscending() ^ previous) {
2593 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2594 }
2595 else {
2596 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2597 }
2598 }
2599 else {
2600 if (orderByComparator.isAscending() ^ previous) {
2601 query.append(WHERE_GREATER_THAN);
2602 }
2603 else {
2604 query.append(WHERE_LESSER_THAN);
2605 }
2606 }
2607 }
2608
2609 query.append(ORDER_BY_CLAUSE);
2610
2611 String[] orderByFields = orderByComparator.getOrderByFields();
2612
2613 for (int i = 0; i < orderByFields.length; i++) {
2614 query.append(_ORDER_BY_ENTITY_ALIAS);
2615 query.append(orderByFields[i]);
2616
2617 if ((i + 1) < orderByFields.length) {
2618 if (orderByComparator.isAscending() ^ previous) {
2619 query.append(ORDER_BY_ASC_HAS_NEXT);
2620 }
2621 else {
2622 query.append(ORDER_BY_DESC_HAS_NEXT);
2623 }
2624 }
2625 else {
2626 if (orderByComparator.isAscending() ^ previous) {
2627 query.append(ORDER_BY_ASC);
2628 }
2629 else {
2630 query.append(ORDER_BY_DESC);
2631 }
2632 }
2633 }
2634 }
2635 else {
2636 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2637 }
2638
2639 String sql = query.toString();
2640
2641 Query q = session.createQuery(sql);
2642
2643 q.setFirstResult(0);
2644 q.setMaxResults(2);
2645
2646 QueryPos qPos = QueryPos.getInstance(q);
2647
2648 qPos.add(companyId);
2649
2650 if (orderByComparator != null) {
2651 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
2652
2653 for (Object value : values) {
2654 qPos.add(value);
2655 }
2656 }
2657
2658 List<WikiNode> list = q.list();
2659
2660 if (list.size() == 2) {
2661 return list.get(1);
2662 }
2663 else {
2664 return null;
2665 }
2666 }
2667
2668
2673 @Override
2674 public void removeByCompanyId(long companyId) {
2675 for (WikiNode wikiNode : findByCompanyId(companyId, QueryUtil.ALL_POS,
2676 QueryUtil.ALL_POS, null)) {
2677 remove(wikiNode);
2678 }
2679 }
2680
2681
2687 @Override
2688 public int countByCompanyId(long companyId) {
2689 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2690
2691 Object[] finderArgs = new Object[] { companyId };
2692
2693 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2694 this);
2695
2696 if (count == null) {
2697 StringBundler query = new StringBundler(2);
2698
2699 query.append(_SQL_COUNT_WIKINODE_WHERE);
2700
2701 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2702
2703 String sql = query.toString();
2704
2705 Session session = null;
2706
2707 try {
2708 session = openSession();
2709
2710 Query q = session.createQuery(sql);
2711
2712 QueryPos qPos = QueryPos.getInstance(q);
2713
2714 qPos.add(companyId);
2715
2716 count = (Long)q.uniqueResult();
2717
2718 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2719 }
2720 catch (Exception e) {
2721 FinderCacheUtil.removeResult(finderPath, finderArgs);
2722
2723 throw processException(e);
2724 }
2725 finally {
2726 closeSession(session);
2727 }
2728 }
2729
2730 return count.intValue();
2731 }
2732
2733 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "wikiNode.companyId = ?";
2734 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2735 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2736 FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
2737 new String[] { Long.class.getName(), String.class.getName() },
2738 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
2739 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
2740 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2741 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2742 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
2743 new String[] { Long.class.getName(), String.class.getName() });
2744
2745
2753 @Override
2754 public WikiNode findByG_N(long groupId, String name)
2755 throws NoSuchNodeException {
2756 WikiNode wikiNode = fetchByG_N(groupId, name);
2757
2758 if (wikiNode == null) {
2759 StringBundler msg = new StringBundler(6);
2760
2761 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2762
2763 msg.append("groupId=");
2764 msg.append(groupId);
2765
2766 msg.append(", name=");
2767 msg.append(name);
2768
2769 msg.append(StringPool.CLOSE_CURLY_BRACE);
2770
2771 if (_log.isWarnEnabled()) {
2772 _log.warn(msg.toString());
2773 }
2774
2775 throw new NoSuchNodeException(msg.toString());
2776 }
2777
2778 return wikiNode;
2779 }
2780
2781
2788 @Override
2789 public WikiNode fetchByG_N(long groupId, String name) {
2790 return fetchByG_N(groupId, name, true);
2791 }
2792
2793
2801 @Override
2802 public WikiNode fetchByG_N(long groupId, String name,
2803 boolean retrieveFromCache) {
2804 Object[] finderArgs = new Object[] { groupId, name };
2805
2806 Object result = null;
2807
2808 if (retrieveFromCache) {
2809 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2810 finderArgs, this);
2811 }
2812
2813 if (result instanceof WikiNode) {
2814 WikiNode wikiNode = (WikiNode)result;
2815
2816 if ((groupId != wikiNode.getGroupId()) ||
2817 !Validator.equals(name, wikiNode.getName())) {
2818 result = null;
2819 }
2820 }
2821
2822 if (result == null) {
2823 StringBundler query = new StringBundler(4);
2824
2825 query.append(_SQL_SELECT_WIKINODE_WHERE);
2826
2827 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2828
2829 boolean bindName = false;
2830
2831 if (name == null) {
2832 query.append(_FINDER_COLUMN_G_N_NAME_1);
2833 }
2834 else if (name.equals(StringPool.BLANK)) {
2835 query.append(_FINDER_COLUMN_G_N_NAME_3);
2836 }
2837 else {
2838 bindName = true;
2839
2840 query.append(_FINDER_COLUMN_G_N_NAME_2);
2841 }
2842
2843 String sql = query.toString();
2844
2845 Session session = null;
2846
2847 try {
2848 session = openSession();
2849
2850 Query q = session.createQuery(sql);
2851
2852 QueryPos qPos = QueryPos.getInstance(q);
2853
2854 qPos.add(groupId);
2855
2856 if (bindName) {
2857 qPos.add(name);
2858 }
2859
2860 List<WikiNode> list = q.list();
2861
2862 if (list.isEmpty()) {
2863 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2864 finderArgs, list);
2865 }
2866 else {
2867 WikiNode wikiNode = list.get(0);
2868
2869 result = wikiNode;
2870
2871 cacheResult(wikiNode);
2872
2873 if ((wikiNode.getGroupId() != groupId) ||
2874 (wikiNode.getName() == null) ||
2875 !wikiNode.getName().equals(name)) {
2876 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2877 finderArgs, wikiNode);
2878 }
2879 }
2880 }
2881 catch (Exception e) {
2882 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2883 finderArgs);
2884
2885 throw processException(e);
2886 }
2887 finally {
2888 closeSession(session);
2889 }
2890 }
2891
2892 if (result instanceof List<?>) {
2893 return null;
2894 }
2895 else {
2896 return (WikiNode)result;
2897 }
2898 }
2899
2900
2907 @Override
2908 public WikiNode removeByG_N(long groupId, String name)
2909 throws NoSuchNodeException {
2910 WikiNode wikiNode = findByG_N(groupId, name);
2911
2912 return remove(wikiNode);
2913 }
2914
2915
2922 @Override
2923 public int countByG_N(long groupId, String name) {
2924 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
2925
2926 Object[] finderArgs = new Object[] { groupId, name };
2927
2928 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2929 this);
2930
2931 if (count == null) {
2932 StringBundler query = new StringBundler(3);
2933
2934 query.append(_SQL_COUNT_WIKINODE_WHERE);
2935
2936 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2937
2938 boolean bindName = false;
2939
2940 if (name == null) {
2941 query.append(_FINDER_COLUMN_G_N_NAME_1);
2942 }
2943 else if (name.equals(StringPool.BLANK)) {
2944 query.append(_FINDER_COLUMN_G_N_NAME_3);
2945 }
2946 else {
2947 bindName = true;
2948
2949 query.append(_FINDER_COLUMN_G_N_NAME_2);
2950 }
2951
2952 String sql = query.toString();
2953
2954 Session session = null;
2955
2956 try {
2957 session = openSession();
2958
2959 Query q = session.createQuery(sql);
2960
2961 QueryPos qPos = QueryPos.getInstance(q);
2962
2963 qPos.add(groupId);
2964
2965 if (bindName) {
2966 qPos.add(name);
2967 }
2968
2969 count = (Long)q.uniqueResult();
2970
2971 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2972 }
2973 catch (Exception e) {
2974 FinderCacheUtil.removeResult(finderPath, finderArgs);
2975
2976 throw processException(e);
2977 }
2978 finally {
2979 closeSession(session);
2980 }
2981 }
2982
2983 return count.intValue();
2984 }
2985
2986 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "wikiNode.groupId = ? AND ";
2987 private static final String _FINDER_COLUMN_G_N_NAME_1 = "wikiNode.name IS NULL";
2988 private static final String _FINDER_COLUMN_G_N_NAME_2 = "wikiNode.name = ?";
2989 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(wikiNode.name IS NULL OR wikiNode.name = '')";
2990 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
2991 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
2992 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
2993 new String[] {
2994 Long.class.getName(), Integer.class.getName(),
2995
2996 Integer.class.getName(), Integer.class.getName(),
2997 OrderByComparator.class.getName()
2998 });
2999 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
3000 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
3001 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
3002 new String[] { Long.class.getName(), Integer.class.getName() },
3003 WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
3004 WikiNodeModelImpl.STATUS_COLUMN_BITMASK |
3005 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
3006 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
3007 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
3008 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
3009 new String[] { Long.class.getName(), Integer.class.getName() });
3010
3011
3018 @Override
3019 public List<WikiNode> findByG_S(long groupId, int status) {
3020 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3021 null);
3022 }
3023
3024
3037 @Override
3038 public List<WikiNode> findByG_S(long groupId, int status, int start, int end) {
3039 return findByG_S(groupId, status, start, end, null);
3040 }
3041
3042
3056 @Override
3057 public List<WikiNode> findByG_S(long groupId, int status, int start,
3058 int end, OrderByComparator<WikiNode> orderByComparator) {
3059 boolean pagination = true;
3060 FinderPath finderPath = null;
3061 Object[] finderArgs = null;
3062
3063 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3064 (orderByComparator == null)) {
3065 pagination = false;
3066 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
3067 finderArgs = new Object[] { groupId, status };
3068 }
3069 else {
3070 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
3071 finderArgs = new Object[] {
3072 groupId, status,
3073
3074 start, end, orderByComparator
3075 };
3076 }
3077
3078 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
3079 finderArgs, this);
3080
3081 if ((list != null) && !list.isEmpty()) {
3082 for (WikiNode wikiNode : list) {
3083 if ((groupId != wikiNode.getGroupId()) ||
3084 (status != wikiNode.getStatus())) {
3085 list = null;
3086
3087 break;
3088 }
3089 }
3090 }
3091
3092 if (list == null) {
3093 StringBundler query = null;
3094
3095 if (orderByComparator != null) {
3096 query = new StringBundler(4 +
3097 (orderByComparator.getOrderByFields().length * 3));
3098 }
3099 else {
3100 query = new StringBundler(4);
3101 }
3102
3103 query.append(_SQL_SELECT_WIKINODE_WHERE);
3104
3105 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3106
3107 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3108
3109 if (orderByComparator != null) {
3110 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3111 orderByComparator);
3112 }
3113 else
3114 if (pagination) {
3115 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3116 }
3117
3118 String sql = query.toString();
3119
3120 Session session = null;
3121
3122 try {
3123 session = openSession();
3124
3125 Query q = session.createQuery(sql);
3126
3127 QueryPos qPos = QueryPos.getInstance(q);
3128
3129 qPos.add(groupId);
3130
3131 qPos.add(status);
3132
3133 if (!pagination) {
3134 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
3135 start, end, false);
3136
3137 Collections.sort(list);
3138
3139 list = Collections.unmodifiableList(list);
3140 }
3141 else {
3142 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
3143 start, end);
3144 }
3145
3146 cacheResult(list);
3147
3148 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3149 }
3150 catch (Exception e) {
3151 FinderCacheUtil.removeResult(finderPath, finderArgs);
3152
3153 throw processException(e);
3154 }
3155 finally {
3156 closeSession(session);
3157 }
3158 }
3159
3160 return list;
3161 }
3162
3163
3172 @Override
3173 public WikiNode findByG_S_First(long groupId, int status,
3174 OrderByComparator<WikiNode> orderByComparator)
3175 throws NoSuchNodeException {
3176 WikiNode wikiNode = fetchByG_S_First(groupId, status, orderByComparator);
3177
3178 if (wikiNode != null) {
3179 return wikiNode;
3180 }
3181
3182 StringBundler msg = new StringBundler(6);
3183
3184 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3185
3186 msg.append("groupId=");
3187 msg.append(groupId);
3188
3189 msg.append(", status=");
3190 msg.append(status);
3191
3192 msg.append(StringPool.CLOSE_CURLY_BRACE);
3193
3194 throw new NoSuchNodeException(msg.toString());
3195 }
3196
3197
3205 @Override
3206 public WikiNode fetchByG_S_First(long groupId, int status,
3207 OrderByComparator<WikiNode> orderByComparator) {
3208 List<WikiNode> list = findByG_S(groupId, status, 0, 1, orderByComparator);
3209
3210 if (!list.isEmpty()) {
3211 return list.get(0);
3212 }
3213
3214 return null;
3215 }
3216
3217
3226 @Override
3227 public WikiNode findByG_S_Last(long groupId, int status,
3228 OrderByComparator<WikiNode> orderByComparator)
3229 throws NoSuchNodeException {
3230 WikiNode wikiNode = fetchByG_S_Last(groupId, status, orderByComparator);
3231
3232 if (wikiNode != null) {
3233 return wikiNode;
3234 }
3235
3236 StringBundler msg = new StringBundler(6);
3237
3238 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3239
3240 msg.append("groupId=");
3241 msg.append(groupId);
3242
3243 msg.append(", status=");
3244 msg.append(status);
3245
3246 msg.append(StringPool.CLOSE_CURLY_BRACE);
3247
3248 throw new NoSuchNodeException(msg.toString());
3249 }
3250
3251
3259 @Override
3260 public WikiNode fetchByG_S_Last(long groupId, int status,
3261 OrderByComparator<WikiNode> orderByComparator) {
3262 int count = countByG_S(groupId, status);
3263
3264 if (count == 0) {
3265 return null;
3266 }
3267
3268 List<WikiNode> list = findByG_S(groupId, status, count - 1, count,
3269 orderByComparator);
3270
3271 if (!list.isEmpty()) {
3272 return list.get(0);
3273 }
3274
3275 return null;
3276 }
3277
3278
3288 @Override
3289 public WikiNode[] findByG_S_PrevAndNext(long nodeId, long groupId,
3290 int status, OrderByComparator<WikiNode> orderByComparator)
3291 throws NoSuchNodeException {
3292 WikiNode wikiNode = findByPrimaryKey(nodeId);
3293
3294 Session session = null;
3295
3296 try {
3297 session = openSession();
3298
3299 WikiNode[] array = new WikiNodeImpl[3];
3300
3301 array[0] = getByG_S_PrevAndNext(session, wikiNode, groupId, status,
3302 orderByComparator, true);
3303
3304 array[1] = wikiNode;
3305
3306 array[2] = getByG_S_PrevAndNext(session, wikiNode, groupId, status,
3307 orderByComparator, false);
3308
3309 return array;
3310 }
3311 catch (Exception e) {
3312 throw processException(e);
3313 }
3314 finally {
3315 closeSession(session);
3316 }
3317 }
3318
3319 protected WikiNode getByG_S_PrevAndNext(Session session, WikiNode wikiNode,
3320 long groupId, int status,
3321 OrderByComparator<WikiNode> orderByComparator, boolean previous) {
3322 StringBundler query = null;
3323
3324 if (orderByComparator != null) {
3325 query = new StringBundler(6 +
3326 (orderByComparator.getOrderByFields().length * 6));
3327 }
3328 else {
3329 query = new StringBundler(3);
3330 }
3331
3332 query.append(_SQL_SELECT_WIKINODE_WHERE);
3333
3334 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3335
3336 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3337
3338 if (orderByComparator != null) {
3339 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3340
3341 if (orderByConditionFields.length > 0) {
3342 query.append(WHERE_AND);
3343 }
3344
3345 for (int i = 0; i < orderByConditionFields.length; i++) {
3346 query.append(_ORDER_BY_ENTITY_ALIAS);
3347 query.append(orderByConditionFields[i]);
3348
3349 if ((i + 1) < orderByConditionFields.length) {
3350 if (orderByComparator.isAscending() ^ previous) {
3351 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3352 }
3353 else {
3354 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3355 }
3356 }
3357 else {
3358 if (orderByComparator.isAscending() ^ previous) {
3359 query.append(WHERE_GREATER_THAN);
3360 }
3361 else {
3362 query.append(WHERE_LESSER_THAN);
3363 }
3364 }
3365 }
3366
3367 query.append(ORDER_BY_CLAUSE);
3368
3369 String[] orderByFields = orderByComparator.getOrderByFields();
3370
3371 for (int i = 0; i < orderByFields.length; i++) {
3372 query.append(_ORDER_BY_ENTITY_ALIAS);
3373 query.append(orderByFields[i]);
3374
3375 if ((i + 1) < orderByFields.length) {
3376 if (orderByComparator.isAscending() ^ previous) {
3377 query.append(ORDER_BY_ASC_HAS_NEXT);
3378 }
3379 else {
3380 query.append(ORDER_BY_DESC_HAS_NEXT);
3381 }
3382 }
3383 else {
3384 if (orderByComparator.isAscending() ^ previous) {
3385 query.append(ORDER_BY_ASC);
3386 }
3387 else {
3388 query.append(ORDER_BY_DESC);
3389 }
3390 }
3391 }
3392 }
3393 else {
3394 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3395 }
3396
3397 String sql = query.toString();
3398
3399 Query q = session.createQuery(sql);
3400
3401 q.setFirstResult(0);
3402 q.setMaxResults(2);
3403
3404 QueryPos qPos = QueryPos.getInstance(q);
3405
3406 qPos.add(groupId);
3407
3408 qPos.add(status);
3409
3410 if (orderByComparator != null) {
3411 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
3412
3413 for (Object value : values) {
3414 qPos.add(value);
3415 }
3416 }
3417
3418 List<WikiNode> list = q.list();
3419
3420 if (list.size() == 2) {
3421 return list.get(1);
3422 }
3423 else {
3424 return null;
3425 }
3426 }
3427
3428
3435 @Override
3436 public List<WikiNode> filterFindByG_S(long groupId, int status) {
3437 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
3438 QueryUtil.ALL_POS, null);
3439 }
3440
3441
3454 @Override
3455 public List<WikiNode> filterFindByG_S(long groupId, int status, int start,
3456 int end) {
3457 return filterFindByG_S(groupId, status, start, end, null);
3458 }
3459
3460
3474 @Override
3475 public List<WikiNode> filterFindByG_S(long groupId, int status, int start,
3476 int end, OrderByComparator<WikiNode> orderByComparator) {
3477 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3478 return findByG_S(groupId, status, start, end, orderByComparator);
3479 }
3480
3481 StringBundler query = null;
3482
3483 if (orderByComparator != null) {
3484 query = new StringBundler(4 +
3485 (orderByComparator.getOrderByFields().length * 3));
3486 }
3487 else {
3488 query = new StringBundler(4);
3489 }
3490
3491 if (getDB().isSupportsInlineDistinct()) {
3492 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
3493 }
3494 else {
3495 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
3496 }
3497
3498 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3499
3500 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3501
3502 if (!getDB().isSupportsInlineDistinct()) {
3503 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
3504 }
3505
3506 if (orderByComparator != null) {
3507 if (getDB().isSupportsInlineDistinct()) {
3508 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3509 orderByComparator, true);
3510 }
3511 else {
3512 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3513 orderByComparator, true);
3514 }
3515 }
3516 else {
3517 if (getDB().isSupportsInlineDistinct()) {
3518 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3519 }
3520 else {
3521 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
3522 }
3523 }
3524
3525 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3526 WikiNode.class.getName(),
3527 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3528
3529 Session session = null;
3530
3531 try {
3532 session = openSession();
3533
3534 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3535
3536 if (getDB().isSupportsInlineDistinct()) {
3537 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
3538 }
3539 else {
3540 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
3541 }
3542
3543 QueryPos qPos = QueryPos.getInstance(q);
3544
3545 qPos.add(groupId);
3546
3547 qPos.add(status);
3548
3549 return (List<WikiNode>)QueryUtil.list(q, getDialect(), start, end);
3550 }
3551 catch (Exception e) {
3552 throw processException(e);
3553 }
3554 finally {
3555 closeSession(session);
3556 }
3557 }
3558
3559
3569 @Override
3570 public WikiNode[] filterFindByG_S_PrevAndNext(long nodeId, long groupId,
3571 int status, OrderByComparator<WikiNode> orderByComparator)
3572 throws NoSuchNodeException {
3573 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3574 return findByG_S_PrevAndNext(nodeId, groupId, status,
3575 orderByComparator);
3576 }
3577
3578 WikiNode wikiNode = findByPrimaryKey(nodeId);
3579
3580 Session session = null;
3581
3582 try {
3583 session = openSession();
3584
3585 WikiNode[] array = new WikiNodeImpl[3];
3586
3587 array[0] = filterGetByG_S_PrevAndNext(session, wikiNode, groupId,
3588 status, orderByComparator, true);
3589
3590 array[1] = wikiNode;
3591
3592 array[2] = filterGetByG_S_PrevAndNext(session, wikiNode, groupId,
3593 status, orderByComparator, false);
3594
3595 return array;
3596 }
3597 catch (Exception e) {
3598 throw processException(e);
3599 }
3600 finally {
3601 closeSession(session);
3602 }
3603 }
3604
3605 protected WikiNode filterGetByG_S_PrevAndNext(Session session,
3606 WikiNode wikiNode, long groupId, int status,
3607 OrderByComparator<WikiNode> orderByComparator, boolean previous) {
3608 StringBundler query = null;
3609
3610 if (orderByComparator != null) {
3611 query = new StringBundler(6 +
3612 (orderByComparator.getOrderByFields().length * 6));
3613 }
3614 else {
3615 query = new StringBundler(3);
3616 }
3617
3618 if (getDB().isSupportsInlineDistinct()) {
3619 query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
3620 }
3621 else {
3622 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
3623 }
3624
3625 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3626
3627 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3628
3629 if (!getDB().isSupportsInlineDistinct()) {
3630 query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
3631 }
3632
3633 if (orderByComparator != null) {
3634 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3635
3636 if (orderByConditionFields.length > 0) {
3637 query.append(WHERE_AND);
3638 }
3639
3640 for (int i = 0; i < orderByConditionFields.length; i++) {
3641 if (getDB().isSupportsInlineDistinct()) {
3642 query.append(_ORDER_BY_ENTITY_ALIAS);
3643 }
3644 else {
3645 query.append(_ORDER_BY_ENTITY_TABLE);
3646 }
3647
3648 query.append(orderByConditionFields[i]);
3649
3650 if ((i + 1) < orderByConditionFields.length) {
3651 if (orderByComparator.isAscending() ^ previous) {
3652 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3653 }
3654 else {
3655 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3656 }
3657 }
3658 else {
3659 if (orderByComparator.isAscending() ^ previous) {
3660 query.append(WHERE_GREATER_THAN);
3661 }
3662 else {
3663 query.append(WHERE_LESSER_THAN);
3664 }
3665 }
3666 }
3667
3668 query.append(ORDER_BY_CLAUSE);
3669
3670 String[] orderByFields = orderByComparator.getOrderByFields();
3671
3672 for (int i = 0; i < orderByFields.length; i++) {
3673 if (getDB().isSupportsInlineDistinct()) {
3674 query.append(_ORDER_BY_ENTITY_ALIAS);
3675 }
3676 else {
3677 query.append(_ORDER_BY_ENTITY_TABLE);
3678 }
3679
3680 query.append(orderByFields[i]);
3681
3682 if ((i + 1) < orderByFields.length) {
3683 if (orderByComparator.isAscending() ^ previous) {
3684 query.append(ORDER_BY_ASC_HAS_NEXT);
3685 }
3686 else {
3687 query.append(ORDER_BY_DESC_HAS_NEXT);
3688 }
3689 }
3690 else {
3691 if (orderByComparator.isAscending() ^ previous) {
3692 query.append(ORDER_BY_ASC);
3693 }
3694 else {
3695 query.append(ORDER_BY_DESC);
3696 }
3697 }
3698 }
3699 }
3700 else {
3701 if (getDB().isSupportsInlineDistinct()) {
3702 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3703 }
3704 else {
3705 query.append(WikiNodeModelImpl.ORDER_BY_SQL);
3706 }
3707 }
3708
3709 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3710 WikiNode.class.getName(),
3711 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3712
3713 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3714
3715 q.setFirstResult(0);
3716 q.setMaxResults(2);
3717
3718 if (getDB().isSupportsInlineDistinct()) {
3719 q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
3720 }
3721 else {
3722 q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
3723 }
3724
3725 QueryPos qPos = QueryPos.getInstance(q);
3726
3727 qPos.add(groupId);
3728
3729 qPos.add(status);
3730
3731 if (orderByComparator != null) {
3732 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
3733
3734 for (Object value : values) {
3735 qPos.add(value);
3736 }
3737 }
3738
3739 List<WikiNode> list = q.list();
3740
3741 if (list.size() == 2) {
3742 return list.get(1);
3743 }
3744 else {
3745 return null;
3746 }
3747 }
3748
3749
3755 @Override
3756 public void removeByG_S(long groupId, int status) {
3757 for (WikiNode wikiNode : findByG_S(groupId, status, QueryUtil.ALL_POS,
3758 QueryUtil.ALL_POS, null)) {
3759 remove(wikiNode);
3760 }
3761 }
3762
3763
3770 @Override
3771 public int countByG_S(long groupId, int status) {
3772 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
3773
3774 Object[] finderArgs = new Object[] { groupId, status };
3775
3776 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3777 this);
3778
3779 if (count == null) {
3780 StringBundler query = new StringBundler(3);
3781
3782 query.append(_SQL_COUNT_WIKINODE_WHERE);
3783
3784 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3785
3786 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3787
3788 String sql = query.toString();
3789
3790 Session session = null;
3791
3792 try {
3793 session = openSession();
3794
3795 Query q = session.createQuery(sql);
3796
3797 QueryPos qPos = QueryPos.getInstance(q);
3798
3799 qPos.add(groupId);
3800
3801 qPos.add(status);
3802
3803 count = (Long)q.uniqueResult();
3804
3805 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3806 }
3807 catch (Exception e) {
3808 FinderCacheUtil.removeResult(finderPath, finderArgs);
3809
3810 throw processException(e);
3811 }
3812 finally {
3813 closeSession(session);
3814 }
3815 }
3816
3817 return count.intValue();
3818 }
3819
3820
3827 @Override
3828 public int filterCountByG_S(long groupId, int status) {
3829 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3830 return countByG_S(groupId, status);
3831 }
3832
3833 StringBundler query = new StringBundler(3);
3834
3835 query.append(_FILTER_SQL_COUNT_WIKINODE_WHERE);
3836
3837 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3838
3839 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3840
3841 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3842 WikiNode.class.getName(),
3843 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3844
3845 Session session = null;
3846
3847 try {
3848 session = openSession();
3849
3850 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3851
3852 q.addScalar(COUNT_COLUMN_NAME,
3853 com.liferay.portal.kernel.dao.orm.Type.LONG);
3854
3855 QueryPos qPos = QueryPos.getInstance(q);
3856
3857 qPos.add(groupId);
3858
3859 qPos.add(status);
3860
3861 Long count = (Long)q.uniqueResult();
3862
3863 return count.intValue();
3864 }
3865 catch (Exception e) {
3866 throw processException(e);
3867 }
3868 finally {
3869 closeSession(session);
3870 }
3871 }
3872
3873 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "wikiNode.groupId = ? AND ";
3874 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "wikiNode.status = ?";
3875 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
3876 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
3877 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
3878 new String[] {
3879 Long.class.getName(), Integer.class.getName(),
3880
3881 Integer.class.getName(), Integer.class.getName(),
3882 OrderByComparator.class.getName()
3883 });
3884 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
3885 WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
3886 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
3887 new String[] { Long.class.getName(), Integer.class.getName() },
3888 WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK |
3889 WikiNodeModelImpl.STATUS_COLUMN_BITMASK |
3890 WikiNodeModelImpl.NAME_COLUMN_BITMASK);
3891 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
3892 WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
3893 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
3894 new String[] { Long.class.getName(), Integer.class.getName() });
3895
3896
3903 @Override
3904 public List<WikiNode> findByC_S(long companyId, int status) {
3905 return findByC_S(companyId, status, QueryUtil.ALL_POS,
3906 QueryUtil.ALL_POS, null);
3907 }
3908
3909
3922 @Override
3923 public List<WikiNode> findByC_S(long companyId, int status, int start,
3924 int end) {
3925 return findByC_S(companyId, status, start, end, null);
3926 }
3927
3928
3942 @Override
3943 public List<WikiNode> findByC_S(long companyId, int status, int start,
3944 int end, OrderByComparator<WikiNode> orderByComparator) {
3945 boolean pagination = true;
3946 FinderPath finderPath = null;
3947 Object[] finderArgs = null;
3948
3949 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3950 (orderByComparator == null)) {
3951 pagination = false;
3952 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
3953 finderArgs = new Object[] { companyId, status };
3954 }
3955 else {
3956 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
3957 finderArgs = new Object[] {
3958 companyId, status,
3959
3960 start, end, orderByComparator
3961 };
3962 }
3963
3964 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
3965 finderArgs, this);
3966
3967 if ((list != null) && !list.isEmpty()) {
3968 for (WikiNode wikiNode : list) {
3969 if ((companyId != wikiNode.getCompanyId()) ||
3970 (status != wikiNode.getStatus())) {
3971 list = null;
3972
3973 break;
3974 }
3975 }
3976 }
3977
3978 if (list == null) {
3979 StringBundler query = null;
3980
3981 if (orderByComparator != null) {
3982 query = new StringBundler(4 +
3983 (orderByComparator.getOrderByFields().length * 3));
3984 }
3985 else {
3986 query = new StringBundler(4);
3987 }
3988
3989 query.append(_SQL_SELECT_WIKINODE_WHERE);
3990
3991 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3992
3993 query.append(_FINDER_COLUMN_C_S_STATUS_2);
3994
3995 if (orderByComparator != null) {
3996 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3997 orderByComparator);
3998 }
3999 else
4000 if (pagination) {
4001 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
4002 }
4003
4004 String sql = query.toString();
4005
4006 Session session = null;
4007
4008 try {
4009 session = openSession();
4010
4011 Query q = session.createQuery(sql);
4012
4013 QueryPos qPos = QueryPos.getInstance(q);
4014
4015 qPos.add(companyId);
4016
4017 qPos.add(status);
4018
4019 if (!pagination) {
4020 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
4021 start, end, false);
4022
4023 Collections.sort(list);
4024
4025 list = Collections.unmodifiableList(list);
4026 }
4027 else {
4028 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
4029 start, end);
4030 }
4031
4032 cacheResult(list);
4033
4034 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4035 }
4036 catch (Exception e) {
4037 FinderCacheUtil.removeResult(finderPath, finderArgs);
4038
4039 throw processException(e);
4040 }
4041 finally {
4042 closeSession(session);
4043 }
4044 }
4045
4046 return list;
4047 }
4048
4049
4058 @Override
4059 public WikiNode findByC_S_First(long companyId, int status,
4060 OrderByComparator<WikiNode> orderByComparator)
4061 throws NoSuchNodeException {
4062 WikiNode wikiNode = fetchByC_S_First(companyId, status,
4063 orderByComparator);
4064
4065 if (wikiNode != null) {
4066 return wikiNode;
4067 }
4068
4069 StringBundler msg = new StringBundler(6);
4070
4071 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4072
4073 msg.append("companyId=");
4074 msg.append(companyId);
4075
4076 msg.append(", status=");
4077 msg.append(status);
4078
4079 msg.append(StringPool.CLOSE_CURLY_BRACE);
4080
4081 throw new NoSuchNodeException(msg.toString());
4082 }
4083
4084
4092 @Override
4093 public WikiNode fetchByC_S_First(long companyId, int status,
4094 OrderByComparator<WikiNode> orderByComparator) {
4095 List<WikiNode> list = findByC_S(companyId, status, 0, 1,
4096 orderByComparator);
4097
4098 if (!list.isEmpty()) {
4099 return list.get(0);
4100 }
4101
4102 return null;
4103 }
4104
4105
4114 @Override
4115 public WikiNode findByC_S_Last(long companyId, int status,
4116 OrderByComparator<WikiNode> orderByComparator)
4117 throws NoSuchNodeException {
4118 WikiNode wikiNode = fetchByC_S_Last(companyId, status, orderByComparator);
4119
4120 if (wikiNode != null) {
4121 return wikiNode;
4122 }
4123
4124 StringBundler msg = new StringBundler(6);
4125
4126 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4127
4128 msg.append("companyId=");
4129 msg.append(companyId);
4130
4131 msg.append(", status=");
4132 msg.append(status);
4133
4134 msg.append(StringPool.CLOSE_CURLY_BRACE);
4135
4136 throw new NoSuchNodeException(msg.toString());
4137 }
4138
4139
4147 @Override
4148 public WikiNode fetchByC_S_Last(long companyId, int status,
4149 OrderByComparator<WikiNode> orderByComparator) {
4150 int count = countByC_S(companyId, status);
4151
4152 if (count == 0) {
4153 return null;
4154 }
4155
4156 List<WikiNode> list = findByC_S(companyId, status, count - 1, count,
4157 orderByComparator);
4158
4159 if (!list.isEmpty()) {
4160 return list.get(0);
4161 }
4162
4163 return null;
4164 }
4165
4166
4176 @Override
4177 public WikiNode[] findByC_S_PrevAndNext(long nodeId, long companyId,
4178 int status, OrderByComparator<WikiNode> orderByComparator)
4179 throws NoSuchNodeException {
4180 WikiNode wikiNode = findByPrimaryKey(nodeId);
4181
4182 Session session = null;
4183
4184 try {
4185 session = openSession();
4186
4187 WikiNode[] array = new WikiNodeImpl[3];
4188
4189 array[0] = getByC_S_PrevAndNext(session, wikiNode, companyId,
4190 status, orderByComparator, true);
4191
4192 array[1] = wikiNode;
4193
4194 array[2] = getByC_S_PrevAndNext(session, wikiNode, companyId,
4195 status, orderByComparator, false);
4196
4197 return array;
4198 }
4199 catch (Exception e) {
4200 throw processException(e);
4201 }
4202 finally {
4203 closeSession(session);
4204 }
4205 }
4206
4207 protected WikiNode getByC_S_PrevAndNext(Session session, WikiNode wikiNode,
4208 long companyId, int status,
4209 OrderByComparator<WikiNode> orderByComparator, boolean previous) {
4210 StringBundler query = null;
4211
4212 if (orderByComparator != null) {
4213 query = new StringBundler(6 +
4214 (orderByComparator.getOrderByFields().length * 6));
4215 }
4216 else {
4217 query = new StringBundler(3);
4218 }
4219
4220 query.append(_SQL_SELECT_WIKINODE_WHERE);
4221
4222 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4223
4224 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4225
4226 if (orderByComparator != null) {
4227 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4228
4229 if (orderByConditionFields.length > 0) {
4230 query.append(WHERE_AND);
4231 }
4232
4233 for (int i = 0; i < orderByConditionFields.length; i++) {
4234 query.append(_ORDER_BY_ENTITY_ALIAS);
4235 query.append(orderByConditionFields[i]);
4236
4237 if ((i + 1) < orderByConditionFields.length) {
4238 if (orderByComparator.isAscending() ^ previous) {
4239 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4240 }
4241 else {
4242 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4243 }
4244 }
4245 else {
4246 if (orderByComparator.isAscending() ^ previous) {
4247 query.append(WHERE_GREATER_THAN);
4248 }
4249 else {
4250 query.append(WHERE_LESSER_THAN);
4251 }
4252 }
4253 }
4254
4255 query.append(ORDER_BY_CLAUSE);
4256
4257 String[] orderByFields = orderByComparator.getOrderByFields();
4258
4259 for (int i = 0; i < orderByFields.length; i++) {
4260 query.append(_ORDER_BY_ENTITY_ALIAS);
4261 query.append(orderByFields[i]);
4262
4263 if ((i + 1) < orderByFields.length) {
4264 if (orderByComparator.isAscending() ^ previous) {
4265 query.append(ORDER_BY_ASC_HAS_NEXT);
4266 }
4267 else {
4268 query.append(ORDER_BY_DESC_HAS_NEXT);
4269 }
4270 }
4271 else {
4272 if (orderByComparator.isAscending() ^ previous) {
4273 query.append(ORDER_BY_ASC);
4274 }
4275 else {
4276 query.append(ORDER_BY_DESC);
4277 }
4278 }
4279 }
4280 }
4281 else {
4282 query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
4283 }
4284
4285 String sql = query.toString();
4286
4287 Query q = session.createQuery(sql);
4288
4289 q.setFirstResult(0);
4290 q.setMaxResults(2);
4291
4292 QueryPos qPos = QueryPos.getInstance(q);
4293
4294 qPos.add(companyId);
4295
4296 qPos.add(status);
4297
4298 if (orderByComparator != null) {
4299 Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
4300
4301 for (Object value : values) {
4302 qPos.add(value);
4303 }
4304 }
4305
4306 List<WikiNode> list = q.list();
4307
4308 if (list.size() == 2) {
4309 return list.get(1);
4310 }
4311 else {
4312 return null;
4313 }
4314 }
4315
4316
4322 @Override
4323 public void removeByC_S(long companyId, int status) {
4324 for (WikiNode wikiNode : findByC_S(companyId, status,
4325 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4326 remove(wikiNode);
4327 }
4328 }
4329
4330
4337 @Override
4338 public int countByC_S(long companyId, int status) {
4339 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
4340
4341 Object[] finderArgs = new Object[] { companyId, status };
4342
4343 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4344 this);
4345
4346 if (count == null) {
4347 StringBundler query = new StringBundler(3);
4348
4349 query.append(_SQL_COUNT_WIKINODE_WHERE);
4350
4351 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4352
4353 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4354
4355 String sql = query.toString();
4356
4357 Session session = null;
4358
4359 try {
4360 session = openSession();
4361
4362 Query q = session.createQuery(sql);
4363
4364 QueryPos qPos = QueryPos.getInstance(q);
4365
4366 qPos.add(companyId);
4367
4368 qPos.add(status);
4369
4370 count = (Long)q.uniqueResult();
4371
4372 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4373 }
4374 catch (Exception e) {
4375 FinderCacheUtil.removeResult(finderPath, finderArgs);
4376
4377 throw processException(e);
4378 }
4379 finally {
4380 closeSession(session);
4381 }
4382 }
4383
4384 return count.intValue();
4385 }
4386
4387 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "wikiNode.companyId = ? AND ";
4388 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "wikiNode.status = ?";
4389
4390 public WikiNodePersistenceImpl() {
4391 setModelClass(WikiNode.class);
4392 }
4393
4394
4399 @Override
4400 public void cacheResult(WikiNode wikiNode) {
4401 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4402 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
4403
4404 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
4405 new Object[] { wikiNode.getUuid(), wikiNode.getGroupId() }, wikiNode);
4406
4407 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
4408 new Object[] { wikiNode.getGroupId(), wikiNode.getName() }, wikiNode);
4409
4410 wikiNode.resetOriginalValues();
4411 }
4412
4413
4418 @Override
4419 public void cacheResult(List<WikiNode> wikiNodes) {
4420 for (WikiNode wikiNode : wikiNodes) {
4421 if (EntityCacheUtil.getResult(
4422 WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4423 WikiNodeImpl.class, wikiNode.getPrimaryKey()) == null) {
4424 cacheResult(wikiNode);
4425 }
4426 else {
4427 wikiNode.resetOriginalValues();
4428 }
4429 }
4430 }
4431
4432
4439 @Override
4440 public void clearCache() {
4441 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4442 CacheRegistryUtil.clear(WikiNodeImpl.class.getName());
4443 }
4444
4445 EntityCacheUtil.clearCache(WikiNodeImpl.class);
4446
4447 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4448 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4449 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4450 }
4451
4452
4459 @Override
4460 public void clearCache(WikiNode wikiNode) {
4461 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4462 WikiNodeImpl.class, wikiNode.getPrimaryKey());
4463
4464 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4465 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4466
4467 clearUniqueFindersCache(wikiNode);
4468 }
4469
4470 @Override
4471 public void clearCache(List<WikiNode> wikiNodes) {
4472 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4473 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4474
4475 for (WikiNode wikiNode : wikiNodes) {
4476 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4477 WikiNodeImpl.class, wikiNode.getPrimaryKey());
4478
4479 clearUniqueFindersCache(wikiNode);
4480 }
4481 }
4482
4483 protected void cacheUniqueFindersCache(WikiNode wikiNode) {
4484 if (wikiNode.isNew()) {
4485 Object[] args = new Object[] {
4486 wikiNode.getUuid(), wikiNode.getGroupId()
4487 };
4488
4489 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
4490 Long.valueOf(1));
4491 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
4492 wikiNode);
4493
4494 args = new Object[] { wikiNode.getGroupId(), wikiNode.getName() };
4495
4496 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
4497 Long.valueOf(1));
4498 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args, wikiNode);
4499 }
4500 else {
4501 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
4502
4503 if ((wikiNodeModelImpl.getColumnBitmask() &
4504 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
4505 Object[] args = new Object[] {
4506 wikiNode.getUuid(), wikiNode.getGroupId()
4507 };
4508
4509 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
4510 Long.valueOf(1));
4511 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
4512 wikiNode);
4513 }
4514
4515 if ((wikiNodeModelImpl.getColumnBitmask() &
4516 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
4517 Object[] args = new Object[] {
4518 wikiNode.getGroupId(), wikiNode.getName()
4519 };
4520
4521 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
4522 Long.valueOf(1));
4523 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
4524 wikiNode);
4525 }
4526 }
4527 }
4528
4529 protected void clearUniqueFindersCache(WikiNode wikiNode) {
4530 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
4531
4532 Object[] args = new Object[] { wikiNode.getUuid(), wikiNode.getGroupId() };
4533
4534 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
4535 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
4536
4537 if ((wikiNodeModelImpl.getColumnBitmask() &
4538 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
4539 args = new Object[] {
4540 wikiNodeModelImpl.getOriginalUuid(),
4541 wikiNodeModelImpl.getOriginalGroupId()
4542 };
4543
4544 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
4545 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
4546 }
4547
4548 args = new Object[] { wikiNode.getGroupId(), wikiNode.getName() };
4549
4550 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
4551 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
4552
4553 if ((wikiNodeModelImpl.getColumnBitmask() &
4554 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
4555 args = new Object[] {
4556 wikiNodeModelImpl.getOriginalGroupId(),
4557 wikiNodeModelImpl.getOriginalName()
4558 };
4559
4560 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
4561 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
4562 }
4563 }
4564
4565
4571 @Override
4572 public WikiNode create(long nodeId) {
4573 WikiNode wikiNode = new WikiNodeImpl();
4574
4575 wikiNode.setNew(true);
4576 wikiNode.setPrimaryKey(nodeId);
4577
4578 String uuid = PortalUUIDUtil.generate();
4579
4580 wikiNode.setUuid(uuid);
4581
4582 return wikiNode;
4583 }
4584
4585
4592 @Override
4593 public WikiNode remove(long nodeId) throws NoSuchNodeException {
4594 return remove((Serializable)nodeId);
4595 }
4596
4597
4604 @Override
4605 public WikiNode remove(Serializable primaryKey) throws NoSuchNodeException {
4606 Session session = null;
4607
4608 try {
4609 session = openSession();
4610
4611 WikiNode wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
4612 primaryKey);
4613
4614 if (wikiNode == null) {
4615 if (_log.isWarnEnabled()) {
4616 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4617 }
4618
4619 throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4620 primaryKey);
4621 }
4622
4623 return remove(wikiNode);
4624 }
4625 catch (NoSuchNodeException nsee) {
4626 throw nsee;
4627 }
4628 catch (Exception e) {
4629 throw processException(e);
4630 }
4631 finally {
4632 closeSession(session);
4633 }
4634 }
4635
4636 @Override
4637 protected WikiNode removeImpl(WikiNode wikiNode) {
4638 wikiNode = toUnwrappedModel(wikiNode);
4639
4640 Session session = null;
4641
4642 try {
4643 session = openSession();
4644
4645 if (!session.contains(wikiNode)) {
4646 wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
4647 wikiNode.getPrimaryKeyObj());
4648 }
4649
4650 if (wikiNode != null) {
4651 session.delete(wikiNode);
4652 }
4653 }
4654 catch (Exception e) {
4655 throw processException(e);
4656 }
4657 finally {
4658 closeSession(session);
4659 }
4660
4661 if (wikiNode != null) {
4662 clearCache(wikiNode);
4663 }
4664
4665 return wikiNode;
4666 }
4667
4668 @Override
4669 public WikiNode updateImpl(com.liferay.portlet.wiki.model.WikiNode wikiNode) {
4670 wikiNode = toUnwrappedModel(wikiNode);
4671
4672 boolean isNew = wikiNode.isNew();
4673
4674 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
4675
4676 if (Validator.isNull(wikiNode.getUuid())) {
4677 String uuid = PortalUUIDUtil.generate();
4678
4679 wikiNode.setUuid(uuid);
4680 }
4681
4682 Session session = null;
4683
4684 try {
4685 session = openSession();
4686
4687 if (wikiNode.isNew()) {
4688 session.save(wikiNode);
4689
4690 wikiNode.setNew(false);
4691 }
4692 else {
4693 session.merge(wikiNode);
4694 }
4695 }
4696 catch (Exception e) {
4697 throw processException(e);
4698 }
4699 finally {
4700 closeSession(session);
4701 }
4702
4703 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4704
4705 if (isNew || !WikiNodeModelImpl.COLUMN_BITMASK_ENABLED) {
4706 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4707 }
4708
4709 else {
4710 if ((wikiNodeModelImpl.getColumnBitmask() &
4711 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
4712 Object[] args = new Object[] { wikiNodeModelImpl.getOriginalUuid() };
4713
4714 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4715 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4716 args);
4717
4718 args = new Object[] { wikiNodeModelImpl.getUuid() };
4719
4720 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4721 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4722 args);
4723 }
4724
4725 if ((wikiNodeModelImpl.getColumnBitmask() &
4726 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
4727 Object[] args = new Object[] {
4728 wikiNodeModelImpl.getOriginalUuid(),
4729 wikiNodeModelImpl.getOriginalCompanyId()
4730 };
4731
4732 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4733 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4734 args);
4735
4736 args = new Object[] {
4737 wikiNodeModelImpl.getUuid(),
4738 wikiNodeModelImpl.getCompanyId()
4739 };
4740
4741 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4742 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4743 args);
4744 }
4745
4746 if ((wikiNodeModelImpl.getColumnBitmask() &
4747 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
4748 Object[] args = new Object[] {
4749 wikiNodeModelImpl.getOriginalGroupId()
4750 };
4751
4752 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
4753 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
4754 args);
4755
4756 args = new Object[] { wikiNodeModelImpl.getGroupId() };
4757
4758 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
4759 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
4760 args);
4761 }
4762
4763 if ((wikiNodeModelImpl.getColumnBitmask() &
4764 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
4765 Object[] args = new Object[] {
4766 wikiNodeModelImpl.getOriginalCompanyId()
4767 };
4768
4769 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
4770 args);
4771 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4772 args);
4773
4774 args = new Object[] { wikiNodeModelImpl.getCompanyId() };
4775
4776 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
4777 args);
4778 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4779 args);
4780 }
4781
4782 if ((wikiNodeModelImpl.getColumnBitmask() &
4783 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
4784 Object[] args = new Object[] {
4785 wikiNodeModelImpl.getOriginalGroupId(),
4786 wikiNodeModelImpl.getOriginalStatus()
4787 };
4788
4789 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
4790 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
4791 args);
4792
4793 args = new Object[] {
4794 wikiNodeModelImpl.getGroupId(),
4795 wikiNodeModelImpl.getStatus()
4796 };
4797
4798 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
4799 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
4800 args);
4801 }
4802
4803 if ((wikiNodeModelImpl.getColumnBitmask() &
4804 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
4805 Object[] args = new Object[] {
4806 wikiNodeModelImpl.getOriginalCompanyId(),
4807 wikiNodeModelImpl.getOriginalStatus()
4808 };
4809
4810 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
4811 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
4812 args);
4813
4814 args = new Object[] {
4815 wikiNodeModelImpl.getCompanyId(),
4816 wikiNodeModelImpl.getStatus()
4817 };
4818
4819 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
4820 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
4821 args);
4822 }
4823 }
4824
4825 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4826 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode, false);
4827
4828 clearUniqueFindersCache(wikiNode);
4829 cacheUniqueFindersCache(wikiNode);
4830
4831 wikiNode.resetOriginalValues();
4832
4833 return wikiNode;
4834 }
4835
4836 protected WikiNode toUnwrappedModel(WikiNode wikiNode) {
4837 if (wikiNode instanceof WikiNodeImpl) {
4838 return wikiNode;
4839 }
4840
4841 WikiNodeImpl wikiNodeImpl = new WikiNodeImpl();
4842
4843 wikiNodeImpl.setNew(wikiNode.isNew());
4844 wikiNodeImpl.setPrimaryKey(wikiNode.getPrimaryKey());
4845
4846 wikiNodeImpl.setUuid(wikiNode.getUuid());
4847 wikiNodeImpl.setNodeId(wikiNode.getNodeId());
4848 wikiNodeImpl.setGroupId(wikiNode.getGroupId());
4849 wikiNodeImpl.setCompanyId(wikiNode.getCompanyId());
4850 wikiNodeImpl.setUserId(wikiNode.getUserId());
4851 wikiNodeImpl.setUserName(wikiNode.getUserName());
4852 wikiNodeImpl.setCreateDate(wikiNode.getCreateDate());
4853 wikiNodeImpl.setModifiedDate(wikiNode.getModifiedDate());
4854 wikiNodeImpl.setName(wikiNode.getName());
4855 wikiNodeImpl.setDescription(wikiNode.getDescription());
4856 wikiNodeImpl.setLastPostDate(wikiNode.getLastPostDate());
4857 wikiNodeImpl.setStatus(wikiNode.getStatus());
4858 wikiNodeImpl.setStatusByUserId(wikiNode.getStatusByUserId());
4859 wikiNodeImpl.setStatusByUserName(wikiNode.getStatusByUserName());
4860 wikiNodeImpl.setStatusDate(wikiNode.getStatusDate());
4861
4862 return wikiNodeImpl;
4863 }
4864
4865
4872 @Override
4873 public WikiNode findByPrimaryKey(Serializable primaryKey)
4874 throws NoSuchNodeException {
4875 WikiNode wikiNode = fetchByPrimaryKey(primaryKey);
4876
4877 if (wikiNode == null) {
4878 if (_log.isWarnEnabled()) {
4879 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4880 }
4881
4882 throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4883 primaryKey);
4884 }
4885
4886 return wikiNode;
4887 }
4888
4889
4896 @Override
4897 public WikiNode findByPrimaryKey(long nodeId) throws NoSuchNodeException {
4898 return findByPrimaryKey((Serializable)nodeId);
4899 }
4900
4901
4907 @Override
4908 public WikiNode fetchByPrimaryKey(Serializable primaryKey) {
4909 WikiNode wikiNode = (WikiNode)EntityCacheUtil.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4910 WikiNodeImpl.class, primaryKey);
4911
4912 if (wikiNode == _nullWikiNode) {
4913 return null;
4914 }
4915
4916 if (wikiNode == null) {
4917 Session session = null;
4918
4919 try {
4920 session = openSession();
4921
4922 wikiNode = (WikiNode)session.get(WikiNodeImpl.class, primaryKey);
4923
4924 if (wikiNode != null) {
4925 cacheResult(wikiNode);
4926 }
4927 else {
4928 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4929 WikiNodeImpl.class, primaryKey, _nullWikiNode);
4930 }
4931 }
4932 catch (Exception e) {
4933 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4934 WikiNodeImpl.class, primaryKey);
4935
4936 throw processException(e);
4937 }
4938 finally {
4939 closeSession(session);
4940 }
4941 }
4942
4943 return wikiNode;
4944 }
4945
4946
4952 @Override
4953 public WikiNode fetchByPrimaryKey(long nodeId) {
4954 return fetchByPrimaryKey((Serializable)nodeId);
4955 }
4956
4957 @Override
4958 public Map<Serializable, WikiNode> fetchByPrimaryKeys(
4959 Set<Serializable> primaryKeys) {
4960 if (primaryKeys.isEmpty()) {
4961 return Collections.emptyMap();
4962 }
4963
4964 Map<Serializable, WikiNode> map = new HashMap<Serializable, WikiNode>();
4965
4966 if (primaryKeys.size() == 1) {
4967 Iterator<Serializable> iterator = primaryKeys.iterator();
4968
4969 Serializable primaryKey = iterator.next();
4970
4971 WikiNode wikiNode = fetchByPrimaryKey(primaryKey);
4972
4973 if (wikiNode != null) {
4974 map.put(primaryKey, wikiNode);
4975 }
4976
4977 return map;
4978 }
4979
4980 Set<Serializable> uncachedPrimaryKeys = null;
4981
4982 for (Serializable primaryKey : primaryKeys) {
4983 WikiNode wikiNode = (WikiNode)EntityCacheUtil.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
4984 WikiNodeImpl.class, primaryKey);
4985
4986 if (wikiNode == null) {
4987 if (uncachedPrimaryKeys == null) {
4988 uncachedPrimaryKeys = new HashSet<Serializable>();
4989 }
4990
4991 uncachedPrimaryKeys.add(primaryKey);
4992 }
4993 else {
4994 map.put(primaryKey, wikiNode);
4995 }
4996 }
4997
4998 if (uncachedPrimaryKeys == null) {
4999 return map;
5000 }
5001
5002 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
5003 1);
5004
5005 query.append(_SQL_SELECT_WIKINODE_WHERE_PKS_IN);
5006
5007 for (Serializable primaryKey : uncachedPrimaryKeys) {
5008 query.append(String.valueOf(primaryKey));
5009
5010 query.append(StringPool.COMMA);
5011 }
5012
5013 query.setIndex(query.index() - 1);
5014
5015 query.append(StringPool.CLOSE_PARENTHESIS);
5016
5017 String sql = query.toString();
5018
5019 Session session = null;
5020
5021 try {
5022 session = openSession();
5023
5024 Query q = session.createQuery(sql);
5025
5026 for (WikiNode wikiNode : (List<WikiNode>)q.list()) {
5027 map.put(wikiNode.getPrimaryKeyObj(), wikiNode);
5028
5029 cacheResult(wikiNode);
5030
5031 uncachedPrimaryKeys.remove(wikiNode.getPrimaryKeyObj());
5032 }
5033
5034 for (Serializable primaryKey : uncachedPrimaryKeys) {
5035 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
5036 WikiNodeImpl.class, primaryKey, _nullWikiNode);
5037 }
5038 }
5039 catch (Exception e) {
5040 throw processException(e);
5041 }
5042 finally {
5043 closeSession(session);
5044 }
5045
5046 return map;
5047 }
5048
5049
5054 @Override
5055 public List<WikiNode> findAll() {
5056 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5057 }
5058
5059
5070 @Override
5071 public List<WikiNode> findAll(int start, int end) {
5072 return findAll(start, end, null);
5073 }
5074
5075
5087 @Override
5088 public List<WikiNode> findAll(int start, int end,
5089 OrderByComparator<WikiNode> orderByComparator) {
5090 boolean pagination = true;
5091 FinderPath finderPath = null;
5092 Object[] finderArgs = null;
5093
5094 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5095 (orderByComparator == null)) {
5096 pagination = false;
5097 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5098 finderArgs = FINDER_ARGS_EMPTY;
5099 }
5100 else {
5101 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5102 finderArgs = new Object[] { start, end, orderByComparator };
5103 }
5104
5105 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
5106 finderArgs, this);
5107
5108 if (list == null) {
5109 StringBundler query = null;
5110 String sql = null;
5111
5112 if (orderByComparator != null) {
5113 query = new StringBundler(2 +
5114 (orderByComparator.getOrderByFields().length * 3));
5115
5116 query.append(_SQL_SELECT_WIKINODE);
5117
5118 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5119 orderByComparator);
5120
5121 sql = query.toString();
5122 }
5123 else {
5124 sql = _SQL_SELECT_WIKINODE;
5125
5126 if (pagination) {
5127 sql = sql.concat(WikiNodeModelImpl.ORDER_BY_JPQL);
5128 }
5129 }
5130
5131 Session session = null;
5132
5133 try {
5134 session = openSession();
5135
5136 Query q = session.createQuery(sql);
5137
5138 if (!pagination) {
5139 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
5140 start, end, false);
5141
5142 Collections.sort(list);
5143
5144 list = Collections.unmodifiableList(list);
5145 }
5146 else {
5147 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
5148 start, end);
5149 }
5150
5151 cacheResult(list);
5152
5153 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5154 }
5155 catch (Exception e) {
5156 FinderCacheUtil.removeResult(finderPath, finderArgs);
5157
5158 throw processException(e);
5159 }
5160 finally {
5161 closeSession(session);
5162 }
5163 }
5164
5165 return list;
5166 }
5167
5168
5172 @Override
5173 public void removeAll() {
5174 for (WikiNode wikiNode : findAll()) {
5175 remove(wikiNode);
5176 }
5177 }
5178
5179
5184 @Override
5185 public int countAll() {
5186 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5187 FINDER_ARGS_EMPTY, this);
5188
5189 if (count == null) {
5190 Session session = null;
5191
5192 try {
5193 session = openSession();
5194
5195 Query q = session.createQuery(_SQL_COUNT_WIKINODE);
5196
5197 count = (Long)q.uniqueResult();
5198
5199 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5200 FINDER_ARGS_EMPTY, count);
5201 }
5202 catch (Exception e) {
5203 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5204 FINDER_ARGS_EMPTY);
5205
5206 throw processException(e);
5207 }
5208 finally {
5209 closeSession(session);
5210 }
5211 }
5212
5213 return count.intValue();
5214 }
5215
5216 @Override
5217 protected Set<String> getBadColumnNames() {
5218 return _badColumnNames;
5219 }
5220
5221
5224 public void afterPropertiesSet() {
5225 }
5226
5227 public void destroy() {
5228 EntityCacheUtil.removeCache(WikiNodeImpl.class.getName());
5229 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5230 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5231 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5232 }
5233
5234 private static final String _SQL_SELECT_WIKINODE = "SELECT wikiNode FROM WikiNode wikiNode";
5235 private static final String _SQL_SELECT_WIKINODE_WHERE_PKS_IN = "SELECT wikiNode FROM WikiNode wikiNode WHERE nodeId IN (";
5236 private static final String _SQL_SELECT_WIKINODE_WHERE = "SELECT wikiNode FROM WikiNode wikiNode WHERE ";
5237 private static final String _SQL_COUNT_WIKINODE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode";
5238 private static final String _SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode WHERE ";
5239 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "wikiNode.nodeId";
5240 private static final String _FILTER_SQL_SELECT_WIKINODE_WHERE = "SELECT DISTINCT {wikiNode.*} FROM WikiNode wikiNode WHERE ";
5241 private static final String _FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1 =
5242 "SELECT {WikiNode.*} FROM (SELECT DISTINCT wikiNode.nodeId FROM WikiNode wikiNode WHERE ";
5243 private static final String _FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2 =
5244 ") TEMP_TABLE INNER JOIN WikiNode ON TEMP_TABLE.nodeId = WikiNode.nodeId";
5245 private static final String _FILTER_SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(DISTINCT wikiNode.nodeId) AS COUNT_VALUE FROM WikiNode wikiNode WHERE ";
5246 private static final String _FILTER_ENTITY_ALIAS = "wikiNode";
5247 private static final String _FILTER_ENTITY_TABLE = "WikiNode";
5248 private static final String _ORDER_BY_ENTITY_ALIAS = "wikiNode.";
5249 private static final String _ORDER_BY_ENTITY_TABLE = "WikiNode.";
5250 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiNode exists with the primary key ";
5251 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiNode exists with the key {";
5252 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5253 private static final Log _log = LogFactoryUtil.getLog(WikiNodePersistenceImpl.class);
5254 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
5255 "uuid"
5256 });
5257 private static final WikiNode _nullWikiNode = new WikiNodeImpl() {
5258 @Override
5259 public Object clone() {
5260 return this;
5261 }
5262
5263 @Override
5264 public CacheModel<WikiNode> toCacheModel() {
5265 return _nullWikiNodeCacheModel;
5266 }
5267 };
5268
5269 private static final CacheModel<WikiNode> _nullWikiNodeCacheModel = new CacheModel<WikiNode>() {
5270 @Override
5271 public WikiNode toEntityModel() {
5272 return _nullWikiNode;
5273 }
5274 };
5275 }