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