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