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