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