001
014
015 package com.liferay.portlet.messageboards.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.message.boards.kernel.exception.NoSuchDiscussionException;
020 import com.liferay.message.boards.kernel.model.MBDiscussion;
021 import com.liferay.message.boards.kernel.service.persistence.MBDiscussionPersistence;
022
023 import com.liferay.portal.kernel.bean.BeanReference;
024 import com.liferay.portal.kernel.dao.orm.EntityCache;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCache;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.log.Log;
034 import com.liferay.portal.kernel.log.LogFactoryUtil;
035 import com.liferay.portal.kernel.model.CacheModel;
036 import com.liferay.portal.kernel.service.ServiceContext;
037 import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
038 import com.liferay.portal.kernel.service.persistence.CompanyProvider;
039 import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
040 import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
041 import com.liferay.portal.kernel.util.OrderByComparator;
042 import com.liferay.portal.kernel.util.SetUtil;
043 import com.liferay.portal.kernel.util.StringBundler;
044 import com.liferay.portal.kernel.util.StringPool;
045 import com.liferay.portal.kernel.util.Validator;
046 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
047
048 import com.liferay.portlet.messageboards.model.impl.MBDiscussionImpl;
049 import com.liferay.portlet.messageboards.model.impl.MBDiscussionModelImpl;
050
051 import java.io.Serializable;
052
053 import java.util.Collections;
054 import java.util.Date;
055 import java.util.HashMap;
056 import java.util.HashSet;
057 import java.util.Iterator;
058 import java.util.List;
059 import java.util.Map;
060 import java.util.Objects;
061 import java.util.Set;
062
063
075 @ProviderType
076 public class MBDiscussionPersistenceImpl extends BasePersistenceImpl<MBDiscussion>
077 implements MBDiscussionPersistence {
078
083 public static final String FINDER_CLASS_NAME_ENTITY = MBDiscussionImpl.class.getName();
084 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085 ".List1";
086 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087 ".List2";
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
089 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
090 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
091 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
092 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
094 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
095 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
097 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
098 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
100 new String[] {
101 String.class.getName(),
102
103 Integer.class.getName(), Integer.class.getName(),
104 OrderByComparator.class.getName()
105 });
106 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
107 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
109 new String[] { String.class.getName() },
110 MBDiscussionModelImpl.UUID_COLUMN_BITMASK);
111 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
112 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, Long.class,
113 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
114 new String[] { String.class.getName() });
115
116
122 @Override
123 public List<MBDiscussion> findByUuid(String uuid) {
124 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
125 }
126
127
139 @Override
140 public List<MBDiscussion> findByUuid(String uuid, int start, int end) {
141 return findByUuid(uuid, start, end, null);
142 }
143
144
157 @Override
158 public List<MBDiscussion> findByUuid(String uuid, int start, int end,
159 OrderByComparator<MBDiscussion> orderByComparator) {
160 return findByUuid(uuid, start, end, orderByComparator, true);
161 }
162
163
177 @Override
178 public List<MBDiscussion> findByUuid(String uuid, int start, int end,
179 OrderByComparator<MBDiscussion> orderByComparator,
180 boolean retrieveFromCache) {
181 boolean pagination = true;
182 FinderPath finderPath = null;
183 Object[] finderArgs = null;
184
185 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
186 (orderByComparator == null)) {
187 pagination = false;
188 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
189 finderArgs = new Object[] { uuid };
190 }
191 else {
192 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
193 finderArgs = new Object[] { uuid, start, end, orderByComparator };
194 }
195
196 List<MBDiscussion> list = null;
197
198 if (retrieveFromCache) {
199 list = (List<MBDiscussion>)finderCache.getResult(finderPath,
200 finderArgs, this);
201
202 if ((list != null) && !list.isEmpty()) {
203 for (MBDiscussion mbDiscussion : list) {
204 if (!Objects.equals(uuid, mbDiscussion.getUuid())) {
205 list = null;
206
207 break;
208 }
209 }
210 }
211 }
212
213 if (list == null) {
214 StringBundler query = null;
215
216 if (orderByComparator != null) {
217 query = new StringBundler(3 +
218 (orderByComparator.getOrderByFields().length * 2));
219 }
220 else {
221 query = new StringBundler(3);
222 }
223
224 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
225
226 boolean bindUuid = false;
227
228 if (uuid == null) {
229 query.append(_FINDER_COLUMN_UUID_UUID_1);
230 }
231 else if (uuid.equals(StringPool.BLANK)) {
232 query.append(_FINDER_COLUMN_UUID_UUID_3);
233 }
234 else {
235 bindUuid = true;
236
237 query.append(_FINDER_COLUMN_UUID_UUID_2);
238 }
239
240 if (orderByComparator != null) {
241 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
242 orderByComparator);
243 }
244 else
245 if (pagination) {
246 query.append(MBDiscussionModelImpl.ORDER_BY_JPQL);
247 }
248
249 String sql = query.toString();
250
251 Session session = null;
252
253 try {
254 session = openSession();
255
256 Query q = session.createQuery(sql);
257
258 QueryPos qPos = QueryPos.getInstance(q);
259
260 if (bindUuid) {
261 qPos.add(uuid);
262 }
263
264 if (!pagination) {
265 list = (List<MBDiscussion>)QueryUtil.list(q, getDialect(),
266 start, end, false);
267
268 Collections.sort(list);
269
270 list = Collections.unmodifiableList(list);
271 }
272 else {
273 list = (List<MBDiscussion>)QueryUtil.list(q, getDialect(),
274 start, end);
275 }
276
277 cacheResult(list);
278
279 finderCache.putResult(finderPath, finderArgs, list);
280 }
281 catch (Exception e) {
282 finderCache.removeResult(finderPath, finderArgs);
283
284 throw processException(e);
285 }
286 finally {
287 closeSession(session);
288 }
289 }
290
291 return list;
292 }
293
294
302 @Override
303 public MBDiscussion findByUuid_First(String uuid,
304 OrderByComparator<MBDiscussion> orderByComparator)
305 throws NoSuchDiscussionException {
306 MBDiscussion mbDiscussion = fetchByUuid_First(uuid, orderByComparator);
307
308 if (mbDiscussion != null) {
309 return mbDiscussion;
310 }
311
312 StringBundler msg = new StringBundler(4);
313
314 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
315
316 msg.append("uuid=");
317 msg.append(uuid);
318
319 msg.append(StringPool.CLOSE_CURLY_BRACE);
320
321 throw new NoSuchDiscussionException(msg.toString());
322 }
323
324
331 @Override
332 public MBDiscussion fetchByUuid_First(String uuid,
333 OrderByComparator<MBDiscussion> orderByComparator) {
334 List<MBDiscussion> list = findByUuid(uuid, 0, 1, orderByComparator);
335
336 if (!list.isEmpty()) {
337 return list.get(0);
338 }
339
340 return null;
341 }
342
343
351 @Override
352 public MBDiscussion findByUuid_Last(String uuid,
353 OrderByComparator<MBDiscussion> orderByComparator)
354 throws NoSuchDiscussionException {
355 MBDiscussion mbDiscussion = fetchByUuid_Last(uuid, orderByComparator);
356
357 if (mbDiscussion != null) {
358 return mbDiscussion;
359 }
360
361 StringBundler msg = new StringBundler(4);
362
363 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
364
365 msg.append("uuid=");
366 msg.append(uuid);
367
368 msg.append(StringPool.CLOSE_CURLY_BRACE);
369
370 throw new NoSuchDiscussionException(msg.toString());
371 }
372
373
380 @Override
381 public MBDiscussion fetchByUuid_Last(String uuid,
382 OrderByComparator<MBDiscussion> orderByComparator) {
383 int count = countByUuid(uuid);
384
385 if (count == 0) {
386 return null;
387 }
388
389 List<MBDiscussion> list = findByUuid(uuid, count - 1, count,
390 orderByComparator);
391
392 if (!list.isEmpty()) {
393 return list.get(0);
394 }
395
396 return null;
397 }
398
399
408 @Override
409 public MBDiscussion[] findByUuid_PrevAndNext(long discussionId,
410 String uuid, OrderByComparator<MBDiscussion> orderByComparator)
411 throws NoSuchDiscussionException {
412 MBDiscussion mbDiscussion = findByPrimaryKey(discussionId);
413
414 Session session = null;
415
416 try {
417 session = openSession();
418
419 MBDiscussion[] array = new MBDiscussionImpl[3];
420
421 array[0] = getByUuid_PrevAndNext(session, mbDiscussion, uuid,
422 orderByComparator, true);
423
424 array[1] = mbDiscussion;
425
426 array[2] = getByUuid_PrevAndNext(session, mbDiscussion, uuid,
427 orderByComparator, false);
428
429 return array;
430 }
431 catch (Exception e) {
432 throw processException(e);
433 }
434 finally {
435 closeSession(session);
436 }
437 }
438
439 protected MBDiscussion getByUuid_PrevAndNext(Session session,
440 MBDiscussion mbDiscussion, String uuid,
441 OrderByComparator<MBDiscussion> orderByComparator, boolean previous) {
442 StringBundler query = null;
443
444 if (orderByComparator != null) {
445 query = new StringBundler(4 +
446 (orderByComparator.getOrderByConditionFields().length * 3) +
447 (orderByComparator.getOrderByFields().length * 3));
448 }
449 else {
450 query = new StringBundler(3);
451 }
452
453 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
454
455 boolean bindUuid = false;
456
457 if (uuid == null) {
458 query.append(_FINDER_COLUMN_UUID_UUID_1);
459 }
460 else if (uuid.equals(StringPool.BLANK)) {
461 query.append(_FINDER_COLUMN_UUID_UUID_3);
462 }
463 else {
464 bindUuid = true;
465
466 query.append(_FINDER_COLUMN_UUID_UUID_2);
467 }
468
469 if (orderByComparator != null) {
470 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
471
472 if (orderByConditionFields.length > 0) {
473 query.append(WHERE_AND);
474 }
475
476 for (int i = 0; i < orderByConditionFields.length; i++) {
477 query.append(_ORDER_BY_ENTITY_ALIAS);
478 query.append(orderByConditionFields[i]);
479
480 if ((i + 1) < orderByConditionFields.length) {
481 if (orderByComparator.isAscending() ^ previous) {
482 query.append(WHERE_GREATER_THAN_HAS_NEXT);
483 }
484 else {
485 query.append(WHERE_LESSER_THAN_HAS_NEXT);
486 }
487 }
488 else {
489 if (orderByComparator.isAscending() ^ previous) {
490 query.append(WHERE_GREATER_THAN);
491 }
492 else {
493 query.append(WHERE_LESSER_THAN);
494 }
495 }
496 }
497
498 query.append(ORDER_BY_CLAUSE);
499
500 String[] orderByFields = orderByComparator.getOrderByFields();
501
502 for (int i = 0; i < orderByFields.length; i++) {
503 query.append(_ORDER_BY_ENTITY_ALIAS);
504 query.append(orderByFields[i]);
505
506 if ((i + 1) < orderByFields.length) {
507 if (orderByComparator.isAscending() ^ previous) {
508 query.append(ORDER_BY_ASC_HAS_NEXT);
509 }
510 else {
511 query.append(ORDER_BY_DESC_HAS_NEXT);
512 }
513 }
514 else {
515 if (orderByComparator.isAscending() ^ previous) {
516 query.append(ORDER_BY_ASC);
517 }
518 else {
519 query.append(ORDER_BY_DESC);
520 }
521 }
522 }
523 }
524 else {
525 query.append(MBDiscussionModelImpl.ORDER_BY_JPQL);
526 }
527
528 String sql = query.toString();
529
530 Query q = session.createQuery(sql);
531
532 q.setFirstResult(0);
533 q.setMaxResults(2);
534
535 QueryPos qPos = QueryPos.getInstance(q);
536
537 if (bindUuid) {
538 qPos.add(uuid);
539 }
540
541 if (orderByComparator != null) {
542 Object[] values = orderByComparator.getOrderByConditionValues(mbDiscussion);
543
544 for (Object value : values) {
545 qPos.add(value);
546 }
547 }
548
549 List<MBDiscussion> list = q.list();
550
551 if (list.size() == 2) {
552 return list.get(1);
553 }
554 else {
555 return null;
556 }
557 }
558
559
564 @Override
565 public void removeByUuid(String uuid) {
566 for (MBDiscussion mbDiscussion : findByUuid(uuid, QueryUtil.ALL_POS,
567 QueryUtil.ALL_POS, null)) {
568 remove(mbDiscussion);
569 }
570 }
571
572
578 @Override
579 public int countByUuid(String uuid) {
580 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
581
582 Object[] finderArgs = new Object[] { uuid };
583
584 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
585
586 if (count == null) {
587 StringBundler query = new StringBundler(2);
588
589 query.append(_SQL_COUNT_MBDISCUSSION_WHERE);
590
591 boolean bindUuid = false;
592
593 if (uuid == null) {
594 query.append(_FINDER_COLUMN_UUID_UUID_1);
595 }
596 else if (uuid.equals(StringPool.BLANK)) {
597 query.append(_FINDER_COLUMN_UUID_UUID_3);
598 }
599 else {
600 bindUuid = true;
601
602 query.append(_FINDER_COLUMN_UUID_UUID_2);
603 }
604
605 String sql = query.toString();
606
607 Session session = null;
608
609 try {
610 session = openSession();
611
612 Query q = session.createQuery(sql);
613
614 QueryPos qPos = QueryPos.getInstance(q);
615
616 if (bindUuid) {
617 qPos.add(uuid);
618 }
619
620 count = (Long)q.uniqueResult();
621
622 finderCache.putResult(finderPath, finderArgs, count);
623 }
624 catch (Exception e) {
625 finderCache.removeResult(finderPath, finderArgs);
626
627 throw processException(e);
628 }
629 finally {
630 closeSession(session);
631 }
632 }
633
634 return count.intValue();
635 }
636
637 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbDiscussion.uuid IS NULL";
638 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbDiscussion.uuid = ?";
639 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbDiscussion.uuid IS NULL OR mbDiscussion.uuid = '')";
640 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
641 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
642 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
643 new String[] { String.class.getName(), Long.class.getName() },
644 MBDiscussionModelImpl.UUID_COLUMN_BITMASK |
645 MBDiscussionModelImpl.GROUPID_COLUMN_BITMASK);
646 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
647 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, Long.class,
648 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
649 new String[] { String.class.getName(), Long.class.getName() });
650
651
659 @Override
660 public MBDiscussion findByUUID_G(String uuid, long groupId)
661 throws NoSuchDiscussionException {
662 MBDiscussion mbDiscussion = fetchByUUID_G(uuid, groupId);
663
664 if (mbDiscussion == null) {
665 StringBundler msg = new StringBundler(6);
666
667 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
668
669 msg.append("uuid=");
670 msg.append(uuid);
671
672 msg.append(", groupId=");
673 msg.append(groupId);
674
675 msg.append(StringPool.CLOSE_CURLY_BRACE);
676
677 if (_log.isDebugEnabled()) {
678 _log.debug(msg.toString());
679 }
680
681 throw new NoSuchDiscussionException(msg.toString());
682 }
683
684 return mbDiscussion;
685 }
686
687
694 @Override
695 public MBDiscussion fetchByUUID_G(String uuid, long groupId) {
696 return fetchByUUID_G(uuid, groupId, true);
697 }
698
699
707 @Override
708 public MBDiscussion fetchByUUID_G(String uuid, long groupId,
709 boolean retrieveFromCache) {
710 Object[] finderArgs = new Object[] { uuid, groupId };
711
712 Object result = null;
713
714 if (retrieveFromCache) {
715 result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
716 finderArgs, this);
717 }
718
719 if (result instanceof MBDiscussion) {
720 MBDiscussion mbDiscussion = (MBDiscussion)result;
721
722 if (!Objects.equals(uuid, mbDiscussion.getUuid()) ||
723 (groupId != mbDiscussion.getGroupId())) {
724 result = null;
725 }
726 }
727
728 if (result == null) {
729 StringBundler query = new StringBundler(4);
730
731 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
732
733 boolean bindUuid = false;
734
735 if (uuid == null) {
736 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
737 }
738 else if (uuid.equals(StringPool.BLANK)) {
739 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
740 }
741 else {
742 bindUuid = true;
743
744 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
745 }
746
747 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
748
749 String sql = query.toString();
750
751 Session session = null;
752
753 try {
754 session = openSession();
755
756 Query q = session.createQuery(sql);
757
758 QueryPos qPos = QueryPos.getInstance(q);
759
760 if (bindUuid) {
761 qPos.add(uuid);
762 }
763
764 qPos.add(groupId);
765
766 List<MBDiscussion> list = q.list();
767
768 if (list.isEmpty()) {
769 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
770 finderArgs, list);
771 }
772 else {
773 MBDiscussion mbDiscussion = list.get(0);
774
775 result = mbDiscussion;
776
777 cacheResult(mbDiscussion);
778
779 if ((mbDiscussion.getUuid() == null) ||
780 !mbDiscussion.getUuid().equals(uuid) ||
781 (mbDiscussion.getGroupId() != groupId)) {
782 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
783 finderArgs, mbDiscussion);
784 }
785 }
786 }
787 catch (Exception e) {
788 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
789
790 throw processException(e);
791 }
792 finally {
793 closeSession(session);
794 }
795 }
796
797 if (result instanceof List<?>) {
798 return null;
799 }
800 else {
801 return (MBDiscussion)result;
802 }
803 }
804
805
812 @Override
813 public MBDiscussion removeByUUID_G(String uuid, long groupId)
814 throws NoSuchDiscussionException {
815 MBDiscussion mbDiscussion = findByUUID_G(uuid, groupId);
816
817 return remove(mbDiscussion);
818 }
819
820
827 @Override
828 public int countByUUID_G(String uuid, long groupId) {
829 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
830
831 Object[] finderArgs = new Object[] { uuid, groupId };
832
833 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
834
835 if (count == null) {
836 StringBundler query = new StringBundler(3);
837
838 query.append(_SQL_COUNT_MBDISCUSSION_WHERE);
839
840 boolean bindUuid = false;
841
842 if (uuid == null) {
843 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
844 }
845 else if (uuid.equals(StringPool.BLANK)) {
846 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
847 }
848 else {
849 bindUuid = true;
850
851 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
852 }
853
854 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
855
856 String sql = query.toString();
857
858 Session session = null;
859
860 try {
861 session = openSession();
862
863 Query q = session.createQuery(sql);
864
865 QueryPos qPos = QueryPos.getInstance(q);
866
867 if (bindUuid) {
868 qPos.add(uuid);
869 }
870
871 qPos.add(groupId);
872
873 count = (Long)q.uniqueResult();
874
875 finderCache.putResult(finderPath, finderArgs, count);
876 }
877 catch (Exception e) {
878 finderCache.removeResult(finderPath, finderArgs);
879
880 throw processException(e);
881 }
882 finally {
883 closeSession(session);
884 }
885 }
886
887 return count.intValue();
888 }
889
890 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbDiscussion.uuid IS NULL AND ";
891 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbDiscussion.uuid = ? AND ";
892 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbDiscussion.uuid IS NULL OR mbDiscussion.uuid = '') AND ";
893 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbDiscussion.groupId = ?";
894 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
895 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
896 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
897 new String[] {
898 String.class.getName(), Long.class.getName(),
899
900 Integer.class.getName(), Integer.class.getName(),
901 OrderByComparator.class.getName()
902 });
903 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
904 new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
905 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
906 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
907 new String[] { String.class.getName(), Long.class.getName() },
908 MBDiscussionModelImpl.UUID_COLUMN_BITMASK |
909 MBDiscussionModelImpl.COMPANYID_COLUMN_BITMASK);
910 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
911 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, Long.class,
912 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
913 new String[] { String.class.getName(), Long.class.getName() });
914
915
922 @Override
923 public List<MBDiscussion> findByUuid_C(String uuid, long companyId) {
924 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
925 QueryUtil.ALL_POS, null);
926 }
927
928
941 @Override
942 public List<MBDiscussion> findByUuid_C(String uuid, long companyId,
943 int start, int end) {
944 return findByUuid_C(uuid, companyId, start, end, null);
945 }
946
947
961 @Override
962 public List<MBDiscussion> findByUuid_C(String uuid, long companyId,
963 int start, int end, OrderByComparator<MBDiscussion> orderByComparator) {
964 return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
965 }
966
967
982 @Override
983 public List<MBDiscussion> findByUuid_C(String uuid, long companyId,
984 int start, int end, OrderByComparator<MBDiscussion> orderByComparator,
985 boolean retrieveFromCache) {
986 boolean pagination = true;
987 FinderPath finderPath = null;
988 Object[] finderArgs = null;
989
990 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
991 (orderByComparator == null)) {
992 pagination = false;
993 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
994 finderArgs = new Object[] { uuid, companyId };
995 }
996 else {
997 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
998 finderArgs = new Object[] {
999 uuid, companyId,
1000
1001 start, end, orderByComparator
1002 };
1003 }
1004
1005 List<MBDiscussion> list = null;
1006
1007 if (retrieveFromCache) {
1008 list = (List<MBDiscussion>)finderCache.getResult(finderPath,
1009 finderArgs, this);
1010
1011 if ((list != null) && !list.isEmpty()) {
1012 for (MBDiscussion mbDiscussion : list) {
1013 if (!Objects.equals(uuid, mbDiscussion.getUuid()) ||
1014 (companyId != mbDiscussion.getCompanyId())) {
1015 list = null;
1016
1017 break;
1018 }
1019 }
1020 }
1021 }
1022
1023 if (list == null) {
1024 StringBundler query = null;
1025
1026 if (orderByComparator != null) {
1027 query = new StringBundler(4 +
1028 (orderByComparator.getOrderByFields().length * 2));
1029 }
1030 else {
1031 query = new StringBundler(4);
1032 }
1033
1034 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
1035
1036 boolean bindUuid = false;
1037
1038 if (uuid == null) {
1039 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1040 }
1041 else if (uuid.equals(StringPool.BLANK)) {
1042 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1043 }
1044 else {
1045 bindUuid = true;
1046
1047 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1048 }
1049
1050 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1051
1052 if (orderByComparator != null) {
1053 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1054 orderByComparator);
1055 }
1056 else
1057 if (pagination) {
1058 query.append(MBDiscussionModelImpl.ORDER_BY_JPQL);
1059 }
1060
1061 String sql = query.toString();
1062
1063 Session session = null;
1064
1065 try {
1066 session = openSession();
1067
1068 Query q = session.createQuery(sql);
1069
1070 QueryPos qPos = QueryPos.getInstance(q);
1071
1072 if (bindUuid) {
1073 qPos.add(uuid);
1074 }
1075
1076 qPos.add(companyId);
1077
1078 if (!pagination) {
1079 list = (List<MBDiscussion>)QueryUtil.list(q, getDialect(),
1080 start, end, false);
1081
1082 Collections.sort(list);
1083
1084 list = Collections.unmodifiableList(list);
1085 }
1086 else {
1087 list = (List<MBDiscussion>)QueryUtil.list(q, getDialect(),
1088 start, end);
1089 }
1090
1091 cacheResult(list);
1092
1093 finderCache.putResult(finderPath, finderArgs, list);
1094 }
1095 catch (Exception e) {
1096 finderCache.removeResult(finderPath, finderArgs);
1097
1098 throw processException(e);
1099 }
1100 finally {
1101 closeSession(session);
1102 }
1103 }
1104
1105 return list;
1106 }
1107
1108
1117 @Override
1118 public MBDiscussion findByUuid_C_First(String uuid, long companyId,
1119 OrderByComparator<MBDiscussion> orderByComparator)
1120 throws NoSuchDiscussionException {
1121 MBDiscussion mbDiscussion = fetchByUuid_C_First(uuid, companyId,
1122 orderByComparator);
1123
1124 if (mbDiscussion != null) {
1125 return mbDiscussion;
1126 }
1127
1128 StringBundler msg = new StringBundler(6);
1129
1130 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1131
1132 msg.append("uuid=");
1133 msg.append(uuid);
1134
1135 msg.append(", companyId=");
1136 msg.append(companyId);
1137
1138 msg.append(StringPool.CLOSE_CURLY_BRACE);
1139
1140 throw new NoSuchDiscussionException(msg.toString());
1141 }
1142
1143
1151 @Override
1152 public MBDiscussion fetchByUuid_C_First(String uuid, long companyId,
1153 OrderByComparator<MBDiscussion> orderByComparator) {
1154 List<MBDiscussion> list = findByUuid_C(uuid, companyId, 0, 1,
1155 orderByComparator);
1156
1157 if (!list.isEmpty()) {
1158 return list.get(0);
1159 }
1160
1161 return null;
1162 }
1163
1164
1173 @Override
1174 public MBDiscussion findByUuid_C_Last(String uuid, long companyId,
1175 OrderByComparator<MBDiscussion> orderByComparator)
1176 throws NoSuchDiscussionException {
1177 MBDiscussion mbDiscussion = fetchByUuid_C_Last(uuid, companyId,
1178 orderByComparator);
1179
1180 if (mbDiscussion != null) {
1181 return mbDiscussion;
1182 }
1183
1184 StringBundler msg = new StringBundler(6);
1185
1186 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1187
1188 msg.append("uuid=");
1189 msg.append(uuid);
1190
1191 msg.append(", companyId=");
1192 msg.append(companyId);
1193
1194 msg.append(StringPool.CLOSE_CURLY_BRACE);
1195
1196 throw new NoSuchDiscussionException(msg.toString());
1197 }
1198
1199
1207 @Override
1208 public MBDiscussion fetchByUuid_C_Last(String uuid, long companyId,
1209 OrderByComparator<MBDiscussion> orderByComparator) {
1210 int count = countByUuid_C(uuid, companyId);
1211
1212 if (count == 0) {
1213 return null;
1214 }
1215
1216 List<MBDiscussion> list = findByUuid_C(uuid, companyId, count - 1,
1217 count, orderByComparator);
1218
1219 if (!list.isEmpty()) {
1220 return list.get(0);
1221 }
1222
1223 return null;
1224 }
1225
1226
1236 @Override
1237 public MBDiscussion[] findByUuid_C_PrevAndNext(long discussionId,
1238 String uuid, long companyId,
1239 OrderByComparator<MBDiscussion> orderByComparator)
1240 throws NoSuchDiscussionException {
1241 MBDiscussion mbDiscussion = findByPrimaryKey(discussionId);
1242
1243 Session session = null;
1244
1245 try {
1246 session = openSession();
1247
1248 MBDiscussion[] array = new MBDiscussionImpl[3];
1249
1250 array[0] = getByUuid_C_PrevAndNext(session, mbDiscussion, uuid,
1251 companyId, orderByComparator, true);
1252
1253 array[1] = mbDiscussion;
1254
1255 array[2] = getByUuid_C_PrevAndNext(session, mbDiscussion, uuid,
1256 companyId, orderByComparator, false);
1257
1258 return array;
1259 }
1260 catch (Exception e) {
1261 throw processException(e);
1262 }
1263 finally {
1264 closeSession(session);
1265 }
1266 }
1267
1268 protected MBDiscussion getByUuid_C_PrevAndNext(Session session,
1269 MBDiscussion mbDiscussion, String uuid, long companyId,
1270 OrderByComparator<MBDiscussion> orderByComparator, boolean previous) {
1271 StringBundler query = null;
1272
1273 if (orderByComparator != null) {
1274 query = new StringBundler(5 +
1275 (orderByComparator.getOrderByConditionFields().length * 3) +
1276 (orderByComparator.getOrderByFields().length * 3));
1277 }
1278 else {
1279 query = new StringBundler(4);
1280 }
1281
1282 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
1283
1284 boolean bindUuid = false;
1285
1286 if (uuid == null) {
1287 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1288 }
1289 else if (uuid.equals(StringPool.BLANK)) {
1290 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1291 }
1292 else {
1293 bindUuid = true;
1294
1295 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1296 }
1297
1298 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1299
1300 if (orderByComparator != null) {
1301 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1302
1303 if (orderByConditionFields.length > 0) {
1304 query.append(WHERE_AND);
1305 }
1306
1307 for (int i = 0; i < orderByConditionFields.length; i++) {
1308 query.append(_ORDER_BY_ENTITY_ALIAS);
1309 query.append(orderByConditionFields[i]);
1310
1311 if ((i + 1) < orderByConditionFields.length) {
1312 if (orderByComparator.isAscending() ^ previous) {
1313 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1314 }
1315 else {
1316 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1317 }
1318 }
1319 else {
1320 if (orderByComparator.isAscending() ^ previous) {
1321 query.append(WHERE_GREATER_THAN);
1322 }
1323 else {
1324 query.append(WHERE_LESSER_THAN);
1325 }
1326 }
1327 }
1328
1329 query.append(ORDER_BY_CLAUSE);
1330
1331 String[] orderByFields = orderByComparator.getOrderByFields();
1332
1333 for (int i = 0; i < orderByFields.length; i++) {
1334 query.append(_ORDER_BY_ENTITY_ALIAS);
1335 query.append(orderByFields[i]);
1336
1337 if ((i + 1) < orderByFields.length) {
1338 if (orderByComparator.isAscending() ^ previous) {
1339 query.append(ORDER_BY_ASC_HAS_NEXT);
1340 }
1341 else {
1342 query.append(ORDER_BY_DESC_HAS_NEXT);
1343 }
1344 }
1345 else {
1346 if (orderByComparator.isAscending() ^ previous) {
1347 query.append(ORDER_BY_ASC);
1348 }
1349 else {
1350 query.append(ORDER_BY_DESC);
1351 }
1352 }
1353 }
1354 }
1355 else {
1356 query.append(MBDiscussionModelImpl.ORDER_BY_JPQL);
1357 }
1358
1359 String sql = query.toString();
1360
1361 Query q = session.createQuery(sql);
1362
1363 q.setFirstResult(0);
1364 q.setMaxResults(2);
1365
1366 QueryPos qPos = QueryPos.getInstance(q);
1367
1368 if (bindUuid) {
1369 qPos.add(uuid);
1370 }
1371
1372 qPos.add(companyId);
1373
1374 if (orderByComparator != null) {
1375 Object[] values = orderByComparator.getOrderByConditionValues(mbDiscussion);
1376
1377 for (Object value : values) {
1378 qPos.add(value);
1379 }
1380 }
1381
1382 List<MBDiscussion> list = q.list();
1383
1384 if (list.size() == 2) {
1385 return list.get(1);
1386 }
1387 else {
1388 return null;
1389 }
1390 }
1391
1392
1398 @Override
1399 public void removeByUuid_C(String uuid, long companyId) {
1400 for (MBDiscussion mbDiscussion : findByUuid_C(uuid, companyId,
1401 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1402 remove(mbDiscussion);
1403 }
1404 }
1405
1406
1413 @Override
1414 public int countByUuid_C(String uuid, long companyId) {
1415 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1416
1417 Object[] finderArgs = new Object[] { uuid, companyId };
1418
1419 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1420
1421 if (count == null) {
1422 StringBundler query = new StringBundler(3);
1423
1424 query.append(_SQL_COUNT_MBDISCUSSION_WHERE);
1425
1426 boolean bindUuid = false;
1427
1428 if (uuid == null) {
1429 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1430 }
1431 else if (uuid.equals(StringPool.BLANK)) {
1432 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1433 }
1434 else {
1435 bindUuid = true;
1436
1437 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1438 }
1439
1440 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1441
1442 String sql = query.toString();
1443
1444 Session session = null;
1445
1446 try {
1447 session = openSession();
1448
1449 Query q = session.createQuery(sql);
1450
1451 QueryPos qPos = QueryPos.getInstance(q);
1452
1453 if (bindUuid) {
1454 qPos.add(uuid);
1455 }
1456
1457 qPos.add(companyId);
1458
1459 count = (Long)q.uniqueResult();
1460
1461 finderCache.putResult(finderPath, finderArgs, count);
1462 }
1463 catch (Exception e) {
1464 finderCache.removeResult(finderPath, finderArgs);
1465
1466 throw processException(e);
1467 }
1468 finally {
1469 closeSession(session);
1470 }
1471 }
1472
1473 return count.intValue();
1474 }
1475
1476 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mbDiscussion.uuid IS NULL AND ";
1477 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbDiscussion.uuid = ? AND ";
1478 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbDiscussion.uuid IS NULL OR mbDiscussion.uuid = '') AND ";
1479 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbDiscussion.companyId = ?";
1480 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID =
1481 new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
1482 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
1483 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByClassNameId",
1484 new String[] {
1485 Long.class.getName(),
1486
1487 Integer.class.getName(), Integer.class.getName(),
1488 OrderByComparator.class.getName()
1489 });
1490 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID =
1491 new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
1492 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
1493 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByClassNameId",
1494 new String[] { Long.class.getName() },
1495 MBDiscussionModelImpl.CLASSNAMEID_COLUMN_BITMASK);
1496 public static final FinderPath FINDER_PATH_COUNT_BY_CLASSNAMEID = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
1497 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1498 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassNameId",
1499 new String[] { Long.class.getName() });
1500
1501
1507 @Override
1508 public List<MBDiscussion> findByClassNameId(long classNameId) {
1509 return findByClassNameId(classNameId, QueryUtil.ALL_POS,
1510 QueryUtil.ALL_POS, null);
1511 }
1512
1513
1525 @Override
1526 public List<MBDiscussion> findByClassNameId(long classNameId, int start,
1527 int end) {
1528 return findByClassNameId(classNameId, start, end, null);
1529 }
1530
1531
1544 @Override
1545 public List<MBDiscussion> findByClassNameId(long classNameId, int start,
1546 int end, OrderByComparator<MBDiscussion> orderByComparator) {
1547 return findByClassNameId(classNameId, start, end, orderByComparator,
1548 true);
1549 }
1550
1551
1565 @Override
1566 public List<MBDiscussion> findByClassNameId(long classNameId, int start,
1567 int end, OrderByComparator<MBDiscussion> orderByComparator,
1568 boolean retrieveFromCache) {
1569 boolean pagination = true;
1570 FinderPath finderPath = null;
1571 Object[] finderArgs = null;
1572
1573 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1574 (orderByComparator == null)) {
1575 pagination = false;
1576 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID;
1577 finderArgs = new Object[] { classNameId };
1578 }
1579 else {
1580 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID;
1581 finderArgs = new Object[] { classNameId, start, end, orderByComparator };
1582 }
1583
1584 List<MBDiscussion> list = null;
1585
1586 if (retrieveFromCache) {
1587 list = (List<MBDiscussion>)finderCache.getResult(finderPath,
1588 finderArgs, this);
1589
1590 if ((list != null) && !list.isEmpty()) {
1591 for (MBDiscussion mbDiscussion : list) {
1592 if ((classNameId != mbDiscussion.getClassNameId())) {
1593 list = null;
1594
1595 break;
1596 }
1597 }
1598 }
1599 }
1600
1601 if (list == null) {
1602 StringBundler query = null;
1603
1604 if (orderByComparator != null) {
1605 query = new StringBundler(3 +
1606 (orderByComparator.getOrderByFields().length * 2));
1607 }
1608 else {
1609 query = new StringBundler(3);
1610 }
1611
1612 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
1613
1614 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
1615
1616 if (orderByComparator != null) {
1617 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1618 orderByComparator);
1619 }
1620 else
1621 if (pagination) {
1622 query.append(MBDiscussionModelImpl.ORDER_BY_JPQL);
1623 }
1624
1625 String sql = query.toString();
1626
1627 Session session = null;
1628
1629 try {
1630 session = openSession();
1631
1632 Query q = session.createQuery(sql);
1633
1634 QueryPos qPos = QueryPos.getInstance(q);
1635
1636 qPos.add(classNameId);
1637
1638 if (!pagination) {
1639 list = (List<MBDiscussion>)QueryUtil.list(q, getDialect(),
1640 start, end, false);
1641
1642 Collections.sort(list);
1643
1644 list = Collections.unmodifiableList(list);
1645 }
1646 else {
1647 list = (List<MBDiscussion>)QueryUtil.list(q, getDialect(),
1648 start, end);
1649 }
1650
1651 cacheResult(list);
1652
1653 finderCache.putResult(finderPath, finderArgs, list);
1654 }
1655 catch (Exception e) {
1656 finderCache.removeResult(finderPath, finderArgs);
1657
1658 throw processException(e);
1659 }
1660 finally {
1661 closeSession(session);
1662 }
1663 }
1664
1665 return list;
1666 }
1667
1668
1676 @Override
1677 public MBDiscussion findByClassNameId_First(long classNameId,
1678 OrderByComparator<MBDiscussion> orderByComparator)
1679 throws NoSuchDiscussionException {
1680 MBDiscussion mbDiscussion = fetchByClassNameId_First(classNameId,
1681 orderByComparator);
1682
1683 if (mbDiscussion != null) {
1684 return mbDiscussion;
1685 }
1686
1687 StringBundler msg = new StringBundler(4);
1688
1689 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1690
1691 msg.append("classNameId=");
1692 msg.append(classNameId);
1693
1694 msg.append(StringPool.CLOSE_CURLY_BRACE);
1695
1696 throw new NoSuchDiscussionException(msg.toString());
1697 }
1698
1699
1706 @Override
1707 public MBDiscussion fetchByClassNameId_First(long classNameId,
1708 OrderByComparator<MBDiscussion> orderByComparator) {
1709 List<MBDiscussion> list = findByClassNameId(classNameId, 0, 1,
1710 orderByComparator);
1711
1712 if (!list.isEmpty()) {
1713 return list.get(0);
1714 }
1715
1716 return null;
1717 }
1718
1719
1727 @Override
1728 public MBDiscussion findByClassNameId_Last(long classNameId,
1729 OrderByComparator<MBDiscussion> orderByComparator)
1730 throws NoSuchDiscussionException {
1731 MBDiscussion mbDiscussion = fetchByClassNameId_Last(classNameId,
1732 orderByComparator);
1733
1734 if (mbDiscussion != null) {
1735 return mbDiscussion;
1736 }
1737
1738 StringBundler msg = new StringBundler(4);
1739
1740 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1741
1742 msg.append("classNameId=");
1743 msg.append(classNameId);
1744
1745 msg.append(StringPool.CLOSE_CURLY_BRACE);
1746
1747 throw new NoSuchDiscussionException(msg.toString());
1748 }
1749
1750
1757 @Override
1758 public MBDiscussion fetchByClassNameId_Last(long classNameId,
1759 OrderByComparator<MBDiscussion> orderByComparator) {
1760 int count = countByClassNameId(classNameId);
1761
1762 if (count == 0) {
1763 return null;
1764 }
1765
1766 List<MBDiscussion> list = findByClassNameId(classNameId, count - 1,
1767 count, orderByComparator);
1768
1769 if (!list.isEmpty()) {
1770 return list.get(0);
1771 }
1772
1773 return null;
1774 }
1775
1776
1785 @Override
1786 public MBDiscussion[] findByClassNameId_PrevAndNext(long discussionId,
1787 long classNameId, OrderByComparator<MBDiscussion> orderByComparator)
1788 throws NoSuchDiscussionException {
1789 MBDiscussion mbDiscussion = findByPrimaryKey(discussionId);
1790
1791 Session session = null;
1792
1793 try {
1794 session = openSession();
1795
1796 MBDiscussion[] array = new MBDiscussionImpl[3];
1797
1798 array[0] = getByClassNameId_PrevAndNext(session, mbDiscussion,
1799 classNameId, orderByComparator, true);
1800
1801 array[1] = mbDiscussion;
1802
1803 array[2] = getByClassNameId_PrevAndNext(session, mbDiscussion,
1804 classNameId, orderByComparator, false);
1805
1806 return array;
1807 }
1808 catch (Exception e) {
1809 throw processException(e);
1810 }
1811 finally {
1812 closeSession(session);
1813 }
1814 }
1815
1816 protected MBDiscussion getByClassNameId_PrevAndNext(Session session,
1817 MBDiscussion mbDiscussion, long classNameId,
1818 OrderByComparator<MBDiscussion> orderByComparator, boolean previous) {
1819 StringBundler query = null;
1820
1821 if (orderByComparator != null) {
1822 query = new StringBundler(4 +
1823 (orderByComparator.getOrderByConditionFields().length * 3) +
1824 (orderByComparator.getOrderByFields().length * 3));
1825 }
1826 else {
1827 query = new StringBundler(3);
1828 }
1829
1830 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
1831
1832 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
1833
1834 if (orderByComparator != null) {
1835 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1836
1837 if (orderByConditionFields.length > 0) {
1838 query.append(WHERE_AND);
1839 }
1840
1841 for (int i = 0; i < orderByConditionFields.length; i++) {
1842 query.append(_ORDER_BY_ENTITY_ALIAS);
1843 query.append(orderByConditionFields[i]);
1844
1845 if ((i + 1) < orderByConditionFields.length) {
1846 if (orderByComparator.isAscending() ^ previous) {
1847 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1848 }
1849 else {
1850 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1851 }
1852 }
1853 else {
1854 if (orderByComparator.isAscending() ^ previous) {
1855 query.append(WHERE_GREATER_THAN);
1856 }
1857 else {
1858 query.append(WHERE_LESSER_THAN);
1859 }
1860 }
1861 }
1862
1863 query.append(ORDER_BY_CLAUSE);
1864
1865 String[] orderByFields = orderByComparator.getOrderByFields();
1866
1867 for (int i = 0; i < orderByFields.length; i++) {
1868 query.append(_ORDER_BY_ENTITY_ALIAS);
1869 query.append(orderByFields[i]);
1870
1871 if ((i + 1) < orderByFields.length) {
1872 if (orderByComparator.isAscending() ^ previous) {
1873 query.append(ORDER_BY_ASC_HAS_NEXT);
1874 }
1875 else {
1876 query.append(ORDER_BY_DESC_HAS_NEXT);
1877 }
1878 }
1879 else {
1880 if (orderByComparator.isAscending() ^ previous) {
1881 query.append(ORDER_BY_ASC);
1882 }
1883 else {
1884 query.append(ORDER_BY_DESC);
1885 }
1886 }
1887 }
1888 }
1889 else {
1890 query.append(MBDiscussionModelImpl.ORDER_BY_JPQL);
1891 }
1892
1893 String sql = query.toString();
1894
1895 Query q = session.createQuery(sql);
1896
1897 q.setFirstResult(0);
1898 q.setMaxResults(2);
1899
1900 QueryPos qPos = QueryPos.getInstance(q);
1901
1902 qPos.add(classNameId);
1903
1904 if (orderByComparator != null) {
1905 Object[] values = orderByComparator.getOrderByConditionValues(mbDiscussion);
1906
1907 for (Object value : values) {
1908 qPos.add(value);
1909 }
1910 }
1911
1912 List<MBDiscussion> list = q.list();
1913
1914 if (list.size() == 2) {
1915 return list.get(1);
1916 }
1917 else {
1918 return null;
1919 }
1920 }
1921
1922
1927 @Override
1928 public void removeByClassNameId(long classNameId) {
1929 for (MBDiscussion mbDiscussion : findByClassNameId(classNameId,
1930 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1931 remove(mbDiscussion);
1932 }
1933 }
1934
1935
1941 @Override
1942 public int countByClassNameId(long classNameId) {
1943 FinderPath finderPath = FINDER_PATH_COUNT_BY_CLASSNAMEID;
1944
1945 Object[] finderArgs = new Object[] { classNameId };
1946
1947 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1948
1949 if (count == null) {
1950 StringBundler query = new StringBundler(2);
1951
1952 query.append(_SQL_COUNT_MBDISCUSSION_WHERE);
1953
1954 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
1955
1956 String sql = query.toString();
1957
1958 Session session = null;
1959
1960 try {
1961 session = openSession();
1962
1963 Query q = session.createQuery(sql);
1964
1965 QueryPos qPos = QueryPos.getInstance(q);
1966
1967 qPos.add(classNameId);
1968
1969 count = (Long)q.uniqueResult();
1970
1971 finderCache.putResult(finderPath, finderArgs, count);
1972 }
1973 catch (Exception e) {
1974 finderCache.removeResult(finderPath, finderArgs);
1975
1976 throw processException(e);
1977 }
1978 finally {
1979 closeSession(session);
1980 }
1981 }
1982
1983 return count.intValue();
1984 }
1985
1986 private static final String _FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2 = "mbDiscussion.classNameId = ?";
1987 public static final FinderPath FINDER_PATH_FETCH_BY_THREADID = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
1988 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
1989 FINDER_CLASS_NAME_ENTITY, "fetchByThreadId",
1990 new String[] { Long.class.getName() },
1991 MBDiscussionModelImpl.THREADID_COLUMN_BITMASK);
1992 public static final FinderPath FINDER_PATH_COUNT_BY_THREADID = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
1993 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1994 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByThreadId",
1995 new String[] { Long.class.getName() });
1996
1997
2004 @Override
2005 public MBDiscussion findByThreadId(long threadId)
2006 throws NoSuchDiscussionException {
2007 MBDiscussion mbDiscussion = fetchByThreadId(threadId);
2008
2009 if (mbDiscussion == null) {
2010 StringBundler msg = new StringBundler(4);
2011
2012 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2013
2014 msg.append("threadId=");
2015 msg.append(threadId);
2016
2017 msg.append(StringPool.CLOSE_CURLY_BRACE);
2018
2019 if (_log.isDebugEnabled()) {
2020 _log.debug(msg.toString());
2021 }
2022
2023 throw new NoSuchDiscussionException(msg.toString());
2024 }
2025
2026 return mbDiscussion;
2027 }
2028
2029
2035 @Override
2036 public MBDiscussion fetchByThreadId(long threadId) {
2037 return fetchByThreadId(threadId, true);
2038 }
2039
2040
2047 @Override
2048 public MBDiscussion fetchByThreadId(long threadId, boolean retrieveFromCache) {
2049 Object[] finderArgs = new Object[] { threadId };
2050
2051 Object result = null;
2052
2053 if (retrieveFromCache) {
2054 result = finderCache.getResult(FINDER_PATH_FETCH_BY_THREADID,
2055 finderArgs, this);
2056 }
2057
2058 if (result instanceof MBDiscussion) {
2059 MBDiscussion mbDiscussion = (MBDiscussion)result;
2060
2061 if ((threadId != mbDiscussion.getThreadId())) {
2062 result = null;
2063 }
2064 }
2065
2066 if (result == null) {
2067 StringBundler query = new StringBundler(3);
2068
2069 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
2070
2071 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
2072
2073 String sql = query.toString();
2074
2075 Session session = null;
2076
2077 try {
2078 session = openSession();
2079
2080 Query q = session.createQuery(sql);
2081
2082 QueryPos qPos = QueryPos.getInstance(q);
2083
2084 qPos.add(threadId);
2085
2086 List<MBDiscussion> list = q.list();
2087
2088 if (list.isEmpty()) {
2089 finderCache.putResult(FINDER_PATH_FETCH_BY_THREADID,
2090 finderArgs, list);
2091 }
2092 else {
2093 MBDiscussion mbDiscussion = list.get(0);
2094
2095 result = mbDiscussion;
2096
2097 cacheResult(mbDiscussion);
2098
2099 if ((mbDiscussion.getThreadId() != threadId)) {
2100 finderCache.putResult(FINDER_PATH_FETCH_BY_THREADID,
2101 finderArgs, mbDiscussion);
2102 }
2103 }
2104 }
2105 catch (Exception e) {
2106 finderCache.removeResult(FINDER_PATH_FETCH_BY_THREADID,
2107 finderArgs);
2108
2109 throw processException(e);
2110 }
2111 finally {
2112 closeSession(session);
2113 }
2114 }
2115
2116 if (result instanceof List<?>) {
2117 return null;
2118 }
2119 else {
2120 return (MBDiscussion)result;
2121 }
2122 }
2123
2124
2130 @Override
2131 public MBDiscussion removeByThreadId(long threadId)
2132 throws NoSuchDiscussionException {
2133 MBDiscussion mbDiscussion = findByThreadId(threadId);
2134
2135 return remove(mbDiscussion);
2136 }
2137
2138
2144 @Override
2145 public int countByThreadId(long threadId) {
2146 FinderPath finderPath = FINDER_PATH_COUNT_BY_THREADID;
2147
2148 Object[] finderArgs = new Object[] { threadId };
2149
2150 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2151
2152 if (count == null) {
2153 StringBundler query = new StringBundler(2);
2154
2155 query.append(_SQL_COUNT_MBDISCUSSION_WHERE);
2156
2157 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
2158
2159 String sql = query.toString();
2160
2161 Session session = null;
2162
2163 try {
2164 session = openSession();
2165
2166 Query q = session.createQuery(sql);
2167
2168 QueryPos qPos = QueryPos.getInstance(q);
2169
2170 qPos.add(threadId);
2171
2172 count = (Long)q.uniqueResult();
2173
2174 finderCache.putResult(finderPath, finderArgs, count);
2175 }
2176 catch (Exception e) {
2177 finderCache.removeResult(finderPath, finderArgs);
2178
2179 throw processException(e);
2180 }
2181 finally {
2182 closeSession(session);
2183 }
2184 }
2185
2186 return count.intValue();
2187 }
2188
2189 private static final String _FINDER_COLUMN_THREADID_THREADID_2 = "mbDiscussion.threadId = ?";
2190 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2191 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, MBDiscussionImpl.class,
2192 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
2193 new String[] { Long.class.getName(), Long.class.getName() },
2194 MBDiscussionModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2195 MBDiscussionModelImpl.CLASSPK_COLUMN_BITMASK);
2196 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2197 MBDiscussionModelImpl.FINDER_CACHE_ENABLED, Long.class,
2198 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2199 new String[] { Long.class.getName(), Long.class.getName() });
2200
2201
2209 @Override
2210 public MBDiscussion findByC_C(long classNameId, long classPK)
2211 throws NoSuchDiscussionException {
2212 MBDiscussion mbDiscussion = fetchByC_C(classNameId, classPK);
2213
2214 if (mbDiscussion == null) {
2215 StringBundler msg = new StringBundler(6);
2216
2217 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2218
2219 msg.append("classNameId=");
2220 msg.append(classNameId);
2221
2222 msg.append(", classPK=");
2223 msg.append(classPK);
2224
2225 msg.append(StringPool.CLOSE_CURLY_BRACE);
2226
2227 if (_log.isDebugEnabled()) {
2228 _log.debug(msg.toString());
2229 }
2230
2231 throw new NoSuchDiscussionException(msg.toString());
2232 }
2233
2234 return mbDiscussion;
2235 }
2236
2237
2244 @Override
2245 public MBDiscussion fetchByC_C(long classNameId, long classPK) {
2246 return fetchByC_C(classNameId, classPK, true);
2247 }
2248
2249
2257 @Override
2258 public MBDiscussion fetchByC_C(long classNameId, long classPK,
2259 boolean retrieveFromCache) {
2260 Object[] finderArgs = new Object[] { classNameId, classPK };
2261
2262 Object result = null;
2263
2264 if (retrieveFromCache) {
2265 result = finderCache.getResult(FINDER_PATH_FETCH_BY_C_C,
2266 finderArgs, this);
2267 }
2268
2269 if (result instanceof MBDiscussion) {
2270 MBDiscussion mbDiscussion = (MBDiscussion)result;
2271
2272 if ((classNameId != mbDiscussion.getClassNameId()) ||
2273 (classPK != mbDiscussion.getClassPK())) {
2274 result = null;
2275 }
2276 }
2277
2278 if (result == null) {
2279 StringBundler query = new StringBundler(4);
2280
2281 query.append(_SQL_SELECT_MBDISCUSSION_WHERE);
2282
2283 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2284
2285 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2286
2287 String sql = query.toString();
2288
2289 Session session = null;
2290
2291 try {
2292 session = openSession();
2293
2294 Query q = session.createQuery(sql);
2295
2296 QueryPos qPos = QueryPos.getInstance(q);
2297
2298 qPos.add(classNameId);
2299
2300 qPos.add(classPK);
2301
2302 List<MBDiscussion> list = q.list();
2303
2304 if (list.isEmpty()) {
2305 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, finderArgs,
2306 list);
2307 }
2308 else {
2309 MBDiscussion mbDiscussion = list.get(0);
2310
2311 result = mbDiscussion;
2312
2313 cacheResult(mbDiscussion);
2314
2315 if ((mbDiscussion.getClassNameId() != classNameId) ||
2316 (mbDiscussion.getClassPK() != classPK)) {
2317 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C,
2318 finderArgs, mbDiscussion);
2319 }
2320 }
2321 }
2322 catch (Exception e) {
2323 finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, finderArgs);
2324
2325 throw processException(e);
2326 }
2327 finally {
2328 closeSession(session);
2329 }
2330 }
2331
2332 if (result instanceof List<?>) {
2333 return null;
2334 }
2335 else {
2336 return (MBDiscussion)result;
2337 }
2338 }
2339
2340
2347 @Override
2348 public MBDiscussion removeByC_C(long classNameId, long classPK)
2349 throws NoSuchDiscussionException {
2350 MBDiscussion mbDiscussion = findByC_C(classNameId, classPK);
2351
2352 return remove(mbDiscussion);
2353 }
2354
2355
2362 @Override
2363 public int countByC_C(long classNameId, long classPK) {
2364 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
2365
2366 Object[] finderArgs = new Object[] { classNameId, classPK };
2367
2368 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2369
2370 if (count == null) {
2371 StringBundler query = new StringBundler(3);
2372
2373 query.append(_SQL_COUNT_MBDISCUSSION_WHERE);
2374
2375 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2376
2377 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2378
2379 String sql = query.toString();
2380
2381 Session session = null;
2382
2383 try {
2384 session = openSession();
2385
2386 Query q = session.createQuery(sql);
2387
2388 QueryPos qPos = QueryPos.getInstance(q);
2389
2390 qPos.add(classNameId);
2391
2392 qPos.add(classPK);
2393
2394 count = (Long)q.uniqueResult();
2395
2396 finderCache.putResult(finderPath, finderArgs, count);
2397 }
2398 catch (Exception e) {
2399 finderCache.removeResult(finderPath, finderArgs);
2400
2401 throw processException(e);
2402 }
2403 finally {
2404 closeSession(session);
2405 }
2406 }
2407
2408 return count.intValue();
2409 }
2410
2411 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "mbDiscussion.classNameId = ? AND ";
2412 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "mbDiscussion.classPK = ?";
2413
2414 public MBDiscussionPersistenceImpl() {
2415 setModelClass(MBDiscussion.class);
2416 }
2417
2418
2423 @Override
2424 public void cacheResult(MBDiscussion mbDiscussion) {
2425 entityCache.putResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2426 MBDiscussionImpl.class, mbDiscussion.getPrimaryKey(), mbDiscussion);
2427
2428 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2429 new Object[] { mbDiscussion.getUuid(), mbDiscussion.getGroupId() },
2430 mbDiscussion);
2431
2432 finderCache.putResult(FINDER_PATH_FETCH_BY_THREADID,
2433 new Object[] { mbDiscussion.getThreadId() }, mbDiscussion);
2434
2435 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C,
2436 new Object[] {
2437 mbDiscussion.getClassNameId(), mbDiscussion.getClassPK()
2438 }, mbDiscussion);
2439
2440 mbDiscussion.resetOriginalValues();
2441 }
2442
2443
2448 @Override
2449 public void cacheResult(List<MBDiscussion> mbDiscussions) {
2450 for (MBDiscussion mbDiscussion : mbDiscussions) {
2451 if (entityCache.getResult(
2452 MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2453 MBDiscussionImpl.class, mbDiscussion.getPrimaryKey()) == null) {
2454 cacheResult(mbDiscussion);
2455 }
2456 else {
2457 mbDiscussion.resetOriginalValues();
2458 }
2459 }
2460 }
2461
2462
2469 @Override
2470 public void clearCache() {
2471 entityCache.clearCache(MBDiscussionImpl.class);
2472
2473 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
2474 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2475 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2476 }
2477
2478
2485 @Override
2486 public void clearCache(MBDiscussion mbDiscussion) {
2487 entityCache.removeResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2488 MBDiscussionImpl.class, mbDiscussion.getPrimaryKey());
2489
2490 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2491 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2492
2493 clearUniqueFindersCache((MBDiscussionModelImpl)mbDiscussion);
2494 }
2495
2496 @Override
2497 public void clearCache(List<MBDiscussion> mbDiscussions) {
2498 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2499 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2500
2501 for (MBDiscussion mbDiscussion : mbDiscussions) {
2502 entityCache.removeResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2503 MBDiscussionImpl.class, mbDiscussion.getPrimaryKey());
2504
2505 clearUniqueFindersCache((MBDiscussionModelImpl)mbDiscussion);
2506 }
2507 }
2508
2509 protected void cacheUniqueFindersCache(
2510 MBDiscussionModelImpl mbDiscussionModelImpl, boolean isNew) {
2511 if (isNew) {
2512 Object[] args = new Object[] {
2513 mbDiscussionModelImpl.getUuid(),
2514 mbDiscussionModelImpl.getGroupId()
2515 };
2516
2517 finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2518 Long.valueOf(1));
2519 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2520 mbDiscussionModelImpl);
2521
2522 args = new Object[] { mbDiscussionModelImpl.getThreadId() };
2523
2524 finderCache.putResult(FINDER_PATH_COUNT_BY_THREADID, args,
2525 Long.valueOf(1));
2526 finderCache.putResult(FINDER_PATH_FETCH_BY_THREADID, args,
2527 mbDiscussionModelImpl);
2528
2529 args = new Object[] {
2530 mbDiscussionModelImpl.getClassNameId(),
2531 mbDiscussionModelImpl.getClassPK()
2532 };
2533
2534 finderCache.putResult(FINDER_PATH_COUNT_BY_C_C, args,
2535 Long.valueOf(1));
2536 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, args,
2537 mbDiscussionModelImpl);
2538 }
2539 else {
2540 if ((mbDiscussionModelImpl.getColumnBitmask() &
2541 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2542 Object[] args = new Object[] {
2543 mbDiscussionModelImpl.getUuid(),
2544 mbDiscussionModelImpl.getGroupId()
2545 };
2546
2547 finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2548 Long.valueOf(1));
2549 finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2550 mbDiscussionModelImpl);
2551 }
2552
2553 if ((mbDiscussionModelImpl.getColumnBitmask() &
2554 FINDER_PATH_FETCH_BY_THREADID.getColumnBitmask()) != 0) {
2555 Object[] args = new Object[] { mbDiscussionModelImpl.getThreadId() };
2556
2557 finderCache.putResult(FINDER_PATH_COUNT_BY_THREADID, args,
2558 Long.valueOf(1));
2559 finderCache.putResult(FINDER_PATH_FETCH_BY_THREADID, args,
2560 mbDiscussionModelImpl);
2561 }
2562
2563 if ((mbDiscussionModelImpl.getColumnBitmask() &
2564 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
2565 Object[] args = new Object[] {
2566 mbDiscussionModelImpl.getClassNameId(),
2567 mbDiscussionModelImpl.getClassPK()
2568 };
2569
2570 finderCache.putResult(FINDER_PATH_COUNT_BY_C_C, args,
2571 Long.valueOf(1));
2572 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, args,
2573 mbDiscussionModelImpl);
2574 }
2575 }
2576 }
2577
2578 protected void clearUniqueFindersCache(
2579 MBDiscussionModelImpl mbDiscussionModelImpl) {
2580 Object[] args = new Object[] {
2581 mbDiscussionModelImpl.getUuid(),
2582 mbDiscussionModelImpl.getGroupId()
2583 };
2584
2585 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2586 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2587
2588 if ((mbDiscussionModelImpl.getColumnBitmask() &
2589 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2590 args = new Object[] {
2591 mbDiscussionModelImpl.getOriginalUuid(),
2592 mbDiscussionModelImpl.getOriginalGroupId()
2593 };
2594
2595 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2596 finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2597 }
2598
2599 args = new Object[] { mbDiscussionModelImpl.getThreadId() };
2600
2601 finderCache.removeResult(FINDER_PATH_COUNT_BY_THREADID, args);
2602 finderCache.removeResult(FINDER_PATH_FETCH_BY_THREADID, args);
2603
2604 if ((mbDiscussionModelImpl.getColumnBitmask() &
2605 FINDER_PATH_FETCH_BY_THREADID.getColumnBitmask()) != 0) {
2606 args = new Object[] { mbDiscussionModelImpl.getOriginalThreadId() };
2607
2608 finderCache.removeResult(FINDER_PATH_COUNT_BY_THREADID, args);
2609 finderCache.removeResult(FINDER_PATH_FETCH_BY_THREADID, args);
2610 }
2611
2612 args = new Object[] {
2613 mbDiscussionModelImpl.getClassNameId(),
2614 mbDiscussionModelImpl.getClassPK()
2615 };
2616
2617 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
2618 finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
2619
2620 if ((mbDiscussionModelImpl.getColumnBitmask() &
2621 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
2622 args = new Object[] {
2623 mbDiscussionModelImpl.getOriginalClassNameId(),
2624 mbDiscussionModelImpl.getOriginalClassPK()
2625 };
2626
2627 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
2628 finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
2629 }
2630 }
2631
2632
2638 @Override
2639 public MBDiscussion create(long discussionId) {
2640 MBDiscussion mbDiscussion = new MBDiscussionImpl();
2641
2642 mbDiscussion.setNew(true);
2643 mbDiscussion.setPrimaryKey(discussionId);
2644
2645 String uuid = PortalUUIDUtil.generate();
2646
2647 mbDiscussion.setUuid(uuid);
2648
2649 mbDiscussion.setCompanyId(companyProvider.getCompanyId());
2650
2651 return mbDiscussion;
2652 }
2653
2654
2661 @Override
2662 public MBDiscussion remove(long discussionId)
2663 throws NoSuchDiscussionException {
2664 return remove((Serializable)discussionId);
2665 }
2666
2667
2674 @Override
2675 public MBDiscussion remove(Serializable primaryKey)
2676 throws NoSuchDiscussionException {
2677 Session session = null;
2678
2679 try {
2680 session = openSession();
2681
2682 MBDiscussion mbDiscussion = (MBDiscussion)session.get(MBDiscussionImpl.class,
2683 primaryKey);
2684
2685 if (mbDiscussion == null) {
2686 if (_log.isDebugEnabled()) {
2687 _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2688 }
2689
2690 throw new NoSuchDiscussionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2691 primaryKey);
2692 }
2693
2694 return remove(mbDiscussion);
2695 }
2696 catch (NoSuchDiscussionException nsee) {
2697 throw nsee;
2698 }
2699 catch (Exception e) {
2700 throw processException(e);
2701 }
2702 finally {
2703 closeSession(session);
2704 }
2705 }
2706
2707 @Override
2708 protected MBDiscussion removeImpl(MBDiscussion mbDiscussion) {
2709 mbDiscussion = toUnwrappedModel(mbDiscussion);
2710
2711 Session session = null;
2712
2713 try {
2714 session = openSession();
2715
2716 if (!session.contains(mbDiscussion)) {
2717 mbDiscussion = (MBDiscussion)session.get(MBDiscussionImpl.class,
2718 mbDiscussion.getPrimaryKeyObj());
2719 }
2720
2721 if (mbDiscussion != null) {
2722 session.delete(mbDiscussion);
2723 }
2724 }
2725 catch (Exception e) {
2726 throw processException(e);
2727 }
2728 finally {
2729 closeSession(session);
2730 }
2731
2732 if (mbDiscussion != null) {
2733 clearCache(mbDiscussion);
2734 }
2735
2736 return mbDiscussion;
2737 }
2738
2739 @Override
2740 public MBDiscussion updateImpl(MBDiscussion mbDiscussion) {
2741 mbDiscussion = toUnwrappedModel(mbDiscussion);
2742
2743 boolean isNew = mbDiscussion.isNew();
2744
2745 MBDiscussionModelImpl mbDiscussionModelImpl = (MBDiscussionModelImpl)mbDiscussion;
2746
2747 if (Validator.isNull(mbDiscussion.getUuid())) {
2748 String uuid = PortalUUIDUtil.generate();
2749
2750 mbDiscussion.setUuid(uuid);
2751 }
2752
2753 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
2754
2755 Date now = new Date();
2756
2757 if (isNew && (mbDiscussion.getCreateDate() == null)) {
2758 if (serviceContext == null) {
2759 mbDiscussion.setCreateDate(now);
2760 }
2761 else {
2762 mbDiscussion.setCreateDate(serviceContext.getCreateDate(now));
2763 }
2764 }
2765
2766 if (!mbDiscussionModelImpl.hasSetModifiedDate()) {
2767 if (serviceContext == null) {
2768 mbDiscussion.setModifiedDate(now);
2769 }
2770 else {
2771 mbDiscussion.setModifiedDate(serviceContext.getModifiedDate(now));
2772 }
2773 }
2774
2775 Session session = null;
2776
2777 try {
2778 session = openSession();
2779
2780 if (mbDiscussion.isNew()) {
2781 session.save(mbDiscussion);
2782
2783 mbDiscussion.setNew(false);
2784 }
2785 else {
2786 mbDiscussion = (MBDiscussion)session.merge(mbDiscussion);
2787 }
2788 }
2789 catch (Exception e) {
2790 throw processException(e);
2791 }
2792 finally {
2793 closeSession(session);
2794 }
2795
2796 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2797
2798 if (isNew || !MBDiscussionModelImpl.COLUMN_BITMASK_ENABLED) {
2799 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2800 }
2801
2802 else {
2803 if ((mbDiscussionModelImpl.getColumnBitmask() &
2804 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2805 Object[] args = new Object[] {
2806 mbDiscussionModelImpl.getOriginalUuid()
2807 };
2808
2809 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2810 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2811 args);
2812
2813 args = new Object[] { mbDiscussionModelImpl.getUuid() };
2814
2815 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2816 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2817 args);
2818 }
2819
2820 if ((mbDiscussionModelImpl.getColumnBitmask() &
2821 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2822 Object[] args = new Object[] {
2823 mbDiscussionModelImpl.getOriginalUuid(),
2824 mbDiscussionModelImpl.getOriginalCompanyId()
2825 };
2826
2827 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2828 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2829 args);
2830
2831 args = new Object[] {
2832 mbDiscussionModelImpl.getUuid(),
2833 mbDiscussionModelImpl.getCompanyId()
2834 };
2835
2836 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2837 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2838 args);
2839 }
2840
2841 if ((mbDiscussionModelImpl.getColumnBitmask() &
2842 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID.getColumnBitmask()) != 0) {
2843 Object[] args = new Object[] {
2844 mbDiscussionModelImpl.getOriginalClassNameId()
2845 };
2846
2847 finderCache.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID, args);
2848 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
2849 args);
2850
2851 args = new Object[] { mbDiscussionModelImpl.getClassNameId() };
2852
2853 finderCache.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID, args);
2854 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
2855 args);
2856 }
2857 }
2858
2859 entityCache.putResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2860 MBDiscussionImpl.class, mbDiscussion.getPrimaryKey(), mbDiscussion,
2861 false);
2862
2863 clearUniqueFindersCache(mbDiscussionModelImpl);
2864 cacheUniqueFindersCache(mbDiscussionModelImpl, isNew);
2865
2866 mbDiscussion.resetOriginalValues();
2867
2868 return mbDiscussion;
2869 }
2870
2871 protected MBDiscussion toUnwrappedModel(MBDiscussion mbDiscussion) {
2872 if (mbDiscussion instanceof MBDiscussionImpl) {
2873 return mbDiscussion;
2874 }
2875
2876 MBDiscussionImpl mbDiscussionImpl = new MBDiscussionImpl();
2877
2878 mbDiscussionImpl.setNew(mbDiscussion.isNew());
2879 mbDiscussionImpl.setPrimaryKey(mbDiscussion.getPrimaryKey());
2880
2881 mbDiscussionImpl.setUuid(mbDiscussion.getUuid());
2882 mbDiscussionImpl.setDiscussionId(mbDiscussion.getDiscussionId());
2883 mbDiscussionImpl.setGroupId(mbDiscussion.getGroupId());
2884 mbDiscussionImpl.setCompanyId(mbDiscussion.getCompanyId());
2885 mbDiscussionImpl.setUserId(mbDiscussion.getUserId());
2886 mbDiscussionImpl.setUserName(mbDiscussion.getUserName());
2887 mbDiscussionImpl.setCreateDate(mbDiscussion.getCreateDate());
2888 mbDiscussionImpl.setModifiedDate(mbDiscussion.getModifiedDate());
2889 mbDiscussionImpl.setClassNameId(mbDiscussion.getClassNameId());
2890 mbDiscussionImpl.setClassPK(mbDiscussion.getClassPK());
2891 mbDiscussionImpl.setThreadId(mbDiscussion.getThreadId());
2892 mbDiscussionImpl.setLastPublishDate(mbDiscussion.getLastPublishDate());
2893
2894 return mbDiscussionImpl;
2895 }
2896
2897
2904 @Override
2905 public MBDiscussion findByPrimaryKey(Serializable primaryKey)
2906 throws NoSuchDiscussionException {
2907 MBDiscussion mbDiscussion = fetchByPrimaryKey(primaryKey);
2908
2909 if (mbDiscussion == null) {
2910 if (_log.isDebugEnabled()) {
2911 _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2912 }
2913
2914 throw new NoSuchDiscussionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2915 primaryKey);
2916 }
2917
2918 return mbDiscussion;
2919 }
2920
2921
2928 @Override
2929 public MBDiscussion findByPrimaryKey(long discussionId)
2930 throws NoSuchDiscussionException {
2931 return findByPrimaryKey((Serializable)discussionId);
2932 }
2933
2934
2940 @Override
2941 public MBDiscussion fetchByPrimaryKey(Serializable primaryKey) {
2942 MBDiscussion mbDiscussion = (MBDiscussion)entityCache.getResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2943 MBDiscussionImpl.class, primaryKey);
2944
2945 if (mbDiscussion == _nullMBDiscussion) {
2946 return null;
2947 }
2948
2949 if (mbDiscussion == null) {
2950 Session session = null;
2951
2952 try {
2953 session = openSession();
2954
2955 mbDiscussion = (MBDiscussion)session.get(MBDiscussionImpl.class,
2956 primaryKey);
2957
2958 if (mbDiscussion != null) {
2959 cacheResult(mbDiscussion);
2960 }
2961 else {
2962 entityCache.putResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2963 MBDiscussionImpl.class, primaryKey, _nullMBDiscussion);
2964 }
2965 }
2966 catch (Exception e) {
2967 entityCache.removeResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
2968 MBDiscussionImpl.class, primaryKey);
2969
2970 throw processException(e);
2971 }
2972 finally {
2973 closeSession(session);
2974 }
2975 }
2976
2977 return mbDiscussion;
2978 }
2979
2980
2986 @Override
2987 public MBDiscussion fetchByPrimaryKey(long discussionId) {
2988 return fetchByPrimaryKey((Serializable)discussionId);
2989 }
2990
2991 @Override
2992 public Map<Serializable, MBDiscussion> fetchByPrimaryKeys(
2993 Set<Serializable> primaryKeys) {
2994 if (primaryKeys.isEmpty()) {
2995 return Collections.emptyMap();
2996 }
2997
2998 Map<Serializable, MBDiscussion> map = new HashMap<Serializable, MBDiscussion>();
2999
3000 if (primaryKeys.size() == 1) {
3001 Iterator<Serializable> iterator = primaryKeys.iterator();
3002
3003 Serializable primaryKey = iterator.next();
3004
3005 MBDiscussion mbDiscussion = fetchByPrimaryKey(primaryKey);
3006
3007 if (mbDiscussion != null) {
3008 map.put(primaryKey, mbDiscussion);
3009 }
3010
3011 return map;
3012 }
3013
3014 Set<Serializable> uncachedPrimaryKeys = null;
3015
3016 for (Serializable primaryKey : primaryKeys) {
3017 MBDiscussion mbDiscussion = (MBDiscussion)entityCache.getResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
3018 MBDiscussionImpl.class, primaryKey);
3019
3020 if (mbDiscussion == null) {
3021 if (uncachedPrimaryKeys == null) {
3022 uncachedPrimaryKeys = new HashSet<Serializable>();
3023 }
3024
3025 uncachedPrimaryKeys.add(primaryKey);
3026 }
3027 else {
3028 map.put(primaryKey, mbDiscussion);
3029 }
3030 }
3031
3032 if (uncachedPrimaryKeys == null) {
3033 return map;
3034 }
3035
3036 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3037 1);
3038
3039 query.append(_SQL_SELECT_MBDISCUSSION_WHERE_PKS_IN);
3040
3041 for (Serializable primaryKey : uncachedPrimaryKeys) {
3042 query.append(String.valueOf(primaryKey));
3043
3044 query.append(StringPool.COMMA);
3045 }
3046
3047 query.setIndex(query.index() - 1);
3048
3049 query.append(StringPool.CLOSE_PARENTHESIS);
3050
3051 String sql = query.toString();
3052
3053 Session session = null;
3054
3055 try {
3056 session = openSession();
3057
3058 Query q = session.createQuery(sql);
3059
3060 for (MBDiscussion mbDiscussion : (List<MBDiscussion>)q.list()) {
3061 map.put(mbDiscussion.getPrimaryKeyObj(), mbDiscussion);
3062
3063 cacheResult(mbDiscussion);
3064
3065 uncachedPrimaryKeys.remove(mbDiscussion.getPrimaryKeyObj());
3066 }
3067
3068 for (Serializable primaryKey : uncachedPrimaryKeys) {
3069 entityCache.putResult(MBDiscussionModelImpl.ENTITY_CACHE_ENABLED,
3070 MBDiscussionImpl.class, primaryKey, _nullMBDiscussion);
3071 }
3072 }
3073 catch (Exception e) {
3074 throw processException(e);
3075 }
3076 finally {
3077 closeSession(session);
3078 }
3079
3080 return map;
3081 }
3082
3083
3088 @Override
3089 public List<MBDiscussion> findAll() {
3090 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3091 }
3092
3093
3104 @Override
3105 public List<MBDiscussion> findAll(int start, int end) {
3106 return findAll(start, end, null);
3107 }
3108
3109
3121 @Override
3122 public List<MBDiscussion> findAll(int start, int end,
3123 OrderByComparator<MBDiscussion> orderByComparator) {
3124 return findAll(start, end, orderByComparator, true);
3125 }
3126
3127
3140 @Override
3141 public List<MBDiscussion> findAll(int start, int end,
3142 OrderByComparator<MBDiscussion> orderByComparator,
3143 boolean retrieveFromCache) {
3144 boolean pagination = true;
3145 FinderPath finderPath = null;
3146 Object[] finderArgs = null;
3147
3148 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3149 (orderByComparator == null)) {
3150 pagination = false;
3151 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3152 finderArgs = FINDER_ARGS_EMPTY;
3153 }
3154 else {
3155 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3156 finderArgs = new Object[] { start, end, orderByComparator };
3157 }
3158
3159 List<MBDiscussion> list = null;
3160
3161 if (retrieveFromCache) {
3162 list = (List<MBDiscussion>)finderCache.getResult(finderPath,
3163 finderArgs, this);
3164 }
3165
3166 if (list == null) {
3167 StringBundler query = null;
3168 String sql = null;
3169
3170 if (orderByComparator != null) {
3171 query = new StringBundler(2 +
3172 (orderByComparator.getOrderByFields().length * 2));
3173
3174 query.append(_SQL_SELECT_MBDISCUSSION);
3175
3176 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3177 orderByComparator);
3178
3179 sql = query.toString();
3180 }
3181 else {
3182 sql = _SQL_SELECT_MBDISCUSSION;
3183
3184 if (pagination) {
3185 sql = sql.concat(MBDiscussionModelImpl.ORDER_BY_JPQL);
3186 }
3187 }
3188
3189 Session session = null;
3190
3191 try {
3192 session = openSession();
3193
3194 Query q = session.createQuery(sql);
3195
3196 if (!pagination) {
3197 list = (List<MBDiscussion>)QueryUtil.list(q, getDialect(),
3198 start, end, false);
3199
3200 Collections.sort(list);
3201
3202 list = Collections.unmodifiableList(list);
3203 }
3204 else {
3205 list = (List<MBDiscussion>)QueryUtil.list(q, getDialect(),
3206 start, end);
3207 }
3208
3209 cacheResult(list);
3210
3211 finderCache.putResult(finderPath, finderArgs, list);
3212 }
3213 catch (Exception e) {
3214 finderCache.removeResult(finderPath, finderArgs);
3215
3216 throw processException(e);
3217 }
3218 finally {
3219 closeSession(session);
3220 }
3221 }
3222
3223 return list;
3224 }
3225
3226
3230 @Override
3231 public void removeAll() {
3232 for (MBDiscussion mbDiscussion : findAll()) {
3233 remove(mbDiscussion);
3234 }
3235 }
3236
3237
3242 @Override
3243 public int countAll() {
3244 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
3245 FINDER_ARGS_EMPTY, this);
3246
3247 if (count == null) {
3248 Session session = null;
3249
3250 try {
3251 session = openSession();
3252
3253 Query q = session.createQuery(_SQL_COUNT_MBDISCUSSION);
3254
3255 count = (Long)q.uniqueResult();
3256
3257 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
3258 count);
3259 }
3260 catch (Exception e) {
3261 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
3262 FINDER_ARGS_EMPTY);
3263
3264 throw processException(e);
3265 }
3266 finally {
3267 closeSession(session);
3268 }
3269 }
3270
3271 return count.intValue();
3272 }
3273
3274 @Override
3275 public Set<String> getBadColumnNames() {
3276 return _badColumnNames;
3277 }
3278
3279 @Override
3280 protected Map<String, Integer> getTableColumnsMap() {
3281 return MBDiscussionModelImpl.TABLE_COLUMNS_MAP;
3282 }
3283
3284
3287 public void afterPropertiesSet() {
3288 }
3289
3290 public void destroy() {
3291 entityCache.removeCache(MBDiscussionImpl.class.getName());
3292 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
3293 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3294 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3295 }
3296
3297 @BeanReference(type = CompanyProviderWrapper.class)
3298 protected CompanyProvider companyProvider;
3299 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
3300 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
3301 private static final String _SQL_SELECT_MBDISCUSSION = "SELECT mbDiscussion FROM MBDiscussion mbDiscussion";
3302 private static final String _SQL_SELECT_MBDISCUSSION_WHERE_PKS_IN = "SELECT mbDiscussion FROM MBDiscussion mbDiscussion WHERE discussionId IN (";
3303 private static final String _SQL_SELECT_MBDISCUSSION_WHERE = "SELECT mbDiscussion FROM MBDiscussion mbDiscussion WHERE ";
3304 private static final String _SQL_COUNT_MBDISCUSSION = "SELECT COUNT(mbDiscussion) FROM MBDiscussion mbDiscussion";
3305 private static final String _SQL_COUNT_MBDISCUSSION_WHERE = "SELECT COUNT(mbDiscussion) FROM MBDiscussion mbDiscussion WHERE ";
3306 private static final String _ORDER_BY_ENTITY_ALIAS = "mbDiscussion.";
3307 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBDiscussion exists with the primary key ";
3308 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBDiscussion exists with the key {";
3309 private static final Log _log = LogFactoryUtil.getLog(MBDiscussionPersistenceImpl.class);
3310 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3311 "uuid"
3312 });
3313 private static final MBDiscussion _nullMBDiscussion = new MBDiscussionImpl() {
3314 @Override
3315 public Object clone() {
3316 return this;
3317 }
3318
3319 @Override
3320 public CacheModel<MBDiscussion> toCacheModel() {
3321 return _nullMBDiscussionCacheModel;
3322 }
3323 };
3324
3325 private static final CacheModel<MBDiscussion> _nullMBDiscussionCacheModel = new CacheModel<MBDiscussion>() {
3326 @Override
3327 public MBDiscussion toEntityModel() {
3328 return _nullMBDiscussion;
3329 }
3330 };
3331 }