1
14
15 package com.liferay.portlet.messageboards.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
21 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderPath;
23 import com.liferay.portal.kernel.dao.orm.Query;
24 import com.liferay.portal.kernel.dao.orm.QueryPos;
25 import com.liferay.portal.kernel.dao.orm.QueryUtil;
26 import com.liferay.portal.kernel.dao.orm.SQLQuery;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.dao.orm.Type;
29 import com.liferay.portal.kernel.exception.SystemException;
30 import com.liferay.portal.kernel.log.Log;
31 import com.liferay.portal.kernel.log.LogFactoryUtil;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.InstanceFactory;
34 import com.liferay.portal.kernel.util.OrderByComparator;
35 import com.liferay.portal.kernel.util.StringBundler;
36 import com.liferay.portal.kernel.util.StringPool;
37 import com.liferay.portal.kernel.util.StringUtil;
38 import com.liferay.portal.kernel.util.Validator;
39 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
40 import com.liferay.portal.model.ModelListener;
41 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
42 import com.liferay.portal.service.persistence.BatchSessionUtil;
43 import com.liferay.portal.service.persistence.GroupPersistence;
44 import com.liferay.portal.service.persistence.ResourcePersistence;
45 import com.liferay.portal.service.persistence.SubscriptionPersistence;
46 import com.liferay.portal.service.persistence.UserPersistence;
47 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
48
49 import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
50 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
51 import com.liferay.portlet.messageboards.NoSuchCategoryException;
52 import com.liferay.portlet.messageboards.model.MBCategory;
53 import com.liferay.portlet.messageboards.model.impl.MBCategoryImpl;
54 import com.liferay.portlet.messageboards.model.impl.MBCategoryModelImpl;
55
56 import java.io.Serializable;
57
58 import java.util.ArrayList;
59 import java.util.Collections;
60 import java.util.List;
61
62
75 public class MBCategoryPersistenceImpl extends BasePersistenceImpl<MBCategory>
76 implements MBCategoryPersistence {
77 public static final String FINDER_CLASS_NAME_ENTITY = MBCategoryImpl.class.getName();
78 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
79 ".List";
80 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
81 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
82 "findByUuid",
83 new String[] {
84 String.class.getName(),
85
86 "java.lang.Integer", "java.lang.Integer",
87 "com.liferay.portal.kernel.util.OrderByComparator"
88 });
89 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
90 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
91 "countByUuid", new String[] { String.class.getName() });
92 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
93 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
94 "fetchByUUID_G",
95 new String[] { String.class.getName(), Long.class.getName() });
96 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
97 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
98 "countByUUID_G",
99 new String[] { String.class.getName(), Long.class.getName() });
100 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
101 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
102 "findByGroupId",
103 new String[] {
104 Long.class.getName(),
105
106 "java.lang.Integer", "java.lang.Integer",
107 "com.liferay.portal.kernel.util.OrderByComparator"
108 });
109 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
110 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111 "countByGroupId", new String[] { Long.class.getName() });
112 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
113 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
114 "findByCompanyId",
115 new String[] {
116 Long.class.getName(),
117
118 "java.lang.Integer", "java.lang.Integer",
119 "com.liferay.portal.kernel.util.OrderByComparator"
120 });
121 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
122 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
123 "countByCompanyId", new String[] { Long.class.getName() });
124 public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
125 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
126 "findByG_P",
127 new String[] {
128 Long.class.getName(), Long.class.getName(),
129
130 "java.lang.Integer", "java.lang.Integer",
131 "com.liferay.portal.kernel.util.OrderByComparator"
132 });
133 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
134 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
135 "countByG_P",
136 new String[] { Long.class.getName(), Long.class.getName() });
137 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
138 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
139 "findAll", new String[0]);
140 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
141 MBCategoryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
142 "countAll", new String[0]);
143
144 public void cacheResult(MBCategory mbCategory) {
145 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
146 MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory);
147
148 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
149 new Object[] { mbCategory.getUuid(), new Long(
150 mbCategory.getGroupId()) }, mbCategory);
151 }
152
153 public void cacheResult(List<MBCategory> mbCategories) {
154 for (MBCategory mbCategory : mbCategories) {
155 if (EntityCacheUtil.getResult(
156 MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
157 MBCategoryImpl.class, mbCategory.getPrimaryKey(), this) == null) {
158 cacheResult(mbCategory);
159 }
160 }
161 }
162
163 public void clearCache() {
164 CacheRegistry.clear(MBCategoryImpl.class.getName());
165 EntityCacheUtil.clearCache(MBCategoryImpl.class.getName());
166 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
167 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
168 }
169
170 public void clearCache(MBCategory mbCategory) {
171 EntityCacheUtil.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
172 MBCategoryImpl.class, mbCategory.getPrimaryKey());
173
174 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
175 new Object[] { mbCategory.getUuid(), new Long(
176 mbCategory.getGroupId()) });
177 }
178
179 public MBCategory create(long categoryId) {
180 MBCategory mbCategory = new MBCategoryImpl();
181
182 mbCategory.setNew(true);
183 mbCategory.setPrimaryKey(categoryId);
184
185 String uuid = PortalUUIDUtil.generate();
186
187 mbCategory.setUuid(uuid);
188
189 return mbCategory;
190 }
191
192 public MBCategory remove(Serializable primaryKey)
193 throws NoSuchModelException, SystemException {
194 return remove(((Long)primaryKey).longValue());
195 }
196
197 public MBCategory remove(long categoryId)
198 throws NoSuchCategoryException, SystemException {
199 Session session = null;
200
201 try {
202 session = openSession();
203
204 MBCategory mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
205 new Long(categoryId));
206
207 if (mbCategory == null) {
208 if (_log.isWarnEnabled()) {
209 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
210 }
211
212 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
213 categoryId);
214 }
215
216 return remove(mbCategory);
217 }
218 catch (NoSuchCategoryException nsee) {
219 throw nsee;
220 }
221 catch (Exception e) {
222 throw processException(e);
223 }
224 finally {
225 closeSession(session);
226 }
227 }
228
229 public MBCategory remove(MBCategory mbCategory) throws SystemException {
230 for (ModelListener<MBCategory> listener : listeners) {
231 listener.onBeforeRemove(mbCategory);
232 }
233
234 mbCategory = removeImpl(mbCategory);
235
236 for (ModelListener<MBCategory> listener : listeners) {
237 listener.onAfterRemove(mbCategory);
238 }
239
240 return mbCategory;
241 }
242
243 protected MBCategory removeImpl(MBCategory mbCategory)
244 throws SystemException {
245 mbCategory = toUnwrappedModel(mbCategory);
246
247 Session session = null;
248
249 try {
250 session = openSession();
251
252 if (mbCategory.isCachedModel() || BatchSessionUtil.isEnabled()) {
253 Object staleObject = session.get(MBCategoryImpl.class,
254 mbCategory.getPrimaryKeyObj());
255
256 if (staleObject != null) {
257 session.evict(staleObject);
258 }
259 }
260
261 session.delete(mbCategory);
262
263 session.flush();
264 }
265 catch (Exception e) {
266 throw processException(e);
267 }
268 finally {
269 closeSession(session);
270 }
271
272 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
273
274 MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory;
275
276 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
277 new Object[] {
278 mbCategoryModelImpl.getOriginalUuid(),
279 new Long(mbCategoryModelImpl.getOriginalGroupId())
280 });
281
282 EntityCacheUtil.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
283 MBCategoryImpl.class, mbCategory.getPrimaryKey());
284
285 return mbCategory;
286 }
287
288 public MBCategory updateImpl(
289 com.liferay.portlet.messageboards.model.MBCategory mbCategory,
290 boolean merge) throws SystemException {
291 mbCategory = toUnwrappedModel(mbCategory);
292
293 boolean isNew = mbCategory.isNew();
294
295 MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory;
296
297 if (Validator.isNull(mbCategory.getUuid())) {
298 String uuid = PortalUUIDUtil.generate();
299
300 mbCategory.setUuid(uuid);
301 }
302
303 Session session = null;
304
305 try {
306 session = openSession();
307
308 BatchSessionUtil.update(session, mbCategory, merge);
309
310 mbCategory.setNew(false);
311 }
312 catch (Exception e) {
313 throw processException(e);
314 }
315 finally {
316 closeSession(session);
317 }
318
319 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
320
321 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
322 MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory);
323
324 if (!isNew &&
325 (!Validator.equals(mbCategory.getUuid(),
326 mbCategoryModelImpl.getOriginalUuid()) ||
327 (mbCategory.getGroupId() != mbCategoryModelImpl.getOriginalGroupId()))) {
328 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
329 new Object[] {
330 mbCategoryModelImpl.getOriginalUuid(),
331 new Long(mbCategoryModelImpl.getOriginalGroupId())
332 });
333 }
334
335 if (isNew ||
336 (!Validator.equals(mbCategory.getUuid(),
337 mbCategoryModelImpl.getOriginalUuid()) ||
338 (mbCategory.getGroupId() != mbCategoryModelImpl.getOriginalGroupId()))) {
339 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
340 new Object[] {
341 mbCategory.getUuid(), new Long(mbCategory.getGroupId())
342 }, mbCategory);
343 }
344
345 return mbCategory;
346 }
347
348 protected MBCategory toUnwrappedModel(MBCategory mbCategory) {
349 if (mbCategory instanceof MBCategoryImpl) {
350 return mbCategory;
351 }
352
353 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
354
355 mbCategoryImpl.setNew(mbCategory.isNew());
356 mbCategoryImpl.setPrimaryKey(mbCategory.getPrimaryKey());
357
358 mbCategoryImpl.setUuid(mbCategory.getUuid());
359 mbCategoryImpl.setCategoryId(mbCategory.getCategoryId());
360 mbCategoryImpl.setGroupId(mbCategory.getGroupId());
361 mbCategoryImpl.setCompanyId(mbCategory.getCompanyId());
362 mbCategoryImpl.setUserId(mbCategory.getUserId());
363 mbCategoryImpl.setUserName(mbCategory.getUserName());
364 mbCategoryImpl.setCreateDate(mbCategory.getCreateDate());
365 mbCategoryImpl.setModifiedDate(mbCategory.getModifiedDate());
366 mbCategoryImpl.setParentCategoryId(mbCategory.getParentCategoryId());
367 mbCategoryImpl.setName(mbCategory.getName());
368 mbCategoryImpl.setDescription(mbCategory.getDescription());
369 mbCategoryImpl.setThreadCount(mbCategory.getThreadCount());
370 mbCategoryImpl.setMessageCount(mbCategory.getMessageCount());
371 mbCategoryImpl.setLastPostDate(mbCategory.getLastPostDate());
372
373 return mbCategoryImpl;
374 }
375
376 public MBCategory findByPrimaryKey(Serializable primaryKey)
377 throws NoSuchModelException, SystemException {
378 return findByPrimaryKey(((Long)primaryKey).longValue());
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_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
388 }
389
390 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
391 categoryId);
392 }
393
394 return mbCategory;
395 }
396
397 public MBCategory fetchByPrimaryKey(Serializable primaryKey)
398 throws SystemException {
399 return fetchByPrimaryKey(((Long)primaryKey).longValue());
400 }
401
402 public MBCategory fetchByPrimaryKey(long categoryId)
403 throws SystemException {
404 MBCategory mbCategory = (MBCategory)EntityCacheUtil.getResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
405 MBCategoryImpl.class, categoryId, this);
406
407 if (mbCategory == null) {
408 Session session = null;
409
410 try {
411 session = openSession();
412
413 mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
414 new Long(categoryId));
415 }
416 catch (Exception e) {
417 throw processException(e);
418 }
419 finally {
420 if (mbCategory != null) {
421 cacheResult(mbCategory);
422 }
423
424 closeSession(session);
425 }
426 }
427
428 return mbCategory;
429 }
430
431 public List<MBCategory> findByUuid(String uuid) throws SystemException {
432 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
433 }
434
435 public List<MBCategory> findByUuid(String uuid, int start, int end)
436 throws SystemException {
437 return findByUuid(uuid, start, end, null);
438 }
439
440 public List<MBCategory> findByUuid(String uuid, int start, int end,
441 OrderByComparator orderByComparator) throws SystemException {
442 Object[] finderArgs = new Object[] {
443 uuid,
444
445 String.valueOf(start), String.valueOf(end),
446 String.valueOf(orderByComparator)
447 };
448
449 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
450 finderArgs, this);
451
452 if (list == null) {
453 Session session = null;
454
455 try {
456 session = openSession();
457
458 StringBundler query = null;
459
460 if (orderByComparator != null) {
461 query = new StringBundler(3 +
462 (orderByComparator.getOrderByFields().length * 3));
463 }
464 else {
465 query = new StringBundler(3);
466 }
467
468 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
469
470 if (uuid == null) {
471 query.append(_FINDER_COLUMN_UUID_UUID_1);
472 }
473 else {
474 if (uuid.equals(StringPool.BLANK)) {
475 query.append(_FINDER_COLUMN_UUID_UUID_3);
476 }
477 else {
478 query.append(_FINDER_COLUMN_UUID_UUID_2);
479 }
480 }
481
482 if (orderByComparator != null) {
483 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
484 orderByComparator);
485 }
486
487 else {
488 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
489 }
490
491 String sql = query.toString();
492
493 Query q = session.createQuery(sql);
494
495 QueryPos qPos = QueryPos.getInstance(q);
496
497 if (uuid != null) {
498 qPos.add(uuid);
499 }
500
501 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
502 end);
503 }
504 catch (Exception e) {
505 throw processException(e);
506 }
507 finally {
508 if (list == null) {
509 list = new ArrayList<MBCategory>();
510 }
511
512 cacheResult(list);
513
514 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
515 list);
516
517 closeSession(session);
518 }
519 }
520
521 return list;
522 }
523
524 public MBCategory findByUuid_First(String uuid,
525 OrderByComparator orderByComparator)
526 throws NoSuchCategoryException, SystemException {
527 List<MBCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
528
529 if (list.isEmpty()) {
530 StringBundler msg = new StringBundler(4);
531
532 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
533
534 msg.append("uuid=");
535 msg.append(uuid);
536
537 msg.append(StringPool.CLOSE_CURLY_BRACE);
538
539 throw new NoSuchCategoryException(msg.toString());
540 }
541 else {
542 return list.get(0);
543 }
544 }
545
546 public MBCategory findByUuid_Last(String uuid,
547 OrderByComparator orderByComparator)
548 throws NoSuchCategoryException, SystemException {
549 int count = countByUuid(uuid);
550
551 List<MBCategory> list = findByUuid(uuid, count - 1, count,
552 orderByComparator);
553
554 if (list.isEmpty()) {
555 StringBundler msg = new StringBundler(4);
556
557 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
558
559 msg.append("uuid=");
560 msg.append(uuid);
561
562 msg.append(StringPool.CLOSE_CURLY_BRACE);
563
564 throw new NoSuchCategoryException(msg.toString());
565 }
566 else {
567 return list.get(0);
568 }
569 }
570
571 public MBCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
572 OrderByComparator orderByComparator)
573 throws NoSuchCategoryException, SystemException {
574 MBCategory mbCategory = findByPrimaryKey(categoryId);
575
576 Session session = null;
577
578 try {
579 session = openSession();
580
581 MBCategory[] array = new MBCategoryImpl[3];
582
583 array[0] = getByUuid_PrevAndNext(session, mbCategory, uuid,
584 orderByComparator, true);
585
586 array[1] = mbCategory;
587
588 array[2] = getByUuid_PrevAndNext(session, mbCategory, uuid,
589 orderByComparator, false);
590
591 return array;
592 }
593 catch (Exception e) {
594 throw processException(e);
595 }
596 finally {
597 closeSession(session);
598 }
599 }
600
601 protected MBCategory getByUuid_PrevAndNext(Session session,
602 MBCategory mbCategory, String uuid,
603 OrderByComparator orderByComparator, boolean previous) {
604 StringBundler query = null;
605
606 if (orderByComparator != null) {
607 query = new StringBundler(6 +
608 (orderByComparator.getOrderByFields().length * 6));
609 }
610 else {
611 query = new StringBundler(3);
612 }
613
614 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
615
616 if (uuid == null) {
617 query.append(_FINDER_COLUMN_UUID_UUID_1);
618 }
619 else {
620 if (uuid.equals(StringPool.BLANK)) {
621 query.append(_FINDER_COLUMN_UUID_UUID_3);
622 }
623 else {
624 query.append(_FINDER_COLUMN_UUID_UUID_2);
625 }
626 }
627
628 if (orderByComparator != null) {
629 String[] orderByFields = orderByComparator.getOrderByFields();
630
631 if (orderByFields.length > 0) {
632 query.append(WHERE_AND);
633 }
634
635 for (int i = 0; i < orderByFields.length; i++) {
636 query.append(_ORDER_BY_ENTITY_ALIAS);
637 query.append(orderByFields[i]);
638
639 if ((i + 1) < orderByFields.length) {
640 if (orderByComparator.isAscending() ^ previous) {
641 query.append(WHERE_GREATER_THAN_HAS_NEXT);
642 }
643 else {
644 query.append(WHERE_LESSER_THAN_HAS_NEXT);
645 }
646 }
647 else {
648 if (orderByComparator.isAscending() ^ previous) {
649 query.append(WHERE_GREATER_THAN);
650 }
651 else {
652 query.append(WHERE_LESSER_THAN);
653 }
654 }
655 }
656
657 query.append(ORDER_BY_CLAUSE);
658
659 for (int i = 0; i < orderByFields.length; i++) {
660 query.append(_ORDER_BY_ENTITY_ALIAS);
661 query.append(orderByFields[i]);
662
663 if ((i + 1) < orderByFields.length) {
664 if (orderByComparator.isAscending() ^ previous) {
665 query.append(ORDER_BY_ASC_HAS_NEXT);
666 }
667 else {
668 query.append(ORDER_BY_DESC_HAS_NEXT);
669 }
670 }
671 else {
672 if (orderByComparator.isAscending() ^ previous) {
673 query.append(ORDER_BY_ASC);
674 }
675 else {
676 query.append(ORDER_BY_DESC);
677 }
678 }
679 }
680 }
681
682 else {
683 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
684 }
685
686 String sql = query.toString();
687
688 Query q = session.createQuery(sql);
689
690 q.setFirstResult(0);
691 q.setMaxResults(2);
692
693 QueryPos qPos = QueryPos.getInstance(q);
694
695 if (uuid != null) {
696 qPos.add(uuid);
697 }
698
699 if (orderByComparator != null) {
700 Object[] values = orderByComparator.getOrderByValues(mbCategory);
701
702 for (Object value : values) {
703 qPos.add(value);
704 }
705 }
706
707 List<MBCategory> list = q.list();
708
709 if (list.size() == 2) {
710 return list.get(1);
711 }
712 else {
713 return null;
714 }
715 }
716
717 public MBCategory findByUUID_G(String uuid, long groupId)
718 throws NoSuchCategoryException, SystemException {
719 MBCategory mbCategory = fetchByUUID_G(uuid, groupId);
720
721 if (mbCategory == null) {
722 StringBundler msg = new StringBundler(6);
723
724 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
725
726 msg.append("uuid=");
727 msg.append(uuid);
728
729 msg.append(", groupId=");
730 msg.append(groupId);
731
732 msg.append(StringPool.CLOSE_CURLY_BRACE);
733
734 if (_log.isWarnEnabled()) {
735 _log.warn(msg.toString());
736 }
737
738 throw new NoSuchCategoryException(msg.toString());
739 }
740
741 return mbCategory;
742 }
743
744 public MBCategory fetchByUUID_G(String uuid, long groupId)
745 throws SystemException {
746 return fetchByUUID_G(uuid, groupId, true);
747 }
748
749 public MBCategory fetchByUUID_G(String uuid, long groupId,
750 boolean retrieveFromCache) throws SystemException {
751 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
752
753 Object result = null;
754
755 if (retrieveFromCache) {
756 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
757 finderArgs, this);
758 }
759
760 if (result == null) {
761 Session session = null;
762
763 try {
764 session = openSession();
765
766 StringBundler query = new StringBundler(4);
767
768 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
769
770 if (uuid == null) {
771 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
772 }
773 else {
774 if (uuid.equals(StringPool.BLANK)) {
775 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
776 }
777 else {
778 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
779 }
780 }
781
782 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
783
784 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
785
786 String sql = query.toString();
787
788 Query q = session.createQuery(sql);
789
790 QueryPos qPos = QueryPos.getInstance(q);
791
792 if (uuid != null) {
793 qPos.add(uuid);
794 }
795
796 qPos.add(groupId);
797
798 List<MBCategory> list = q.list();
799
800 result = list;
801
802 MBCategory mbCategory = null;
803
804 if (list.isEmpty()) {
805 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
806 finderArgs, list);
807 }
808 else {
809 mbCategory = list.get(0);
810
811 cacheResult(mbCategory);
812
813 if ((mbCategory.getUuid() == null) ||
814 !mbCategory.getUuid().equals(uuid) ||
815 (mbCategory.getGroupId() != groupId)) {
816 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
817 finderArgs, mbCategory);
818 }
819 }
820
821 return mbCategory;
822 }
823 catch (Exception e) {
824 throw processException(e);
825 }
826 finally {
827 if (result == null) {
828 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
829 finderArgs, new ArrayList<MBCategory>());
830 }
831
832 closeSession(session);
833 }
834 }
835 else {
836 if (result instanceof List<?>) {
837 return null;
838 }
839 else {
840 return (MBCategory)result;
841 }
842 }
843 }
844
845 public List<MBCategory> findByGroupId(long groupId)
846 throws SystemException {
847 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
848 }
849
850 public List<MBCategory> findByGroupId(long groupId, int start, int end)
851 throws SystemException {
852 return findByGroupId(groupId, start, end, null);
853 }
854
855 public List<MBCategory> findByGroupId(long groupId, int start, int end,
856 OrderByComparator orderByComparator) throws SystemException {
857 Object[] finderArgs = new Object[] {
858 new Long(groupId),
859
860 String.valueOf(start), String.valueOf(end),
861 String.valueOf(orderByComparator)
862 };
863
864 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
865 finderArgs, this);
866
867 if (list == null) {
868 Session session = null;
869
870 try {
871 session = openSession();
872
873 StringBundler query = null;
874
875 if (orderByComparator != null) {
876 query = new StringBundler(3 +
877 (orderByComparator.getOrderByFields().length * 3));
878 }
879 else {
880 query = new StringBundler(3);
881 }
882
883 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
884
885 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
886
887 if (orderByComparator != null) {
888 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
889 orderByComparator);
890 }
891
892 else {
893 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
894 }
895
896 String sql = query.toString();
897
898 Query q = session.createQuery(sql);
899
900 QueryPos qPos = QueryPos.getInstance(q);
901
902 qPos.add(groupId);
903
904 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
905 end);
906 }
907 catch (Exception e) {
908 throw processException(e);
909 }
910 finally {
911 if (list == null) {
912 list = new ArrayList<MBCategory>();
913 }
914
915 cacheResult(list);
916
917 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
918 finderArgs, list);
919
920 closeSession(session);
921 }
922 }
923
924 return list;
925 }
926
927 public MBCategory findByGroupId_First(long groupId,
928 OrderByComparator orderByComparator)
929 throws NoSuchCategoryException, SystemException {
930 List<MBCategory> list = findByGroupId(groupId, 0, 1, orderByComparator);
931
932 if (list.isEmpty()) {
933 StringBundler msg = new StringBundler(4);
934
935 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
936
937 msg.append("groupId=");
938 msg.append(groupId);
939
940 msg.append(StringPool.CLOSE_CURLY_BRACE);
941
942 throw new NoSuchCategoryException(msg.toString());
943 }
944 else {
945 return list.get(0);
946 }
947 }
948
949 public MBCategory findByGroupId_Last(long groupId,
950 OrderByComparator orderByComparator)
951 throws NoSuchCategoryException, SystemException {
952 int count = countByGroupId(groupId);
953
954 List<MBCategory> list = findByGroupId(groupId, count - 1, count,
955 orderByComparator);
956
957 if (list.isEmpty()) {
958 StringBundler msg = new StringBundler(4);
959
960 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
961
962 msg.append("groupId=");
963 msg.append(groupId);
964
965 msg.append(StringPool.CLOSE_CURLY_BRACE);
966
967 throw new NoSuchCategoryException(msg.toString());
968 }
969 else {
970 return list.get(0);
971 }
972 }
973
974 public MBCategory[] findByGroupId_PrevAndNext(long categoryId,
975 long groupId, OrderByComparator orderByComparator)
976 throws NoSuchCategoryException, SystemException {
977 MBCategory mbCategory = findByPrimaryKey(categoryId);
978
979 Session session = null;
980
981 try {
982 session = openSession();
983
984 MBCategory[] array = new MBCategoryImpl[3];
985
986 array[0] = getByGroupId_PrevAndNext(session, mbCategory, groupId,
987 orderByComparator, true);
988
989 array[1] = mbCategory;
990
991 array[2] = getByGroupId_PrevAndNext(session, mbCategory, groupId,
992 orderByComparator, false);
993
994 return array;
995 }
996 catch (Exception e) {
997 throw processException(e);
998 }
999 finally {
1000 closeSession(session);
1001 }
1002 }
1003
1004 protected MBCategory getByGroupId_PrevAndNext(Session session,
1005 MBCategory mbCategory, long groupId,
1006 OrderByComparator orderByComparator, boolean previous) {
1007 StringBundler query = null;
1008
1009 if (orderByComparator != null) {
1010 query = new StringBundler(6 +
1011 (orderByComparator.getOrderByFields().length * 6));
1012 }
1013 else {
1014 query = new StringBundler(3);
1015 }
1016
1017 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1018
1019 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1020
1021 if (orderByComparator != null) {
1022 String[] orderByFields = orderByComparator.getOrderByFields();
1023
1024 if (orderByFields.length > 0) {
1025 query.append(WHERE_AND);
1026 }
1027
1028 for (int i = 0; i < orderByFields.length; i++) {
1029 query.append(_ORDER_BY_ENTITY_ALIAS);
1030 query.append(orderByFields[i]);
1031
1032 if ((i + 1) < orderByFields.length) {
1033 if (orderByComparator.isAscending() ^ previous) {
1034 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1035 }
1036 else {
1037 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1038 }
1039 }
1040 else {
1041 if (orderByComparator.isAscending() ^ previous) {
1042 query.append(WHERE_GREATER_THAN);
1043 }
1044 else {
1045 query.append(WHERE_LESSER_THAN);
1046 }
1047 }
1048 }
1049
1050 query.append(ORDER_BY_CLAUSE);
1051
1052 for (int i = 0; i < orderByFields.length; i++) {
1053 query.append(_ORDER_BY_ENTITY_ALIAS);
1054 query.append(orderByFields[i]);
1055
1056 if ((i + 1) < orderByFields.length) {
1057 if (orderByComparator.isAscending() ^ previous) {
1058 query.append(ORDER_BY_ASC_HAS_NEXT);
1059 }
1060 else {
1061 query.append(ORDER_BY_DESC_HAS_NEXT);
1062 }
1063 }
1064 else {
1065 if (orderByComparator.isAscending() ^ previous) {
1066 query.append(ORDER_BY_ASC);
1067 }
1068 else {
1069 query.append(ORDER_BY_DESC);
1070 }
1071 }
1072 }
1073 }
1074
1075 else {
1076 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1077 }
1078
1079 String sql = query.toString();
1080
1081 Query q = session.createQuery(sql);
1082
1083 q.setFirstResult(0);
1084 q.setMaxResults(2);
1085
1086 QueryPos qPos = QueryPos.getInstance(q);
1087
1088 qPos.add(groupId);
1089
1090 if (orderByComparator != null) {
1091 Object[] values = orderByComparator.getOrderByValues(mbCategory);
1092
1093 for (Object value : values) {
1094 qPos.add(value);
1095 }
1096 }
1097
1098 List<MBCategory> list = q.list();
1099
1100 if (list.size() == 2) {
1101 return list.get(1);
1102 }
1103 else {
1104 return null;
1105 }
1106 }
1107
1108 public List<MBCategory> filterFindByGroupId(long groupId)
1109 throws SystemException {
1110 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1111 QueryUtil.ALL_POS, null);
1112 }
1113
1114 public List<MBCategory> filterFindByGroupId(long groupId, int start, int end)
1115 throws SystemException {
1116 return filterFindByGroupId(groupId, start, end, null);
1117 }
1118
1119 public List<MBCategory> filterFindByGroupId(long groupId, int start,
1120 int end, OrderByComparator orderByComparator) throws SystemException {
1121 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1122 return findByGroupId(groupId, start, end, orderByComparator);
1123 }
1124
1125 Session session = null;
1126
1127 try {
1128 session = openSession();
1129
1130 StringBundler query = null;
1131
1132 if (orderByComparator != null) {
1133 query = new StringBundler(3 +
1134 (orderByComparator.getOrderByFields().length * 3));
1135 }
1136 else {
1137 query = new StringBundler(3);
1138 }
1139
1140 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
1141
1142 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1143
1144 if (orderByComparator != null) {
1145 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1146 orderByComparator);
1147 }
1148
1149 else {
1150 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1151 }
1152
1153 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1154 MBCategory.class.getName(), _FILTER_COLUMN_CATEGORYID,
1155 _FILTER_COLUMN_USERID, groupId);
1156
1157 SQLQuery q = session.createSQLQuery(sql);
1158
1159 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
1160
1161 QueryPos qPos = QueryPos.getInstance(q);
1162
1163 qPos.add(groupId);
1164
1165 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
1166 }
1167 catch (Exception e) {
1168 throw processException(e);
1169 }
1170 finally {
1171 closeSession(session);
1172 }
1173 }
1174
1175 public List<MBCategory> findByCompanyId(long companyId)
1176 throws SystemException {
1177 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1178 null);
1179 }
1180
1181 public List<MBCategory> findByCompanyId(long companyId, int start, int end)
1182 throws SystemException {
1183 return findByCompanyId(companyId, start, end, null);
1184 }
1185
1186 public List<MBCategory> findByCompanyId(long companyId, int start, int end,
1187 OrderByComparator orderByComparator) throws SystemException {
1188 Object[] finderArgs = new Object[] {
1189 new Long(companyId),
1190
1191 String.valueOf(start), String.valueOf(end),
1192 String.valueOf(orderByComparator)
1193 };
1194
1195 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1196 finderArgs, this);
1197
1198 if (list == null) {
1199 Session session = null;
1200
1201 try {
1202 session = openSession();
1203
1204 StringBundler query = null;
1205
1206 if (orderByComparator != null) {
1207 query = new StringBundler(3 +
1208 (orderByComparator.getOrderByFields().length * 3));
1209 }
1210 else {
1211 query = new StringBundler(3);
1212 }
1213
1214 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1215
1216 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1217
1218 if (orderByComparator != null) {
1219 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1220 orderByComparator);
1221 }
1222
1223 else {
1224 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1225 }
1226
1227 String sql = query.toString();
1228
1229 Query q = session.createQuery(sql);
1230
1231 QueryPos qPos = QueryPos.getInstance(q);
1232
1233 qPos.add(companyId);
1234
1235 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
1236 end);
1237 }
1238 catch (Exception e) {
1239 throw processException(e);
1240 }
1241 finally {
1242 if (list == null) {
1243 list = new ArrayList<MBCategory>();
1244 }
1245
1246 cacheResult(list);
1247
1248 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1249 finderArgs, list);
1250
1251 closeSession(session);
1252 }
1253 }
1254
1255 return list;
1256 }
1257
1258 public MBCategory findByCompanyId_First(long companyId,
1259 OrderByComparator orderByComparator)
1260 throws NoSuchCategoryException, SystemException {
1261 List<MBCategory> list = findByCompanyId(companyId, 0, 1,
1262 orderByComparator);
1263
1264 if (list.isEmpty()) {
1265 StringBundler msg = new StringBundler(4);
1266
1267 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1268
1269 msg.append("companyId=");
1270 msg.append(companyId);
1271
1272 msg.append(StringPool.CLOSE_CURLY_BRACE);
1273
1274 throw new NoSuchCategoryException(msg.toString());
1275 }
1276 else {
1277 return list.get(0);
1278 }
1279 }
1280
1281 public MBCategory findByCompanyId_Last(long companyId,
1282 OrderByComparator orderByComparator)
1283 throws NoSuchCategoryException, SystemException {
1284 int count = countByCompanyId(companyId);
1285
1286 List<MBCategory> list = findByCompanyId(companyId, count - 1, count,
1287 orderByComparator);
1288
1289 if (list.isEmpty()) {
1290 StringBundler msg = new StringBundler(4);
1291
1292 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1293
1294 msg.append("companyId=");
1295 msg.append(companyId);
1296
1297 msg.append(StringPool.CLOSE_CURLY_BRACE);
1298
1299 throw new NoSuchCategoryException(msg.toString());
1300 }
1301 else {
1302 return list.get(0);
1303 }
1304 }
1305
1306 public MBCategory[] findByCompanyId_PrevAndNext(long categoryId,
1307 long companyId, OrderByComparator orderByComparator)
1308 throws NoSuchCategoryException, SystemException {
1309 MBCategory mbCategory = findByPrimaryKey(categoryId);
1310
1311 Session session = null;
1312
1313 try {
1314 session = openSession();
1315
1316 MBCategory[] array = new MBCategoryImpl[3];
1317
1318 array[0] = getByCompanyId_PrevAndNext(session, mbCategory,
1319 companyId, orderByComparator, true);
1320
1321 array[1] = mbCategory;
1322
1323 array[2] = getByCompanyId_PrevAndNext(session, mbCategory,
1324 companyId, orderByComparator, false);
1325
1326 return array;
1327 }
1328 catch (Exception e) {
1329 throw processException(e);
1330 }
1331 finally {
1332 closeSession(session);
1333 }
1334 }
1335
1336 protected MBCategory getByCompanyId_PrevAndNext(Session session,
1337 MBCategory mbCategory, long companyId,
1338 OrderByComparator orderByComparator, boolean previous) {
1339 StringBundler query = null;
1340
1341 if (orderByComparator != null) {
1342 query = new StringBundler(6 +
1343 (orderByComparator.getOrderByFields().length * 6));
1344 }
1345 else {
1346 query = new StringBundler(3);
1347 }
1348
1349 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1350
1351 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1352
1353 if (orderByComparator != null) {
1354 String[] orderByFields = orderByComparator.getOrderByFields();
1355
1356 if (orderByFields.length > 0) {
1357 query.append(WHERE_AND);
1358 }
1359
1360 for (int i = 0; i < orderByFields.length; i++) {
1361 query.append(_ORDER_BY_ENTITY_ALIAS);
1362 query.append(orderByFields[i]);
1363
1364 if ((i + 1) < orderByFields.length) {
1365 if (orderByComparator.isAscending() ^ previous) {
1366 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1367 }
1368 else {
1369 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1370 }
1371 }
1372 else {
1373 if (orderByComparator.isAscending() ^ previous) {
1374 query.append(WHERE_GREATER_THAN);
1375 }
1376 else {
1377 query.append(WHERE_LESSER_THAN);
1378 }
1379 }
1380 }
1381
1382 query.append(ORDER_BY_CLAUSE);
1383
1384 for (int i = 0; i < orderByFields.length; i++) {
1385 query.append(_ORDER_BY_ENTITY_ALIAS);
1386 query.append(orderByFields[i]);
1387
1388 if ((i + 1) < orderByFields.length) {
1389 if (orderByComparator.isAscending() ^ previous) {
1390 query.append(ORDER_BY_ASC_HAS_NEXT);
1391 }
1392 else {
1393 query.append(ORDER_BY_DESC_HAS_NEXT);
1394 }
1395 }
1396 else {
1397 if (orderByComparator.isAscending() ^ previous) {
1398 query.append(ORDER_BY_ASC);
1399 }
1400 else {
1401 query.append(ORDER_BY_DESC);
1402 }
1403 }
1404 }
1405 }
1406
1407 else {
1408 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1409 }
1410
1411 String sql = query.toString();
1412
1413 Query q = session.createQuery(sql);
1414
1415 q.setFirstResult(0);
1416 q.setMaxResults(2);
1417
1418 QueryPos qPos = QueryPos.getInstance(q);
1419
1420 qPos.add(companyId);
1421
1422 if (orderByComparator != null) {
1423 Object[] values = orderByComparator.getOrderByValues(mbCategory);
1424
1425 for (Object value : values) {
1426 qPos.add(value);
1427 }
1428 }
1429
1430 List<MBCategory> list = q.list();
1431
1432 if (list.size() == 2) {
1433 return list.get(1);
1434 }
1435 else {
1436 return null;
1437 }
1438 }
1439
1440 public List<MBCategory> findByG_P(long groupId, long parentCategoryId)
1441 throws SystemException {
1442 return findByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS,
1443 QueryUtil.ALL_POS, null);
1444 }
1445
1446 public List<MBCategory> findByG_P(long groupId, long parentCategoryId,
1447 int start, int end) throws SystemException {
1448 return findByG_P(groupId, parentCategoryId, start, end, null);
1449 }
1450
1451 public List<MBCategory> findByG_P(long groupId, long parentCategoryId,
1452 int start, int end, OrderByComparator orderByComparator)
1453 throws SystemException {
1454 Object[] finderArgs = new Object[] {
1455 new Long(groupId), new Long(parentCategoryId),
1456
1457 String.valueOf(start), String.valueOf(end),
1458 String.valueOf(orderByComparator)
1459 };
1460
1461 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
1462 finderArgs, this);
1463
1464 if (list == null) {
1465 Session session = null;
1466
1467 try {
1468 session = openSession();
1469
1470 StringBundler query = null;
1471
1472 if (orderByComparator != null) {
1473 query = new StringBundler(4 +
1474 (orderByComparator.getOrderByFields().length * 3));
1475 }
1476 else {
1477 query = new StringBundler(4);
1478 }
1479
1480 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1481
1482 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1483
1484 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
1485
1486 if (orderByComparator != null) {
1487 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1488 orderByComparator);
1489 }
1490
1491 else {
1492 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1493 }
1494
1495 String sql = query.toString();
1496
1497 Query q = session.createQuery(sql);
1498
1499 QueryPos qPos = QueryPos.getInstance(q);
1500
1501 qPos.add(groupId);
1502
1503 qPos.add(parentCategoryId);
1504
1505 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
1506 end);
1507 }
1508 catch (Exception e) {
1509 throw processException(e);
1510 }
1511 finally {
1512 if (list == null) {
1513 list = new ArrayList<MBCategory>();
1514 }
1515
1516 cacheResult(list);
1517
1518 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
1519 list);
1520
1521 closeSession(session);
1522 }
1523 }
1524
1525 return list;
1526 }
1527
1528 public MBCategory findByG_P_First(long groupId, long parentCategoryId,
1529 OrderByComparator orderByComparator)
1530 throws NoSuchCategoryException, SystemException {
1531 List<MBCategory> list = findByG_P(groupId, parentCategoryId, 0, 1,
1532 orderByComparator);
1533
1534 if (list.isEmpty()) {
1535 StringBundler msg = new StringBundler(6);
1536
1537 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1538
1539 msg.append("groupId=");
1540 msg.append(groupId);
1541
1542 msg.append(", parentCategoryId=");
1543 msg.append(parentCategoryId);
1544
1545 msg.append(StringPool.CLOSE_CURLY_BRACE);
1546
1547 throw new NoSuchCategoryException(msg.toString());
1548 }
1549 else {
1550 return list.get(0);
1551 }
1552 }
1553
1554 public MBCategory findByG_P_Last(long groupId, long parentCategoryId,
1555 OrderByComparator orderByComparator)
1556 throws NoSuchCategoryException, SystemException {
1557 int count = countByG_P(groupId, parentCategoryId);
1558
1559 List<MBCategory> list = findByG_P(groupId, parentCategoryId, count - 1,
1560 count, orderByComparator);
1561
1562 if (list.isEmpty()) {
1563 StringBundler msg = new StringBundler(6);
1564
1565 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1566
1567 msg.append("groupId=");
1568 msg.append(groupId);
1569
1570 msg.append(", parentCategoryId=");
1571 msg.append(parentCategoryId);
1572
1573 msg.append(StringPool.CLOSE_CURLY_BRACE);
1574
1575 throw new NoSuchCategoryException(msg.toString());
1576 }
1577 else {
1578 return list.get(0);
1579 }
1580 }
1581
1582 public MBCategory[] findByG_P_PrevAndNext(long categoryId, long groupId,
1583 long parentCategoryId, OrderByComparator orderByComparator)
1584 throws NoSuchCategoryException, SystemException {
1585 MBCategory mbCategory = findByPrimaryKey(categoryId);
1586
1587 Session session = null;
1588
1589 try {
1590 session = openSession();
1591
1592 MBCategory[] array = new MBCategoryImpl[3];
1593
1594 array[0] = getByG_P_PrevAndNext(session, mbCategory, groupId,
1595 parentCategoryId, orderByComparator, true);
1596
1597 array[1] = mbCategory;
1598
1599 array[2] = getByG_P_PrevAndNext(session, mbCategory, groupId,
1600 parentCategoryId, orderByComparator, false);
1601
1602 return array;
1603 }
1604 catch (Exception e) {
1605 throw processException(e);
1606 }
1607 finally {
1608 closeSession(session);
1609 }
1610 }
1611
1612 protected MBCategory getByG_P_PrevAndNext(Session session,
1613 MBCategory mbCategory, long groupId, long parentCategoryId,
1614 OrderByComparator orderByComparator, boolean previous) {
1615 StringBundler query = null;
1616
1617 if (orderByComparator != null) {
1618 query = new StringBundler(6 +
1619 (orderByComparator.getOrderByFields().length * 6));
1620 }
1621 else {
1622 query = new StringBundler(3);
1623 }
1624
1625 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1626
1627 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1628
1629 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
1630
1631 if (orderByComparator != null) {
1632 String[] orderByFields = orderByComparator.getOrderByFields();
1633
1634 if (orderByFields.length > 0) {
1635 query.append(WHERE_AND);
1636 }
1637
1638 for (int i = 0; i < orderByFields.length; i++) {
1639 query.append(_ORDER_BY_ENTITY_ALIAS);
1640 query.append(orderByFields[i]);
1641
1642 if ((i + 1) < orderByFields.length) {
1643 if (orderByComparator.isAscending() ^ previous) {
1644 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1645 }
1646 else {
1647 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1648 }
1649 }
1650 else {
1651 if (orderByComparator.isAscending() ^ previous) {
1652 query.append(WHERE_GREATER_THAN);
1653 }
1654 else {
1655 query.append(WHERE_LESSER_THAN);
1656 }
1657 }
1658 }
1659
1660 query.append(ORDER_BY_CLAUSE);
1661
1662 for (int i = 0; i < orderByFields.length; i++) {
1663 query.append(_ORDER_BY_ENTITY_ALIAS);
1664 query.append(orderByFields[i]);
1665
1666 if ((i + 1) < orderByFields.length) {
1667 if (orderByComparator.isAscending() ^ previous) {
1668 query.append(ORDER_BY_ASC_HAS_NEXT);
1669 }
1670 else {
1671 query.append(ORDER_BY_DESC_HAS_NEXT);
1672 }
1673 }
1674 else {
1675 if (orderByComparator.isAscending() ^ previous) {
1676 query.append(ORDER_BY_ASC);
1677 }
1678 else {
1679 query.append(ORDER_BY_DESC);
1680 }
1681 }
1682 }
1683 }
1684
1685 else {
1686 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1687 }
1688
1689 String sql = query.toString();
1690
1691 Query q = session.createQuery(sql);
1692
1693 q.setFirstResult(0);
1694 q.setMaxResults(2);
1695
1696 QueryPos qPos = QueryPos.getInstance(q);
1697
1698 qPos.add(groupId);
1699
1700 qPos.add(parentCategoryId);
1701
1702 if (orderByComparator != null) {
1703 Object[] values = orderByComparator.getOrderByValues(mbCategory);
1704
1705 for (Object value : values) {
1706 qPos.add(value);
1707 }
1708 }
1709
1710 List<MBCategory> list = q.list();
1711
1712 if (list.size() == 2) {
1713 return list.get(1);
1714 }
1715 else {
1716 return null;
1717 }
1718 }
1719
1720 public List<MBCategory> filterFindByG_P(long groupId, long parentCategoryId)
1721 throws SystemException {
1722 return filterFindByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS,
1723 QueryUtil.ALL_POS, null);
1724 }
1725
1726 public List<MBCategory> filterFindByG_P(long groupId,
1727 long parentCategoryId, int start, int end) throws SystemException {
1728 return filterFindByG_P(groupId, parentCategoryId, start, end, null);
1729 }
1730
1731 public List<MBCategory> filterFindByG_P(long groupId,
1732 long parentCategoryId, int start, int end,
1733 OrderByComparator orderByComparator) throws SystemException {
1734 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1735 return findByG_P(groupId, parentCategoryId, start, end,
1736 orderByComparator);
1737 }
1738
1739 Session session = null;
1740
1741 try {
1742 session = openSession();
1743
1744 StringBundler query = null;
1745
1746 if (orderByComparator != null) {
1747 query = new StringBundler(4 +
1748 (orderByComparator.getOrderByFields().length * 3));
1749 }
1750 else {
1751 query = new StringBundler(4);
1752 }
1753
1754 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
1755
1756 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1757
1758 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
1759
1760 if (orderByComparator != null) {
1761 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1762 orderByComparator);
1763 }
1764
1765 else {
1766 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1767 }
1768
1769 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1770 MBCategory.class.getName(), _FILTER_COLUMN_CATEGORYID,
1771 _FILTER_COLUMN_USERID, groupId);
1772
1773 SQLQuery q = session.createSQLQuery(sql);
1774
1775 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
1776
1777 QueryPos qPos = QueryPos.getInstance(q);
1778
1779 qPos.add(groupId);
1780
1781 qPos.add(parentCategoryId);
1782
1783 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
1784 }
1785 catch (Exception e) {
1786 throw processException(e);
1787 }
1788 finally {
1789 closeSession(session);
1790 }
1791 }
1792
1793 public List<MBCategory> findAll() throws SystemException {
1794 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1795 }
1796
1797 public List<MBCategory> findAll(int start, int end)
1798 throws SystemException {
1799 return findAll(start, end, null);
1800 }
1801
1802 public List<MBCategory> findAll(int start, int end,
1803 OrderByComparator orderByComparator) throws SystemException {
1804 Object[] finderArgs = new Object[] {
1805 String.valueOf(start), String.valueOf(end),
1806 String.valueOf(orderByComparator)
1807 };
1808
1809 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1810 finderArgs, this);
1811
1812 if (list == null) {
1813 Session session = null;
1814
1815 try {
1816 session = openSession();
1817
1818 StringBundler query = null;
1819 String sql = null;
1820
1821 if (orderByComparator != null) {
1822 query = new StringBundler(2 +
1823 (orderByComparator.getOrderByFields().length * 3));
1824
1825 query.append(_SQL_SELECT_MBCATEGORY);
1826
1827 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1828 orderByComparator);
1829
1830 sql = query.toString();
1831 }
1832
1833 else {
1834 sql = _SQL_SELECT_MBCATEGORY.concat(MBCategoryModelImpl.ORDER_BY_JPQL);
1835 }
1836
1837 Query q = session.createQuery(sql);
1838
1839 if (orderByComparator == null) {
1840 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
1841 start, end, false);
1842
1843 Collections.sort(list);
1844 }
1845 else {
1846 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
1847 start, end);
1848 }
1849 }
1850 catch (Exception e) {
1851 throw processException(e);
1852 }
1853 finally {
1854 if (list == null) {
1855 list = new ArrayList<MBCategory>();
1856 }
1857
1858 cacheResult(list);
1859
1860 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1861
1862 closeSession(session);
1863 }
1864 }
1865
1866 return list;
1867 }
1868
1869 public void removeByUuid(String uuid) throws SystemException {
1870 for (MBCategory mbCategory : findByUuid(uuid)) {
1871 remove(mbCategory);
1872 }
1873 }
1874
1875 public void removeByUUID_G(String uuid, long groupId)
1876 throws NoSuchCategoryException, SystemException {
1877 MBCategory mbCategory = findByUUID_G(uuid, groupId);
1878
1879 remove(mbCategory);
1880 }
1881
1882 public void removeByGroupId(long groupId) throws SystemException {
1883 for (MBCategory mbCategory : findByGroupId(groupId)) {
1884 remove(mbCategory);
1885 }
1886 }
1887
1888 public void removeByCompanyId(long companyId) throws SystemException {
1889 for (MBCategory mbCategory : findByCompanyId(companyId)) {
1890 remove(mbCategory);
1891 }
1892 }
1893
1894 public void removeByG_P(long groupId, long parentCategoryId)
1895 throws SystemException {
1896 for (MBCategory mbCategory : findByG_P(groupId, parentCategoryId)) {
1897 remove(mbCategory);
1898 }
1899 }
1900
1901 public void removeAll() throws SystemException {
1902 for (MBCategory mbCategory : findAll()) {
1903 remove(mbCategory);
1904 }
1905 }
1906
1907 public int countByUuid(String uuid) throws SystemException {
1908 Object[] finderArgs = new Object[] { uuid };
1909
1910 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1911 finderArgs, this);
1912
1913 if (count == null) {
1914 Session session = null;
1915
1916 try {
1917 session = openSession();
1918
1919 StringBundler query = new StringBundler(2);
1920
1921 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
1922
1923 if (uuid == null) {
1924 query.append(_FINDER_COLUMN_UUID_UUID_1);
1925 }
1926 else {
1927 if (uuid.equals(StringPool.BLANK)) {
1928 query.append(_FINDER_COLUMN_UUID_UUID_3);
1929 }
1930 else {
1931 query.append(_FINDER_COLUMN_UUID_UUID_2);
1932 }
1933 }
1934
1935 String sql = query.toString();
1936
1937 Query q = session.createQuery(sql);
1938
1939 QueryPos qPos = QueryPos.getInstance(q);
1940
1941 if (uuid != null) {
1942 qPos.add(uuid);
1943 }
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_BY_UUID,
1956 finderArgs, count);
1957
1958 closeSession(session);
1959 }
1960 }
1961
1962 return count.intValue();
1963 }
1964
1965 public int countByUUID_G(String uuid, long groupId)
1966 throws SystemException {
1967 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1968
1969 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1970 finderArgs, this);
1971
1972 if (count == null) {
1973 Session session = null;
1974
1975 try {
1976 session = openSession();
1977
1978 StringBundler query = new StringBundler(3);
1979
1980 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
1981
1982 if (uuid == null) {
1983 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1984 }
1985 else {
1986 if (uuid.equals(StringPool.BLANK)) {
1987 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1988 }
1989 else {
1990 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1991 }
1992 }
1993
1994 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1995
1996 String sql = query.toString();
1997
1998 Query q = session.createQuery(sql);
1999
2000 QueryPos qPos = QueryPos.getInstance(q);
2001
2002 if (uuid != null) {
2003 qPos.add(uuid);
2004 }
2005
2006 qPos.add(groupId);
2007
2008 count = (Long)q.uniqueResult();
2009 }
2010 catch (Exception e) {
2011 throw processException(e);
2012 }
2013 finally {
2014 if (count == null) {
2015 count = Long.valueOf(0);
2016 }
2017
2018 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2019 finderArgs, count);
2020
2021 closeSession(session);
2022 }
2023 }
2024
2025 return count.intValue();
2026 }
2027
2028 public int countByGroupId(long groupId) throws SystemException {
2029 Object[] finderArgs = new Object[] { new Long(groupId) };
2030
2031 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2032 finderArgs, this);
2033
2034 if (count == null) {
2035 Session session = null;
2036
2037 try {
2038 session = openSession();
2039
2040 StringBundler query = new StringBundler(2);
2041
2042 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
2043
2044 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2045
2046 String sql = query.toString();
2047
2048 Query q = session.createQuery(sql);
2049
2050 QueryPos qPos = QueryPos.getInstance(q);
2051
2052 qPos.add(groupId);
2053
2054 count = (Long)q.uniqueResult();
2055 }
2056 catch (Exception e) {
2057 throw processException(e);
2058 }
2059 finally {
2060 if (count == null) {
2061 count = Long.valueOf(0);
2062 }
2063
2064 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2065 finderArgs, count);
2066
2067 closeSession(session);
2068 }
2069 }
2070
2071 return count.intValue();
2072 }
2073
2074 public int filterCountByGroupId(long groupId) throws SystemException {
2075 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2076 return countByGroupId(groupId);
2077 }
2078
2079 Session session = null;
2080
2081 try {
2082 session = openSession();
2083
2084 StringBundler query = new StringBundler(2);
2085
2086 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
2087
2088 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2089
2090 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2091 MBCategory.class.getName(), _FILTER_COLUMN_CATEGORYID,
2092 _FILTER_COLUMN_USERID, groupId);
2093
2094 SQLQuery q = session.createSQLQuery(sql);
2095
2096 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2097
2098 QueryPos qPos = QueryPos.getInstance(q);
2099
2100 qPos.add(groupId);
2101
2102 Long count = (Long)q.uniqueResult();
2103
2104 return count.intValue();
2105 }
2106 catch (Exception e) {
2107 throw processException(e);
2108 }
2109 finally {
2110 closeSession(session);
2111 }
2112 }
2113
2114 public int countByCompanyId(long companyId) throws SystemException {
2115 Object[] finderArgs = new Object[] { new Long(companyId) };
2116
2117 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2118 finderArgs, this);
2119
2120 if (count == null) {
2121 Session session = null;
2122
2123 try {
2124 session = openSession();
2125
2126 StringBundler query = new StringBundler(2);
2127
2128 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
2129
2130 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2131
2132 String sql = query.toString();
2133
2134 Query q = session.createQuery(sql);
2135
2136 QueryPos qPos = QueryPos.getInstance(q);
2137
2138 qPos.add(companyId);
2139
2140 count = (Long)q.uniqueResult();
2141 }
2142 catch (Exception e) {
2143 throw processException(e);
2144 }
2145 finally {
2146 if (count == null) {
2147 count = Long.valueOf(0);
2148 }
2149
2150 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2151 finderArgs, count);
2152
2153 closeSession(session);
2154 }
2155 }
2156
2157 return count.intValue();
2158 }
2159
2160 public int countByG_P(long groupId, long parentCategoryId)
2161 throws SystemException {
2162 Object[] finderArgs = new Object[] {
2163 new Long(groupId), new Long(parentCategoryId)
2164 };
2165
2166 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2167 finderArgs, this);
2168
2169 if (count == null) {
2170 Session session = null;
2171
2172 try {
2173 session = openSession();
2174
2175 StringBundler query = new StringBundler(3);
2176
2177 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
2178
2179 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2180
2181 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
2182
2183 String sql = query.toString();
2184
2185 Query q = session.createQuery(sql);
2186
2187 QueryPos qPos = QueryPos.getInstance(q);
2188
2189 qPos.add(groupId);
2190
2191 qPos.add(parentCategoryId);
2192
2193 count = (Long)q.uniqueResult();
2194 }
2195 catch (Exception e) {
2196 throw processException(e);
2197 }
2198 finally {
2199 if (count == null) {
2200 count = Long.valueOf(0);
2201 }
2202
2203 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2204 count);
2205
2206 closeSession(session);
2207 }
2208 }
2209
2210 return count.intValue();
2211 }
2212
2213 public int filterCountByG_P(long groupId, long parentCategoryId)
2214 throws SystemException {
2215 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2216 return countByG_P(groupId, parentCategoryId);
2217 }
2218
2219 Session session = null;
2220
2221 try {
2222 session = openSession();
2223
2224 StringBundler query = new StringBundler(3);
2225
2226 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
2227
2228 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2229
2230 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
2231
2232 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2233 MBCategory.class.getName(), _FILTER_COLUMN_CATEGORYID,
2234 _FILTER_COLUMN_USERID, groupId);
2235
2236 SQLQuery q = session.createSQLQuery(sql);
2237
2238 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2239
2240 QueryPos qPos = QueryPos.getInstance(q);
2241
2242 qPos.add(groupId);
2243
2244 qPos.add(parentCategoryId);
2245
2246 Long count = (Long)q.uniqueResult();
2247
2248 return count.intValue();
2249 }
2250 catch (Exception e) {
2251 throw processException(e);
2252 }
2253 finally {
2254 closeSession(session);
2255 }
2256 }
2257
2258 public int countAll() throws SystemException {
2259 Object[] finderArgs = new Object[0];
2260
2261 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2262 finderArgs, this);
2263
2264 if (count == null) {
2265 Session session = null;
2266
2267 try {
2268 session = openSession();
2269
2270 Query q = session.createQuery(_SQL_COUNT_MBCATEGORY);
2271
2272 count = (Long)q.uniqueResult();
2273 }
2274 catch (Exception e) {
2275 throw processException(e);
2276 }
2277 finally {
2278 if (count == null) {
2279 count = Long.valueOf(0);
2280 }
2281
2282 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2283 count);
2284
2285 closeSession(session);
2286 }
2287 }
2288
2289 return count.intValue();
2290 }
2291
2292 public void afterPropertiesSet() {
2293 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2294 com.liferay.portal.util.PropsUtil.get(
2295 "value.object.listener.com.liferay.portlet.messageboards.model.MBCategory")));
2296
2297 if (listenerClassNames.length > 0) {
2298 try {
2299 List<ModelListener<MBCategory>> listenersList = new ArrayList<ModelListener<MBCategory>>();
2300
2301 for (String listenerClassName : listenerClassNames) {
2302 listenersList.add((ModelListener<MBCategory>)InstanceFactory.newInstance(
2303 listenerClassName));
2304 }
2305
2306 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2307 }
2308 catch (Exception e) {
2309 _log.error(e);
2310 }
2311 }
2312 }
2313
2314 @BeanReference(type = MBBanPersistence.class)
2315 protected MBBanPersistence mbBanPersistence;
2316 @BeanReference(type = MBCategoryPersistence.class)
2317 protected MBCategoryPersistence mbCategoryPersistence;
2318 @BeanReference(type = MBDiscussionPersistence.class)
2319 protected MBDiscussionPersistence mbDiscussionPersistence;
2320 @BeanReference(type = MBMailingListPersistence.class)
2321 protected MBMailingListPersistence mbMailingListPersistence;
2322 @BeanReference(type = MBMessagePersistence.class)
2323 protected MBMessagePersistence mbMessagePersistence;
2324 @BeanReference(type = MBMessageFlagPersistence.class)
2325 protected MBMessageFlagPersistence mbMessageFlagPersistence;
2326 @BeanReference(type = MBStatsUserPersistence.class)
2327 protected MBStatsUserPersistence mbStatsUserPersistence;
2328 @BeanReference(type = MBThreadPersistence.class)
2329 protected MBThreadPersistence mbThreadPersistence;
2330 @BeanReference(type = GroupPersistence.class)
2331 protected GroupPersistence groupPersistence;
2332 @BeanReference(type = ResourcePersistence.class)
2333 protected ResourcePersistence resourcePersistence;
2334 @BeanReference(type = SubscriptionPersistence.class)
2335 protected SubscriptionPersistence subscriptionPersistence;
2336 @BeanReference(type = UserPersistence.class)
2337 protected UserPersistence userPersistence;
2338 @BeanReference(type = AssetTagPersistence.class)
2339 protected AssetTagPersistence assetTagPersistence;
2340 @BeanReference(type = ExpandoValuePersistence.class)
2341 protected ExpandoValuePersistence expandoValuePersistence;
2342 private static final String _SQL_SELECT_MBCATEGORY = "SELECT mbCategory FROM MBCategory mbCategory";
2343 private static final String _SQL_SELECT_MBCATEGORY_WHERE = "SELECT mbCategory FROM MBCategory mbCategory WHERE ";
2344 private static final String _SQL_COUNT_MBCATEGORY = "SELECT COUNT(mbCategory) FROM MBCategory mbCategory";
2345 private static final String _SQL_COUNT_MBCATEGORY_WHERE = "SELECT COUNT(mbCategory) FROM MBCategory mbCategory WHERE ";
2346 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbCategory.uuid IS NULL";
2347 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbCategory.uuid = ?";
2348 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = ?)";
2349 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbCategory.uuid IS NULL AND ";
2350 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbCategory.uuid = ? AND ";
2351 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = ?) AND ";
2352 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbCategory.groupId = ?";
2353 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbCategory.groupId = ?";
2354 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "mbCategory.companyId = ?";
2355 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "mbCategory.groupId = ? AND ";
2356 private static final String _FINDER_COLUMN_G_P_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ?";
2357 private static final String _FILTER_SQL_SELECT_MBCATEGORY_WHERE = "SELECT DISTINCT {mbCategory.*} FROM MBCategory mbCategory WHERE ";
2358 private static final String _FILTER_SQL_COUNT_MBCATEGORY_WHERE = "SELECT COUNT(DISTINCT mbCategory.categoryId) AS COUNT_VALUE FROM MBCategory mbCategory WHERE ";
2359 private static final String _FILTER_COLUMN_CATEGORYID = "mbCategory.categoryId";
2360 private static final String _FILTER_COLUMN_USERID = "mbCategory.userId";
2361 private static final String _FILTER_ENTITY_ALIAS = "mbCategory";
2362 private static final String _ORDER_BY_ENTITY_ALIAS = "mbCategory.";
2363 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBCategory exists with the primary key ";
2364 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBCategory exists with the key {";
2365 private static Log _log = LogFactoryUtil.getLog(MBCategoryPersistenceImpl.class);
2366}