1
19
20 package com.liferay.portlet.messageboards.service.persistence;
21
22 import com.liferay.portal.SystemException;
23 import com.liferay.portal.kernel.annotation.BeanReference;
24 import com.liferay.portal.kernel.cache.CacheRegistry;
25 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
26 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
27 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.FinderPath;
29 import com.liferay.portal.kernel.dao.orm.Query;
30 import com.liferay.portal.kernel.dao.orm.QueryPos;
31 import com.liferay.portal.kernel.dao.orm.QueryUtil;
32 import com.liferay.portal.kernel.dao.orm.Session;
33 import com.liferay.portal.kernel.log.Log;
34 import com.liferay.portal.kernel.log.LogFactoryUtil;
35 import com.liferay.portal.kernel.util.GetterUtil;
36 import com.liferay.portal.kernel.util.OrderByComparator;
37 import com.liferay.portal.kernel.util.StringPool;
38 import com.liferay.portal.kernel.util.StringUtil;
39 import com.liferay.portal.kernel.util.Validator;
40 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
41 import com.liferay.portal.model.ModelListener;
42 import com.liferay.portal.service.persistence.BatchSessionUtil;
43 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
44
45 import com.liferay.portlet.messageboards.NoSuchCategoryException;
46 import com.liferay.portlet.messageboards.model.MBCategory;
47 import com.liferay.portlet.messageboards.model.impl.MBCategoryImpl;
48 import com.liferay.portlet.messageboards.model.impl.MBCategoryModelImpl;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.List;
53
54
60 public class MBCategoryPersistenceImpl extends BasePersistenceImpl
61 implements MBCategoryPersistence {
62 public static final String FINDER_CLASS_NAME_ENTITY = MBCategoryImpl.class.getName();
63 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
64 ".List";
65 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
66 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
67 "findByUuid", new String[] { String.class.getName() });
68 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
69 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
70 "findByUuid",
71 new String[] {
72 String.class.getName(),
73
74 "java.lang.Integer", "java.lang.Integer",
75 "com.liferay.portal.kernel.util.OrderByComparator"
76 });
77 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
78 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
79 "countByUuid", new String[] { String.class.getName() });
80 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
81 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
82 "fetchByUUID_G",
83 new String[] { String.class.getName(), Long.class.getName() });
84 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
85 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
86 "countByUUID_G",
87 new String[] { String.class.getName(), Long.class.getName() });
88 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
89 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
90 "findByGroupId", new String[] { Long.class.getName() });
91 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
92 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
93 "findByGroupId",
94 new String[] {
95 Long.class.getName(),
96
97 "java.lang.Integer", "java.lang.Integer",
98 "com.liferay.portal.kernel.util.OrderByComparator"
99 });
100 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
101 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
102 "countByGroupId", new String[] { Long.class.getName() });
103 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
104 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105 "findByCompanyId", new String[] { Long.class.getName() });
106 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
107 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108 "findByCompanyId",
109 new String[] {
110 Long.class.getName(),
111
112 "java.lang.Integer", "java.lang.Integer",
113 "com.liferay.portal.kernel.util.OrderByComparator"
114 });
115 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
116 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117 "countByCompanyId", new String[] { Long.class.getName() });
118 public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
119 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
120 "findByG_P",
121 new String[] { Long.class.getName(), Long.class.getName() });
122 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
123 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
124 "findByG_P",
125 new String[] {
126 Long.class.getName(), Long.class.getName(),
127
128 "java.lang.Integer", "java.lang.Integer",
129 "com.liferay.portal.kernel.util.OrderByComparator"
130 });
131 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
132 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
133 "countByG_P",
134 new String[] { Long.class.getName(), Long.class.getName() });
135 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
136 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
137 "findAll", new String[0]);
138 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
139 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
140 "countAll", new String[0]);
141
142 public void cacheResult(MBCategory mbCategory) {
143 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
144 MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory);
145
146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
147 new Object[] { mbCategory.getUuid(), new Long(
148 mbCategory.getGroupId()) }, mbCategory);
149 }
150
151 public void cacheResult(List<MBCategory> mbCategories) {
152 for (MBCategory mbCategory : mbCategories) {
153 if (EntityCacheUtil.getResult(
154 MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
155 MBCategoryImpl.class, mbCategory.getPrimaryKey(), this) == null) {
156 cacheResult(mbCategory);
157 }
158 }
159 }
160
161 public void clearCache() {
162 CacheRegistry.clear(MBCategoryImpl.class.getName());
163 EntityCacheUtil.clearCache(MBCategoryImpl.class.getName());
164 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
165 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
166 }
167
168 public MBCategory create(long categoryId) {
169 MBCategory mbCategory = new MBCategoryImpl();
170
171 mbCategory.setNew(true);
172 mbCategory.setPrimaryKey(categoryId);
173
174 String uuid = PortalUUIDUtil.generate();
175
176 mbCategory.setUuid(uuid);
177
178 return mbCategory;
179 }
180
181 public MBCategory remove(long categoryId)
182 throws NoSuchCategoryException, SystemException {
183 Session session = null;
184
185 try {
186 session = openSession();
187
188 MBCategory mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
189 new Long(categoryId));
190
191 if (mbCategory == null) {
192 if (_log.isWarnEnabled()) {
193 _log.warn("No MBCategory exists with the primary key " +
194 categoryId);
195 }
196
197 throw new NoSuchCategoryException(
198 "No MBCategory exists with the primary key " + categoryId);
199 }
200
201 return remove(mbCategory);
202 }
203 catch (NoSuchCategoryException nsee) {
204 throw nsee;
205 }
206 catch (Exception e) {
207 throw processException(e);
208 }
209 finally {
210 closeSession(session);
211 }
212 }
213
214 public MBCategory remove(MBCategory mbCategory) throws SystemException {
215 for (ModelListener<MBCategory> listener : listeners) {
216 listener.onBeforeRemove(mbCategory);
217 }
218
219 mbCategory = removeImpl(mbCategory);
220
221 for (ModelListener<MBCategory> listener : listeners) {
222 listener.onAfterRemove(mbCategory);
223 }
224
225 return mbCategory;
226 }
227
228 protected MBCategory removeImpl(MBCategory mbCategory)
229 throws SystemException {
230 Session session = null;
231
232 try {
233 session = openSession();
234
235 if (mbCategory.isCachedModel() || BatchSessionUtil.isEnabled()) {
236 Object staleObject = session.get(MBCategoryImpl.class,
237 mbCategory.getPrimaryKeyObj());
238
239 if (staleObject != null) {
240 session.evict(staleObject);
241 }
242 }
243
244 session.delete(mbCategory);
245
246 session.flush();
247 }
248 catch (Exception e) {
249 throw processException(e);
250 }
251 finally {
252 closeSession(session);
253 }
254
255 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
256
257 MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory;
258
259 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
260 new Object[] {
261 mbCategoryModelImpl.getOriginalUuid(),
262 new Long(mbCategoryModelImpl.getOriginalGroupId())
263 });
264
265 EntityCacheUtil.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
266 MBCategoryImpl.class, mbCategory.getPrimaryKey());
267
268 return mbCategory;
269 }
270
271
274 public MBCategory update(MBCategory mbCategory) throws SystemException {
275 if (_log.isWarnEnabled()) {
276 _log.warn(
277 "Using the deprecated update(MBCategory mbCategory) method. Use update(MBCategory mbCategory, boolean merge) instead.");
278 }
279
280 return update(mbCategory, false);
281 }
282
283
296 public MBCategory update(MBCategory mbCategory, boolean merge)
297 throws SystemException {
298 boolean isNew = mbCategory.isNew();
299
300 for (ModelListener<MBCategory> listener : listeners) {
301 if (isNew) {
302 listener.onBeforeCreate(mbCategory);
303 }
304 else {
305 listener.onBeforeUpdate(mbCategory);
306 }
307 }
308
309 mbCategory = updateImpl(mbCategory, merge);
310
311 for (ModelListener<MBCategory> listener : listeners) {
312 if (isNew) {
313 listener.onAfterCreate(mbCategory);
314 }
315 else {
316 listener.onAfterUpdate(mbCategory);
317 }
318 }
319
320 return mbCategory;
321 }
322
323 public MBCategory updateImpl(
324 com.liferay.portlet.messageboards.model.MBCategory mbCategory,
325 boolean merge) throws SystemException {
326 boolean isNew = mbCategory.isNew();
327
328 MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory;
329
330 if (Validator.isNull(mbCategory.getUuid())) {
331 String uuid = PortalUUIDUtil.generate();
332
333 mbCategory.setUuid(uuid);
334 }
335
336 Session session = null;
337
338 try {
339 session = openSession();
340
341 BatchSessionUtil.update(session, mbCategory, merge);
342
343 mbCategory.setNew(false);
344 }
345 catch (Exception e) {
346 throw processException(e);
347 }
348 finally {
349 closeSession(session);
350 }
351
352 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
353
354 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
355 MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory);
356
357 if (!isNew &&
358 (!mbCategory.getUuid()
359 .equals(mbCategoryModelImpl.getOriginalUuid()) ||
360 (mbCategory.getGroupId() != mbCategoryModelImpl.getOriginalGroupId()))) {
361 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
362 new Object[] {
363 mbCategoryModelImpl.getOriginalUuid(),
364 new Long(mbCategoryModelImpl.getOriginalGroupId())
365 });
366 }
367
368 if (isNew ||
369 (!mbCategory.getUuid()
370 .equals(mbCategoryModelImpl.getOriginalUuid()) ||
371 (mbCategory.getGroupId() != mbCategoryModelImpl.getOriginalGroupId()))) {
372 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
373 new Object[] {
374 mbCategory.getUuid(), new Long(mbCategory.getGroupId())
375 }, mbCategory);
376 }
377
378 return mbCategory;
379 }
380
381 public MBCategory findByPrimaryKey(long categoryId)
382 throws NoSuchCategoryException, SystemException {
383 MBCategory mbCategory = fetchByPrimaryKey(categoryId);
384
385 if (mbCategory == null) {
386 if (_log.isWarnEnabled()) {
387 _log.warn("No MBCategory exists with the primary key " +
388 categoryId);
389 }
390
391 throw new NoSuchCategoryException(
392 "No MBCategory exists with the primary key " + categoryId);
393 }
394
395 return mbCategory;
396 }
397
398 public MBCategory fetchByPrimaryKey(long categoryId)
399 throws SystemException {
400 MBCategory mbCategory = (MBCategory)EntityCacheUtil.getResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
401 MBCategoryImpl.class, categoryId, this);
402
403 if (mbCategory == null) {
404 Session session = null;
405
406 try {
407 session = openSession();
408
409 mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
410 new Long(categoryId));
411 }
412 catch (Exception e) {
413 throw processException(e);
414 }
415 finally {
416 if (mbCategory != null) {
417 cacheResult(mbCategory);
418 }
419
420 closeSession(session);
421 }
422 }
423
424 return mbCategory;
425 }
426
427 public List<MBCategory> findByUuid(String uuid) throws SystemException {
428 Object[] finderArgs = new Object[] { uuid };
429
430 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
431 finderArgs, this);
432
433 if (list == null) {
434 Session session = null;
435
436 try {
437 session = openSession();
438
439 StringBuilder query = new StringBuilder();
440
441 query.append(
442 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
443
444 if (uuid == null) {
445 query.append("uuid_ IS NULL");
446 }
447 else {
448 query.append("uuid_ = ?");
449 }
450
451 query.append(" ");
452
453 query.append("ORDER BY ");
454
455 query.append("parentCategoryId ASC, ");
456 query.append("name ASC");
457
458 Query q = session.createQuery(query.toString());
459
460 QueryPos qPos = QueryPos.getInstance(q);
461
462 if (uuid != null) {
463 qPos.add(uuid);
464 }
465
466 list = q.list();
467 }
468 catch (Exception e) {
469 throw processException(e);
470 }
471 finally {
472 if (list == null) {
473 list = new ArrayList<MBCategory>();
474 }
475
476 cacheResult(list);
477
478 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
479 list);
480
481 closeSession(session);
482 }
483 }
484
485 return list;
486 }
487
488 public List<MBCategory> findByUuid(String uuid, int start, int end)
489 throws SystemException {
490 return findByUuid(uuid, start, end, null);
491 }
492
493 public List<MBCategory> findByUuid(String uuid, int start, int end,
494 OrderByComparator obc) throws SystemException {
495 Object[] finderArgs = new Object[] {
496 uuid,
497
498 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
499 };
500
501 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
502 finderArgs, this);
503
504 if (list == null) {
505 Session session = null;
506
507 try {
508 session = openSession();
509
510 StringBuilder query = new StringBuilder();
511
512 query.append(
513 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
514
515 if (uuid == null) {
516 query.append("uuid_ IS NULL");
517 }
518 else {
519 query.append("uuid_ = ?");
520 }
521
522 query.append(" ");
523
524 if (obc != null) {
525 query.append("ORDER BY ");
526 query.append(obc.getOrderBy());
527 }
528
529 else {
530 query.append("ORDER BY ");
531
532 query.append("parentCategoryId ASC, ");
533 query.append("name ASC");
534 }
535
536 Query q = session.createQuery(query.toString());
537
538 QueryPos qPos = QueryPos.getInstance(q);
539
540 if (uuid != null) {
541 qPos.add(uuid);
542 }
543
544 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
545 end);
546 }
547 catch (Exception e) {
548 throw processException(e);
549 }
550 finally {
551 if (list == null) {
552 list = new ArrayList<MBCategory>();
553 }
554
555 cacheResult(list);
556
557 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
558 finderArgs, list);
559
560 closeSession(session);
561 }
562 }
563
564 return list;
565 }
566
567 public MBCategory findByUuid_First(String uuid, OrderByComparator obc)
568 throws NoSuchCategoryException, SystemException {
569 List<MBCategory> list = findByUuid(uuid, 0, 1, obc);
570
571 if (list.isEmpty()) {
572 StringBuilder msg = new StringBuilder();
573
574 msg.append("No MBCategory exists with the key {");
575
576 msg.append("uuid=" + uuid);
577
578 msg.append(StringPool.CLOSE_CURLY_BRACE);
579
580 throw new NoSuchCategoryException(msg.toString());
581 }
582 else {
583 return list.get(0);
584 }
585 }
586
587 public MBCategory findByUuid_Last(String uuid, OrderByComparator obc)
588 throws NoSuchCategoryException, SystemException {
589 int count = countByUuid(uuid);
590
591 List<MBCategory> list = findByUuid(uuid, count - 1, count, obc);
592
593 if (list.isEmpty()) {
594 StringBuilder msg = new StringBuilder();
595
596 msg.append("No MBCategory exists with the key {");
597
598 msg.append("uuid=" + uuid);
599
600 msg.append(StringPool.CLOSE_CURLY_BRACE);
601
602 throw new NoSuchCategoryException(msg.toString());
603 }
604 else {
605 return list.get(0);
606 }
607 }
608
609 public MBCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
610 OrderByComparator obc) throws NoSuchCategoryException, SystemException {
611 MBCategory mbCategory = findByPrimaryKey(categoryId);
612
613 int count = countByUuid(uuid);
614
615 Session session = null;
616
617 try {
618 session = openSession();
619
620 StringBuilder query = new StringBuilder();
621
622 query.append(
623 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
624
625 if (uuid == null) {
626 query.append("uuid_ IS NULL");
627 }
628 else {
629 query.append("uuid_ = ?");
630 }
631
632 query.append(" ");
633
634 if (obc != null) {
635 query.append("ORDER BY ");
636 query.append(obc.getOrderBy());
637 }
638
639 else {
640 query.append("ORDER BY ");
641
642 query.append("parentCategoryId ASC, ");
643 query.append("name ASC");
644 }
645
646 Query q = session.createQuery(query.toString());
647
648 QueryPos qPos = QueryPos.getInstance(q);
649
650 if (uuid != null) {
651 qPos.add(uuid);
652 }
653
654 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
655 mbCategory);
656
657 MBCategory[] array = new MBCategoryImpl[3];
658
659 array[0] = (MBCategory)objArray[0];
660 array[1] = (MBCategory)objArray[1];
661 array[2] = (MBCategory)objArray[2];
662
663 return array;
664 }
665 catch (Exception e) {
666 throw processException(e);
667 }
668 finally {
669 closeSession(session);
670 }
671 }
672
673 public MBCategory findByUUID_G(String uuid, long groupId)
674 throws NoSuchCategoryException, SystemException {
675 MBCategory mbCategory = fetchByUUID_G(uuid, groupId);
676
677 if (mbCategory == null) {
678 StringBuilder msg = new StringBuilder();
679
680 msg.append("No MBCategory exists with the key {");
681
682 msg.append("uuid=" + uuid);
683
684 msg.append(", ");
685 msg.append("groupId=" + groupId);
686
687 msg.append(StringPool.CLOSE_CURLY_BRACE);
688
689 if (_log.isWarnEnabled()) {
690 _log.warn(msg.toString());
691 }
692
693 throw new NoSuchCategoryException(msg.toString());
694 }
695
696 return mbCategory;
697 }
698
699 public MBCategory fetchByUUID_G(String uuid, long groupId)
700 throws SystemException {
701 return fetchByUUID_G(uuid, groupId, true);
702 }
703
704 public MBCategory fetchByUUID_G(String uuid, long groupId,
705 boolean retrieveFromCache) throws SystemException {
706 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
707
708 Object result = null;
709
710 if (retrieveFromCache) {
711 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
712 finderArgs, this);
713 }
714
715 if (result == null) {
716 Session session = null;
717
718 try {
719 session = openSession();
720
721 StringBuilder query = new StringBuilder();
722
723 query.append(
724 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
725
726 if (uuid == null) {
727 query.append("uuid_ IS NULL");
728 }
729 else {
730 query.append("uuid_ = ?");
731 }
732
733 query.append(" AND ");
734
735 query.append("groupId = ?");
736
737 query.append(" ");
738
739 query.append("ORDER BY ");
740
741 query.append("parentCategoryId ASC, ");
742 query.append("name ASC");
743
744 Query q = session.createQuery(query.toString());
745
746 QueryPos qPos = QueryPos.getInstance(q);
747
748 if (uuid != null) {
749 qPos.add(uuid);
750 }
751
752 qPos.add(groupId);
753
754 List<MBCategory> list = q.list();
755
756 result = list;
757
758 MBCategory mbCategory = null;
759
760 if (list.isEmpty()) {
761 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
762 finderArgs, list);
763 }
764 else {
765 mbCategory = list.get(0);
766
767 cacheResult(mbCategory);
768
769 if ((mbCategory.getUuid() == null) ||
770 !mbCategory.getUuid().equals(uuid) ||
771 (mbCategory.getGroupId() != groupId)) {
772 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
773 finderArgs, list);
774 }
775 }
776
777 return mbCategory;
778 }
779 catch (Exception e) {
780 throw processException(e);
781 }
782 finally {
783 if (result == null) {
784 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
785 finderArgs, new ArrayList<MBCategory>());
786 }
787
788 closeSession(session);
789 }
790 }
791 else {
792 if (result instanceof List) {
793 return null;
794 }
795 else {
796 return (MBCategory)result;
797 }
798 }
799 }
800
801 public List<MBCategory> findByGroupId(long groupId)
802 throws SystemException {
803 Object[] finderArgs = new Object[] { new Long(groupId) };
804
805 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
806 finderArgs, this);
807
808 if (list == null) {
809 Session session = null;
810
811 try {
812 session = openSession();
813
814 StringBuilder query = new StringBuilder();
815
816 query.append(
817 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
818
819 query.append("groupId = ?");
820
821 query.append(" ");
822
823 query.append("ORDER BY ");
824
825 query.append("parentCategoryId ASC, ");
826 query.append("name ASC");
827
828 Query q = session.createQuery(query.toString());
829
830 QueryPos qPos = QueryPos.getInstance(q);
831
832 qPos.add(groupId);
833
834 list = q.list();
835 }
836 catch (Exception e) {
837 throw processException(e);
838 }
839 finally {
840 if (list == null) {
841 list = new ArrayList<MBCategory>();
842 }
843
844 cacheResult(list);
845
846 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
847 finderArgs, list);
848
849 closeSession(session);
850 }
851 }
852
853 return list;
854 }
855
856 public List<MBCategory> findByGroupId(long groupId, int start, int end)
857 throws SystemException {
858 return findByGroupId(groupId, start, end, null);
859 }
860
861 public List<MBCategory> findByGroupId(long groupId, int start, int end,
862 OrderByComparator obc) throws SystemException {
863 Object[] finderArgs = new Object[] {
864 new Long(groupId),
865
866 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
867 };
868
869 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
870 finderArgs, this);
871
872 if (list == null) {
873 Session session = null;
874
875 try {
876 session = openSession();
877
878 StringBuilder query = new StringBuilder();
879
880 query.append(
881 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
882
883 query.append("groupId = ?");
884
885 query.append(" ");
886
887 if (obc != null) {
888 query.append("ORDER BY ");
889 query.append(obc.getOrderBy());
890 }
891
892 else {
893 query.append("ORDER BY ");
894
895 query.append("parentCategoryId ASC, ");
896 query.append("name ASC");
897 }
898
899 Query q = session.createQuery(query.toString());
900
901 QueryPos qPos = QueryPos.getInstance(q);
902
903 qPos.add(groupId);
904
905 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
906 end);
907 }
908 catch (Exception e) {
909 throw processException(e);
910 }
911 finally {
912 if (list == null) {
913 list = new ArrayList<MBCategory>();
914 }
915
916 cacheResult(list);
917
918 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
919 finderArgs, list);
920
921 closeSession(session);
922 }
923 }
924
925 return list;
926 }
927
928 public MBCategory findByGroupId_First(long groupId, OrderByComparator obc)
929 throws NoSuchCategoryException, SystemException {
930 List<MBCategory> list = findByGroupId(groupId, 0, 1, obc);
931
932 if (list.isEmpty()) {
933 StringBuilder msg = new StringBuilder();
934
935 msg.append("No MBCategory exists with the key {");
936
937 msg.append("groupId=" + groupId);
938
939 msg.append(StringPool.CLOSE_CURLY_BRACE);
940
941 throw new NoSuchCategoryException(msg.toString());
942 }
943 else {
944 return list.get(0);
945 }
946 }
947
948 public MBCategory findByGroupId_Last(long groupId, OrderByComparator obc)
949 throws NoSuchCategoryException, SystemException {
950 int count = countByGroupId(groupId);
951
952 List<MBCategory> list = findByGroupId(groupId, count - 1, count, obc);
953
954 if (list.isEmpty()) {
955 StringBuilder msg = new StringBuilder();
956
957 msg.append("No MBCategory exists with the key {");
958
959 msg.append("groupId=" + groupId);
960
961 msg.append(StringPool.CLOSE_CURLY_BRACE);
962
963 throw new NoSuchCategoryException(msg.toString());
964 }
965 else {
966 return list.get(0);
967 }
968 }
969
970 public MBCategory[] findByGroupId_PrevAndNext(long categoryId,
971 long groupId, OrderByComparator obc)
972 throws NoSuchCategoryException, SystemException {
973 MBCategory mbCategory = findByPrimaryKey(categoryId);
974
975 int count = countByGroupId(groupId);
976
977 Session session = null;
978
979 try {
980 session = openSession();
981
982 StringBuilder query = new StringBuilder();
983
984 query.append(
985 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
986
987 query.append("groupId = ?");
988
989 query.append(" ");
990
991 if (obc != null) {
992 query.append("ORDER BY ");
993 query.append(obc.getOrderBy());
994 }
995
996 else {
997 query.append("ORDER BY ");
998
999 query.append("parentCategoryId ASC, ");
1000 query.append("name ASC");
1001 }
1002
1003 Query q = session.createQuery(query.toString());
1004
1005 QueryPos qPos = QueryPos.getInstance(q);
1006
1007 qPos.add(groupId);
1008
1009 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1010 mbCategory);
1011
1012 MBCategory[] array = new MBCategoryImpl[3];
1013
1014 array[0] = (MBCategory)objArray[0];
1015 array[1] = (MBCategory)objArray[1];
1016 array[2] = (MBCategory)objArray[2];
1017
1018 return array;
1019 }
1020 catch (Exception e) {
1021 throw processException(e);
1022 }
1023 finally {
1024 closeSession(session);
1025 }
1026 }
1027
1028 public List<MBCategory> findByCompanyId(long companyId)
1029 throws SystemException {
1030 Object[] finderArgs = new Object[] { new Long(companyId) };
1031
1032 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1033 finderArgs, this);
1034
1035 if (list == null) {
1036 Session session = null;
1037
1038 try {
1039 session = openSession();
1040
1041 StringBuilder query = new StringBuilder();
1042
1043 query.append(
1044 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1045
1046 query.append("companyId = ?");
1047
1048 query.append(" ");
1049
1050 query.append("ORDER BY ");
1051
1052 query.append("parentCategoryId ASC, ");
1053 query.append("name ASC");
1054
1055 Query q = session.createQuery(query.toString());
1056
1057 QueryPos qPos = QueryPos.getInstance(q);
1058
1059 qPos.add(companyId);
1060
1061 list = q.list();
1062 }
1063 catch (Exception e) {
1064 throw processException(e);
1065 }
1066 finally {
1067 if (list == null) {
1068 list = new ArrayList<MBCategory>();
1069 }
1070
1071 cacheResult(list);
1072
1073 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1074 finderArgs, list);
1075
1076 closeSession(session);
1077 }
1078 }
1079
1080 return list;
1081 }
1082
1083 public List<MBCategory> findByCompanyId(long companyId, int start, int end)
1084 throws SystemException {
1085 return findByCompanyId(companyId, start, end, null);
1086 }
1087
1088 public List<MBCategory> findByCompanyId(long companyId, int start, int end,
1089 OrderByComparator obc) throws SystemException {
1090 Object[] finderArgs = new Object[] {
1091 new Long(companyId),
1092
1093 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1094 };
1095
1096 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1097 finderArgs, this);
1098
1099 if (list == null) {
1100 Session session = null;
1101
1102 try {
1103 session = openSession();
1104
1105 StringBuilder query = new StringBuilder();
1106
1107 query.append(
1108 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1109
1110 query.append("companyId = ?");
1111
1112 query.append(" ");
1113
1114 if (obc != null) {
1115 query.append("ORDER BY ");
1116 query.append(obc.getOrderBy());
1117 }
1118
1119 else {
1120 query.append("ORDER BY ");
1121
1122 query.append("parentCategoryId ASC, ");
1123 query.append("name ASC");
1124 }
1125
1126 Query q = session.createQuery(query.toString());
1127
1128 QueryPos qPos = QueryPos.getInstance(q);
1129
1130 qPos.add(companyId);
1131
1132 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
1133 end);
1134 }
1135 catch (Exception e) {
1136 throw processException(e);
1137 }
1138 finally {
1139 if (list == null) {
1140 list = new ArrayList<MBCategory>();
1141 }
1142
1143 cacheResult(list);
1144
1145 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1146 finderArgs, list);
1147
1148 closeSession(session);
1149 }
1150 }
1151
1152 return list;
1153 }
1154
1155 public MBCategory findByCompanyId_First(long companyId,
1156 OrderByComparator obc) throws NoSuchCategoryException, SystemException {
1157 List<MBCategory> list = findByCompanyId(companyId, 0, 1, obc);
1158
1159 if (list.isEmpty()) {
1160 StringBuilder msg = new StringBuilder();
1161
1162 msg.append("No MBCategory exists with the key {");
1163
1164 msg.append("companyId=" + companyId);
1165
1166 msg.append(StringPool.CLOSE_CURLY_BRACE);
1167
1168 throw new NoSuchCategoryException(msg.toString());
1169 }
1170 else {
1171 return list.get(0);
1172 }
1173 }
1174
1175 public MBCategory findByCompanyId_Last(long companyId, OrderByComparator obc)
1176 throws NoSuchCategoryException, SystemException {
1177 int count = countByCompanyId(companyId);
1178
1179 List<MBCategory> list = findByCompanyId(companyId, count - 1, count, obc);
1180
1181 if (list.isEmpty()) {
1182 StringBuilder msg = new StringBuilder();
1183
1184 msg.append("No MBCategory exists with the key {");
1185
1186 msg.append("companyId=" + companyId);
1187
1188 msg.append(StringPool.CLOSE_CURLY_BRACE);
1189
1190 throw new NoSuchCategoryException(msg.toString());
1191 }
1192 else {
1193 return list.get(0);
1194 }
1195 }
1196
1197 public MBCategory[] findByCompanyId_PrevAndNext(long categoryId,
1198 long companyId, OrderByComparator obc)
1199 throws NoSuchCategoryException, SystemException {
1200 MBCategory mbCategory = findByPrimaryKey(categoryId);
1201
1202 int count = countByCompanyId(companyId);
1203
1204 Session session = null;
1205
1206 try {
1207 session = openSession();
1208
1209 StringBuilder query = new StringBuilder();
1210
1211 query.append(
1212 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1213
1214 query.append("companyId = ?");
1215
1216 query.append(" ");
1217
1218 if (obc != null) {
1219 query.append("ORDER BY ");
1220 query.append(obc.getOrderBy());
1221 }
1222
1223 else {
1224 query.append("ORDER BY ");
1225
1226 query.append("parentCategoryId ASC, ");
1227 query.append("name ASC");
1228 }
1229
1230 Query q = session.createQuery(query.toString());
1231
1232 QueryPos qPos = QueryPos.getInstance(q);
1233
1234 qPos.add(companyId);
1235
1236 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1237 mbCategory);
1238
1239 MBCategory[] array = new MBCategoryImpl[3];
1240
1241 array[0] = (MBCategory)objArray[0];
1242 array[1] = (MBCategory)objArray[1];
1243 array[2] = (MBCategory)objArray[2];
1244
1245 return array;
1246 }
1247 catch (Exception e) {
1248 throw processException(e);
1249 }
1250 finally {
1251 closeSession(session);
1252 }
1253 }
1254
1255 public List<MBCategory> findByG_P(long groupId, long parentCategoryId)
1256 throws SystemException {
1257 Object[] finderArgs = new Object[] {
1258 new Long(groupId), new Long(parentCategoryId)
1259 };
1260
1261 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
1262 finderArgs, this);
1263
1264 if (list == null) {
1265 Session session = null;
1266
1267 try {
1268 session = openSession();
1269
1270 StringBuilder query = new StringBuilder();
1271
1272 query.append(
1273 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1274
1275 query.append("groupId = ?");
1276
1277 query.append(" AND ");
1278
1279 query.append("parentCategoryId = ?");
1280
1281 query.append(" ");
1282
1283 query.append("ORDER BY ");
1284
1285 query.append("parentCategoryId ASC, ");
1286 query.append("name ASC");
1287
1288 Query q = session.createQuery(query.toString());
1289
1290 QueryPos qPos = QueryPos.getInstance(q);
1291
1292 qPos.add(groupId);
1293
1294 qPos.add(parentCategoryId);
1295
1296 list = q.list();
1297 }
1298 catch (Exception e) {
1299 throw processException(e);
1300 }
1301 finally {
1302 if (list == null) {
1303 list = new ArrayList<MBCategory>();
1304 }
1305
1306 cacheResult(list);
1307
1308 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
1309 list);
1310
1311 closeSession(session);
1312 }
1313 }
1314
1315 return list;
1316 }
1317
1318 public List<MBCategory> findByG_P(long groupId, long parentCategoryId,
1319 int start, int end) throws SystemException {
1320 return findByG_P(groupId, parentCategoryId, start, end, null);
1321 }
1322
1323 public List<MBCategory> findByG_P(long groupId, long parentCategoryId,
1324 int start, int end, OrderByComparator obc) throws SystemException {
1325 Object[] finderArgs = new Object[] {
1326 new Long(groupId), new Long(parentCategoryId),
1327
1328 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1329 };
1330
1331 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P,
1332 finderArgs, this);
1333
1334 if (list == null) {
1335 Session session = null;
1336
1337 try {
1338 session = openSession();
1339
1340 StringBuilder query = new StringBuilder();
1341
1342 query.append(
1343 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1344
1345 query.append("groupId = ?");
1346
1347 query.append(" AND ");
1348
1349 query.append("parentCategoryId = ?");
1350
1351 query.append(" ");
1352
1353 if (obc != null) {
1354 query.append("ORDER BY ");
1355 query.append(obc.getOrderBy());
1356 }
1357
1358 else {
1359 query.append("ORDER BY ");
1360
1361 query.append("parentCategoryId ASC, ");
1362 query.append("name ASC");
1363 }
1364
1365 Query q = session.createQuery(query.toString());
1366
1367 QueryPos qPos = QueryPos.getInstance(q);
1368
1369 qPos.add(groupId);
1370
1371 qPos.add(parentCategoryId);
1372
1373 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
1374 end);
1375 }
1376 catch (Exception e) {
1377 throw processException(e);
1378 }
1379 finally {
1380 if (list == null) {
1381 list = new ArrayList<MBCategory>();
1382 }
1383
1384 cacheResult(list);
1385
1386 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P,
1387 finderArgs, list);
1388
1389 closeSession(session);
1390 }
1391 }
1392
1393 return list;
1394 }
1395
1396 public MBCategory findByG_P_First(long groupId, long parentCategoryId,
1397 OrderByComparator obc) throws NoSuchCategoryException, SystemException {
1398 List<MBCategory> list = findByG_P(groupId, parentCategoryId, 0, 1, obc);
1399
1400 if (list.isEmpty()) {
1401 StringBuilder msg = new StringBuilder();
1402
1403 msg.append("No MBCategory exists with the key {");
1404
1405 msg.append("groupId=" + groupId);
1406
1407 msg.append(", ");
1408 msg.append("parentCategoryId=" + parentCategoryId);
1409
1410 msg.append(StringPool.CLOSE_CURLY_BRACE);
1411
1412 throw new NoSuchCategoryException(msg.toString());
1413 }
1414 else {
1415 return list.get(0);
1416 }
1417 }
1418
1419 public MBCategory findByG_P_Last(long groupId, long parentCategoryId,
1420 OrderByComparator obc) throws NoSuchCategoryException, SystemException {
1421 int count = countByG_P(groupId, parentCategoryId);
1422
1423 List<MBCategory> list = findByG_P(groupId, parentCategoryId, count - 1,
1424 count, obc);
1425
1426 if (list.isEmpty()) {
1427 StringBuilder msg = new StringBuilder();
1428
1429 msg.append("No MBCategory exists with the key {");
1430
1431 msg.append("groupId=" + groupId);
1432
1433 msg.append(", ");
1434 msg.append("parentCategoryId=" + parentCategoryId);
1435
1436 msg.append(StringPool.CLOSE_CURLY_BRACE);
1437
1438 throw new NoSuchCategoryException(msg.toString());
1439 }
1440 else {
1441 return list.get(0);
1442 }
1443 }
1444
1445 public MBCategory[] findByG_P_PrevAndNext(long categoryId, long groupId,
1446 long parentCategoryId, OrderByComparator obc)
1447 throws NoSuchCategoryException, SystemException {
1448 MBCategory mbCategory = findByPrimaryKey(categoryId);
1449
1450 int count = countByG_P(groupId, parentCategoryId);
1451
1452 Session session = null;
1453
1454 try {
1455 session = openSession();
1456
1457 StringBuilder query = new StringBuilder();
1458
1459 query.append(
1460 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1461
1462 query.append("groupId = ?");
1463
1464 query.append(" AND ");
1465
1466 query.append("parentCategoryId = ?");
1467
1468 query.append(" ");
1469
1470 if (obc != null) {
1471 query.append("ORDER BY ");
1472 query.append(obc.getOrderBy());
1473 }
1474
1475 else {
1476 query.append("ORDER BY ");
1477
1478 query.append("parentCategoryId ASC, ");
1479 query.append("name ASC");
1480 }
1481
1482 Query q = session.createQuery(query.toString());
1483
1484 QueryPos qPos = QueryPos.getInstance(q);
1485
1486 qPos.add(groupId);
1487
1488 qPos.add(parentCategoryId);
1489
1490 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1491 mbCategory);
1492
1493 MBCategory[] array = new MBCategoryImpl[3];
1494
1495 array[0] = (MBCategory)objArray[0];
1496 array[1] = (MBCategory)objArray[1];
1497 array[2] = (MBCategory)objArray[2];
1498
1499 return array;
1500 }
1501 catch (Exception e) {
1502 throw processException(e);
1503 }
1504 finally {
1505 closeSession(session);
1506 }
1507 }
1508
1509 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1510 throws SystemException {
1511 Session session = null;
1512
1513 try {
1514 session = openSession();
1515
1516 dynamicQuery.compile(session);
1517
1518 return dynamicQuery.list();
1519 }
1520 catch (Exception e) {
1521 throw processException(e);
1522 }
1523 finally {
1524 closeSession(session);
1525 }
1526 }
1527
1528 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1529 int start, int end) throws SystemException {
1530 Session session = null;
1531
1532 try {
1533 session = openSession();
1534
1535 dynamicQuery.setLimit(start, end);
1536
1537 dynamicQuery.compile(session);
1538
1539 return dynamicQuery.list();
1540 }
1541 catch (Exception e) {
1542 throw processException(e);
1543 }
1544 finally {
1545 closeSession(session);
1546 }
1547 }
1548
1549 public List<MBCategory> findAll() throws SystemException {
1550 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1551 }
1552
1553 public List<MBCategory> findAll(int start, int end)
1554 throws SystemException {
1555 return findAll(start, end, null);
1556 }
1557
1558 public List<MBCategory> findAll(int start, int end, OrderByComparator obc)
1559 throws SystemException {
1560 Object[] finderArgs = new Object[] {
1561 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1562 };
1563
1564 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1565 finderArgs, this);
1566
1567 if (list == null) {
1568 Session session = null;
1569
1570 try {
1571 session = openSession();
1572
1573 StringBuilder query = new StringBuilder();
1574
1575 query.append(
1576 "FROM com.liferay.portlet.messageboards.model.MBCategory ");
1577
1578 if (obc != null) {
1579 query.append("ORDER BY ");
1580 query.append(obc.getOrderBy());
1581 }
1582
1583 else {
1584 query.append("ORDER BY ");
1585
1586 query.append("parentCategoryId ASC, ");
1587 query.append("name ASC");
1588 }
1589
1590 Query q = session.createQuery(query.toString());
1591
1592 if (obc == null) {
1593 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
1594 start, end, false);
1595
1596 Collections.sort(list);
1597 }
1598 else {
1599 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
1600 start, end);
1601 }
1602 }
1603 catch (Exception e) {
1604 throw processException(e);
1605 }
1606 finally {
1607 if (list == null) {
1608 list = new ArrayList<MBCategory>();
1609 }
1610
1611 cacheResult(list);
1612
1613 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1614
1615 closeSession(session);
1616 }
1617 }
1618
1619 return list;
1620 }
1621
1622 public void removeByUuid(String uuid) throws SystemException {
1623 for (MBCategory mbCategory : findByUuid(uuid)) {
1624 remove(mbCategory);
1625 }
1626 }
1627
1628 public void removeByUUID_G(String uuid, long groupId)
1629 throws NoSuchCategoryException, SystemException {
1630 MBCategory mbCategory = findByUUID_G(uuid, groupId);
1631
1632 remove(mbCategory);
1633 }
1634
1635 public void removeByGroupId(long groupId) throws SystemException {
1636 for (MBCategory mbCategory : findByGroupId(groupId)) {
1637 remove(mbCategory);
1638 }
1639 }
1640
1641 public void removeByCompanyId(long companyId) throws SystemException {
1642 for (MBCategory mbCategory : findByCompanyId(companyId)) {
1643 remove(mbCategory);
1644 }
1645 }
1646
1647 public void removeByG_P(long groupId, long parentCategoryId)
1648 throws SystemException {
1649 for (MBCategory mbCategory : findByG_P(groupId, parentCategoryId)) {
1650 remove(mbCategory);
1651 }
1652 }
1653
1654 public void removeAll() throws SystemException {
1655 for (MBCategory mbCategory : findAll()) {
1656 remove(mbCategory);
1657 }
1658 }
1659
1660 public int countByUuid(String uuid) throws SystemException {
1661 Object[] finderArgs = new Object[] { uuid };
1662
1663 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1664 finderArgs, this);
1665
1666 if (count == null) {
1667 Session session = null;
1668
1669 try {
1670 session = openSession();
1671
1672 StringBuilder query = new StringBuilder();
1673
1674 query.append("SELECT COUNT(*) ");
1675 query.append(
1676 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1677
1678 if (uuid == null) {
1679 query.append("uuid_ IS NULL");
1680 }
1681 else {
1682 query.append("uuid_ = ?");
1683 }
1684
1685 query.append(" ");
1686
1687 Query q = session.createQuery(query.toString());
1688
1689 QueryPos qPos = QueryPos.getInstance(q);
1690
1691 if (uuid != null) {
1692 qPos.add(uuid);
1693 }
1694
1695 count = (Long)q.uniqueResult();
1696 }
1697 catch (Exception e) {
1698 throw processException(e);
1699 }
1700 finally {
1701 if (count == null) {
1702 count = Long.valueOf(0);
1703 }
1704
1705 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1706 finderArgs, count);
1707
1708 closeSession(session);
1709 }
1710 }
1711
1712 return count.intValue();
1713 }
1714
1715 public int countByUUID_G(String uuid, long groupId)
1716 throws SystemException {
1717 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1718
1719 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1720 finderArgs, this);
1721
1722 if (count == null) {
1723 Session session = null;
1724
1725 try {
1726 session = openSession();
1727
1728 StringBuilder query = new StringBuilder();
1729
1730 query.append("SELECT COUNT(*) ");
1731 query.append(
1732 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1733
1734 if (uuid == null) {
1735 query.append("uuid_ IS NULL");
1736 }
1737 else {
1738 query.append("uuid_ = ?");
1739 }
1740
1741 query.append(" AND ");
1742
1743 query.append("groupId = ?");
1744
1745 query.append(" ");
1746
1747 Query q = session.createQuery(query.toString());
1748
1749 QueryPos qPos = QueryPos.getInstance(q);
1750
1751 if (uuid != null) {
1752 qPos.add(uuid);
1753 }
1754
1755 qPos.add(groupId);
1756
1757 count = (Long)q.uniqueResult();
1758 }
1759 catch (Exception e) {
1760 throw processException(e);
1761 }
1762 finally {
1763 if (count == null) {
1764 count = Long.valueOf(0);
1765 }
1766
1767 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1768 finderArgs, count);
1769
1770 closeSession(session);
1771 }
1772 }
1773
1774 return count.intValue();
1775 }
1776
1777 public int countByGroupId(long groupId) throws SystemException {
1778 Object[] finderArgs = new Object[] { new Long(groupId) };
1779
1780 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1781 finderArgs, this);
1782
1783 if (count == null) {
1784 Session session = null;
1785
1786 try {
1787 session = openSession();
1788
1789 StringBuilder query = new StringBuilder();
1790
1791 query.append("SELECT COUNT(*) ");
1792 query.append(
1793 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1794
1795 query.append("groupId = ?");
1796
1797 query.append(" ");
1798
1799 Query q = session.createQuery(query.toString());
1800
1801 QueryPos qPos = QueryPos.getInstance(q);
1802
1803 qPos.add(groupId);
1804
1805 count = (Long)q.uniqueResult();
1806 }
1807 catch (Exception e) {
1808 throw processException(e);
1809 }
1810 finally {
1811 if (count == null) {
1812 count = Long.valueOf(0);
1813 }
1814
1815 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1816 finderArgs, count);
1817
1818 closeSession(session);
1819 }
1820 }
1821
1822 return count.intValue();
1823 }
1824
1825 public int countByCompanyId(long companyId) throws SystemException {
1826 Object[] finderArgs = new Object[] { new Long(companyId) };
1827
1828 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1829 finderArgs, this);
1830
1831 if (count == null) {
1832 Session session = null;
1833
1834 try {
1835 session = openSession();
1836
1837 StringBuilder query = new StringBuilder();
1838
1839 query.append("SELECT COUNT(*) ");
1840 query.append(
1841 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1842
1843 query.append("companyId = ?");
1844
1845 query.append(" ");
1846
1847 Query q = session.createQuery(query.toString());
1848
1849 QueryPos qPos = QueryPos.getInstance(q);
1850
1851 qPos.add(companyId);
1852
1853 count = (Long)q.uniqueResult();
1854 }
1855 catch (Exception e) {
1856 throw processException(e);
1857 }
1858 finally {
1859 if (count == null) {
1860 count = Long.valueOf(0);
1861 }
1862
1863 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1864 finderArgs, count);
1865
1866 closeSession(session);
1867 }
1868 }
1869
1870 return count.intValue();
1871 }
1872
1873 public int countByG_P(long groupId, long parentCategoryId)
1874 throws SystemException {
1875 Object[] finderArgs = new Object[] {
1876 new Long(groupId), new Long(parentCategoryId)
1877 };
1878
1879 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
1880 finderArgs, this);
1881
1882 if (count == null) {
1883 Session session = null;
1884
1885 try {
1886 session = openSession();
1887
1888 StringBuilder query = new StringBuilder();
1889
1890 query.append("SELECT COUNT(*) ");
1891 query.append(
1892 "FROM com.liferay.portlet.messageboards.model.MBCategory WHERE ");
1893
1894 query.append("groupId = ?");
1895
1896 query.append(" AND ");
1897
1898 query.append("parentCategoryId = ?");
1899
1900 query.append(" ");
1901
1902 Query q = session.createQuery(query.toString());
1903
1904 QueryPos qPos = QueryPos.getInstance(q);
1905
1906 qPos.add(groupId);
1907
1908 qPos.add(parentCategoryId);
1909
1910 count = (Long)q.uniqueResult();
1911 }
1912 catch (Exception e) {
1913 throw processException(e);
1914 }
1915 finally {
1916 if (count == null) {
1917 count = Long.valueOf(0);
1918 }
1919
1920 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
1921 count);
1922
1923 closeSession(session);
1924 }
1925 }
1926
1927 return count.intValue();
1928 }
1929
1930 public int countAll() throws SystemException {
1931 Object[] finderArgs = new Object[0];
1932
1933 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1934 finderArgs, this);
1935
1936 if (count == null) {
1937 Session session = null;
1938
1939 try {
1940 session = openSession();
1941
1942 Query q = session.createQuery(
1943 "SELECT COUNT(*) FROM com.liferay.portlet.messageboards.model.MBCategory");
1944
1945 count = (Long)q.uniqueResult();
1946 }
1947 catch (Exception e) {
1948 throw processException(e);
1949 }
1950 finally {
1951 if (count == null) {
1952 count = Long.valueOf(0);
1953 }
1954
1955 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1956 count);
1957
1958 closeSession(session);
1959 }
1960 }
1961
1962 return count.intValue();
1963 }
1964
1965 public void afterPropertiesSet() {
1966 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1967 com.liferay.portal.util.PropsUtil.get(
1968 "value.object.listener.com.liferay.portlet.messageboards.model.MBCategory")));
1969
1970 if (listenerClassNames.length > 0) {
1971 try {
1972 List<ModelListener<MBCategory>> listenersList = new ArrayList<ModelListener<MBCategory>>();
1973
1974 for (String listenerClassName : listenerClassNames) {
1975 listenersList.add((ModelListener<MBCategory>)Class.forName(
1976 listenerClassName).newInstance());
1977 }
1978
1979 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1980 }
1981 catch (Exception e) {
1982 _log.error(e);
1983 }
1984 }
1985 }
1986
1987 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBBanPersistence.impl")
1988 protected com.liferay.portlet.messageboards.service.persistence.MBBanPersistence mbBanPersistence;
1989 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence.impl")
1990 protected com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence mbCategoryPersistence;
1991 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence.impl")
1992 protected com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence mbDiscussionPersistence;
1993 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence.impl")
1994 protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
1995 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence.impl")
1996 protected com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence mbMessageFlagPersistence;
1997 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence.impl")
1998 protected com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence mbStatsUserPersistence;
1999 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence.impl")
2000 protected com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence mbThreadPersistence;
2001 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
2002 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2003 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
2004 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
2005 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
2006 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2007 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence.impl")
2008 protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
2009 private static Log _log = LogFactoryUtil.getLog(MBCategoryPersistenceImpl.class);
2010}