001
014
015 package com.liferay.portlet.messageboards.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.ArrayUtil;
032 import com.liferay.portal.kernel.util.GetterUtil;
033 import com.liferay.portal.kernel.util.InstanceFactory;
034 import com.liferay.portal.kernel.util.OrderByComparator;
035 import com.liferay.portal.kernel.util.StringBundler;
036 import com.liferay.portal.kernel.util.StringPool;
037 import com.liferay.portal.kernel.util.StringUtil;
038 import com.liferay.portal.kernel.util.Validator;
039 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040 import com.liferay.portal.model.CacheModel;
041 import com.liferay.portal.model.ModelListener;
042 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043 import com.liferay.portal.service.persistence.BatchSessionUtil;
044 import com.liferay.portal.service.persistence.GroupPersistence;
045 import com.liferay.portal.service.persistence.ResourcePersistence;
046 import com.liferay.portal.service.persistence.SubscriptionPersistence;
047 import com.liferay.portal.service.persistence.UserPersistence;
048 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049
050 import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
051 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
052 import com.liferay.portlet.messageboards.NoSuchCategoryException;
053 import com.liferay.portlet.messageboards.model.MBCategory;
054 import com.liferay.portlet.messageboards.model.impl.MBCategoryImpl;
055 import com.liferay.portlet.messageboards.model.impl.MBCategoryModelImpl;
056
057 import java.io.Serializable;
058
059 import java.util.ArrayList;
060 import java.util.Collections;
061 import java.util.List;
062
063
075 public class MBCategoryPersistenceImpl extends BasePersistenceImpl<MBCategory>
076 implements MBCategoryPersistence {
077
082 public static final String FINDER_CLASS_NAME_ENTITY = MBCategoryImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List1";
085 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List2";
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
088 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
090 new String[] {
091 String.class.getName(),
092
093 "java.lang.Integer", "java.lang.Integer",
094 "com.liferay.portal.kernel.util.OrderByComparator"
095 });
096 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
097 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
099 new String[] { String.class.getName() },
100 MBCategoryModelImpl.UUID_COLUMN_BITMASK);
101 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
102 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
104 new String[] { String.class.getName() });
105 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
106 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
107 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
108 new String[] { String.class.getName(), Long.class.getName() },
109 MBCategoryModelImpl.UUID_COLUMN_BITMASK |
110 MBCategoryModelImpl.GROUPID_COLUMN_BITMASK);
111 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
112 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
113 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
114 new String[] { String.class.getName(), Long.class.getName() });
115 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
116 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
117 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
118 new String[] {
119 Long.class.getName(),
120
121 "java.lang.Integer", "java.lang.Integer",
122 "com.liferay.portal.kernel.util.OrderByComparator"
123 });
124 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
125 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
126 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
128 new String[] { Long.class.getName() },
129 MBCategoryModelImpl.GROUPID_COLUMN_BITMASK);
130 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
131 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
133 new String[] { Long.class.getName() });
134 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
135 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
136 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
137 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
138 new String[] {
139 Long.class.getName(),
140
141 "java.lang.Integer", "java.lang.Integer",
142 "com.liferay.portal.kernel.util.OrderByComparator"
143 });
144 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
145 new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
146 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
147 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
148 new String[] { Long.class.getName() },
149 MBCategoryModelImpl.COMPANYID_COLUMN_BITMASK);
150 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
151 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
152 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
153 new String[] { Long.class.getName() });
154 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
155 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
156 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
157 new String[] {
158 Long.class.getName(), Long.class.getName(),
159
160 "java.lang.Integer", "java.lang.Integer",
161 "com.liferay.portal.kernel.util.OrderByComparator"
162 });
163 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
164 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
165 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
166 new String[] { Long.class.getName(), Long.class.getName() },
167 MBCategoryModelImpl.GROUPID_COLUMN_BITMASK |
168 MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK);
169 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
170 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
171 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
172 new String[] { Long.class.getName(), Long.class.getName() });
173 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
174 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
175 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_P",
176 new String[] { Long.class.getName(), Long.class.getName() });
177 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
178 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
179 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
180 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
181 MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class,
182 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
183 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
184 MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
185 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
186
187
192 public void cacheResult(MBCategory mbCategory) {
193 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
194 MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory);
195
196 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
197 new Object[] {
198 mbCategory.getUuid(), Long.valueOf(mbCategory.getGroupId())
199 }, mbCategory);
200
201 mbCategory.resetOriginalValues();
202 }
203
204
209 public void cacheResult(List<MBCategory> mbCategories) {
210 for (MBCategory mbCategory : mbCategories) {
211 if (EntityCacheUtil.getResult(
212 MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
213 MBCategoryImpl.class, mbCategory.getPrimaryKey()) == null) {
214 cacheResult(mbCategory);
215 }
216 else {
217 mbCategory.resetOriginalValues();
218 }
219 }
220 }
221
222
229 @Override
230 public void clearCache() {
231 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
232 CacheRegistryUtil.clear(MBCategoryImpl.class.getName());
233 }
234
235 EntityCacheUtil.clearCache(MBCategoryImpl.class.getName());
236
237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
238 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
239 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
240 }
241
242
249 @Override
250 public void clearCache(MBCategory mbCategory) {
251 EntityCacheUtil.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
252 MBCategoryImpl.class, mbCategory.getPrimaryKey());
253
254 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
255 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
256
257 clearUniqueFindersCache(mbCategory);
258 }
259
260 @Override
261 public void clearCache(List<MBCategory> mbCategories) {
262 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
264
265 for (MBCategory mbCategory : mbCategories) {
266 EntityCacheUtil.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
267 MBCategoryImpl.class, mbCategory.getPrimaryKey());
268
269 clearUniqueFindersCache(mbCategory);
270 }
271 }
272
273 protected void clearUniqueFindersCache(MBCategory mbCategory) {
274 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
275 new Object[] {
276 mbCategory.getUuid(), Long.valueOf(mbCategory.getGroupId())
277 });
278 }
279
280
286 public MBCategory create(long categoryId) {
287 MBCategory mbCategory = new MBCategoryImpl();
288
289 mbCategory.setNew(true);
290 mbCategory.setPrimaryKey(categoryId);
291
292 String uuid = PortalUUIDUtil.generate();
293
294 mbCategory.setUuid(uuid);
295
296 return mbCategory;
297 }
298
299
307 public MBCategory remove(long categoryId)
308 throws NoSuchCategoryException, SystemException {
309 return remove(Long.valueOf(categoryId));
310 }
311
312
320 @Override
321 public MBCategory remove(Serializable primaryKey)
322 throws NoSuchCategoryException, SystemException {
323 Session session = null;
324
325 try {
326 session = openSession();
327
328 MBCategory mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
329 primaryKey);
330
331 if (mbCategory == null) {
332 if (_log.isWarnEnabled()) {
333 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
334 }
335
336 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
337 primaryKey);
338 }
339
340 return remove(mbCategory);
341 }
342 catch (NoSuchCategoryException nsee) {
343 throw nsee;
344 }
345 catch (Exception e) {
346 throw processException(e);
347 }
348 finally {
349 closeSession(session);
350 }
351 }
352
353 @Override
354 protected MBCategory removeImpl(MBCategory mbCategory)
355 throws SystemException {
356 mbCategory = toUnwrappedModel(mbCategory);
357
358 Session session = null;
359
360 try {
361 session = openSession();
362
363 BatchSessionUtil.delete(session, mbCategory);
364 }
365 catch (Exception e) {
366 throw processException(e);
367 }
368 finally {
369 closeSession(session);
370 }
371
372 clearCache(mbCategory);
373
374 return mbCategory;
375 }
376
377 @Override
378 public MBCategory updateImpl(
379 com.liferay.portlet.messageboards.model.MBCategory mbCategory,
380 boolean merge) throws SystemException {
381 mbCategory = toUnwrappedModel(mbCategory);
382
383 boolean isNew = mbCategory.isNew();
384
385 MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory;
386
387 if (Validator.isNull(mbCategory.getUuid())) {
388 String uuid = PortalUUIDUtil.generate();
389
390 mbCategory.setUuid(uuid);
391 }
392
393 Session session = null;
394
395 try {
396 session = openSession();
397
398 BatchSessionUtil.update(session, mbCategory, merge);
399
400 mbCategory.setNew(false);
401 }
402 catch (Exception e) {
403 throw processException(e);
404 }
405 finally {
406 closeSession(session);
407 }
408
409 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
410
411 if (isNew || !MBCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
412 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
413 }
414
415 else {
416 if ((mbCategoryModelImpl.getColumnBitmask() &
417 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
418 Object[] args = new Object[] {
419 mbCategoryModelImpl.getOriginalUuid()
420 };
421
422 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
423 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
424 args);
425
426 args = new Object[] { mbCategoryModelImpl.getUuid() };
427
428 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
429 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
430 args);
431 }
432
433 if ((mbCategoryModelImpl.getColumnBitmask() &
434 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
435 Object[] args = new Object[] {
436 Long.valueOf(mbCategoryModelImpl.getOriginalGroupId())
437 };
438
439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
440 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
441 args);
442
443 args = new Object[] {
444 Long.valueOf(mbCategoryModelImpl.getGroupId())
445 };
446
447 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
448 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
449 args);
450 }
451
452 if ((mbCategoryModelImpl.getColumnBitmask() &
453 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
454 Object[] args = new Object[] {
455 Long.valueOf(mbCategoryModelImpl.getOriginalCompanyId())
456 };
457
458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
459 args);
460 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
461 args);
462
463 args = new Object[] {
464 Long.valueOf(mbCategoryModelImpl.getCompanyId())
465 };
466
467 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
468 args);
469 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
470 args);
471 }
472
473 if ((mbCategoryModelImpl.getColumnBitmask() &
474 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
475 Object[] args = new Object[] {
476 Long.valueOf(mbCategoryModelImpl.getOriginalGroupId()),
477 Long.valueOf(mbCategoryModelImpl.getOriginalParentCategoryId())
478 };
479
480 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
481 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
482 args);
483
484 args = new Object[] {
485 Long.valueOf(mbCategoryModelImpl.getGroupId()),
486 Long.valueOf(mbCategoryModelImpl.getParentCategoryId())
487 };
488
489 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
490 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
491 args);
492 }
493 }
494
495 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
496 MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory);
497
498 if (isNew) {
499 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
500 new Object[] {
501 mbCategory.getUuid(), Long.valueOf(mbCategory.getGroupId())
502 }, mbCategory);
503 }
504 else {
505 if ((mbCategoryModelImpl.getColumnBitmask() &
506 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
507 Object[] args = new Object[] {
508 mbCategoryModelImpl.getOriginalUuid(),
509 Long.valueOf(mbCategoryModelImpl.getOriginalGroupId())
510 };
511
512 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
513
514 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
515
516 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
517 new Object[] {
518 mbCategory.getUuid(),
519 Long.valueOf(mbCategory.getGroupId())
520 }, mbCategory);
521 }
522 }
523
524 return mbCategory;
525 }
526
527 protected MBCategory toUnwrappedModel(MBCategory mbCategory) {
528 if (mbCategory instanceof MBCategoryImpl) {
529 return mbCategory;
530 }
531
532 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
533
534 mbCategoryImpl.setNew(mbCategory.isNew());
535 mbCategoryImpl.setPrimaryKey(mbCategory.getPrimaryKey());
536
537 mbCategoryImpl.setUuid(mbCategory.getUuid());
538 mbCategoryImpl.setCategoryId(mbCategory.getCategoryId());
539 mbCategoryImpl.setGroupId(mbCategory.getGroupId());
540 mbCategoryImpl.setCompanyId(mbCategory.getCompanyId());
541 mbCategoryImpl.setUserId(mbCategory.getUserId());
542 mbCategoryImpl.setUserName(mbCategory.getUserName());
543 mbCategoryImpl.setCreateDate(mbCategory.getCreateDate());
544 mbCategoryImpl.setModifiedDate(mbCategory.getModifiedDate());
545 mbCategoryImpl.setParentCategoryId(mbCategory.getParentCategoryId());
546 mbCategoryImpl.setName(mbCategory.getName());
547 mbCategoryImpl.setDescription(mbCategory.getDescription());
548 mbCategoryImpl.setDisplayStyle(mbCategory.getDisplayStyle());
549 mbCategoryImpl.setThreadCount(mbCategory.getThreadCount());
550 mbCategoryImpl.setMessageCount(mbCategory.getMessageCount());
551 mbCategoryImpl.setLastPostDate(mbCategory.getLastPostDate());
552
553 return mbCategoryImpl;
554 }
555
556
564 @Override
565 public MBCategory findByPrimaryKey(Serializable primaryKey)
566 throws NoSuchModelException, SystemException {
567 return findByPrimaryKey(((Long)primaryKey).longValue());
568 }
569
570
578 public MBCategory findByPrimaryKey(long categoryId)
579 throws NoSuchCategoryException, SystemException {
580 MBCategory mbCategory = fetchByPrimaryKey(categoryId);
581
582 if (mbCategory == null) {
583 if (_log.isWarnEnabled()) {
584 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
585 }
586
587 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
588 categoryId);
589 }
590
591 return mbCategory;
592 }
593
594
601 @Override
602 public MBCategory fetchByPrimaryKey(Serializable primaryKey)
603 throws SystemException {
604 return fetchByPrimaryKey(((Long)primaryKey).longValue());
605 }
606
607
614 public MBCategory fetchByPrimaryKey(long categoryId)
615 throws SystemException {
616 MBCategory mbCategory = (MBCategory)EntityCacheUtil.getResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
617 MBCategoryImpl.class, categoryId);
618
619 if (mbCategory == _nullMBCategory) {
620 return null;
621 }
622
623 if (mbCategory == null) {
624 Session session = null;
625
626 boolean hasException = false;
627
628 try {
629 session = openSession();
630
631 mbCategory = (MBCategory)session.get(MBCategoryImpl.class,
632 Long.valueOf(categoryId));
633 }
634 catch (Exception e) {
635 hasException = true;
636
637 throw processException(e);
638 }
639 finally {
640 if (mbCategory != null) {
641 cacheResult(mbCategory);
642 }
643 else if (!hasException) {
644 EntityCacheUtil.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED,
645 MBCategoryImpl.class, categoryId, _nullMBCategory);
646 }
647
648 closeSession(session);
649 }
650 }
651
652 return mbCategory;
653 }
654
655
662 public List<MBCategory> findByUuid(String uuid) throws SystemException {
663 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
664 }
665
666
679 public List<MBCategory> findByUuid(String uuid, int start, int end)
680 throws SystemException {
681 return findByUuid(uuid, start, end, null);
682 }
683
684
698 public List<MBCategory> findByUuid(String uuid, int start, int end,
699 OrderByComparator orderByComparator) throws SystemException {
700 FinderPath finderPath = null;
701 Object[] finderArgs = null;
702
703 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
704 (orderByComparator == null)) {
705 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
706 finderArgs = new Object[] { uuid };
707 }
708 else {
709 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
710 finderArgs = new Object[] { uuid, start, end, orderByComparator };
711 }
712
713 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
714 finderArgs, this);
715
716 if ((list != null) && !list.isEmpty()) {
717 for (MBCategory mbCategory : list) {
718 if (!Validator.equals(uuid, mbCategory.getUuid())) {
719 list = null;
720
721 break;
722 }
723 }
724 }
725
726 if (list == null) {
727 StringBundler query = null;
728
729 if (orderByComparator != null) {
730 query = new StringBundler(3 +
731 (orderByComparator.getOrderByFields().length * 3));
732 }
733 else {
734 query = new StringBundler(3);
735 }
736
737 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
738
739 if (uuid == null) {
740 query.append(_FINDER_COLUMN_UUID_UUID_1);
741 }
742 else {
743 if (uuid.equals(StringPool.BLANK)) {
744 query.append(_FINDER_COLUMN_UUID_UUID_3);
745 }
746 else {
747 query.append(_FINDER_COLUMN_UUID_UUID_2);
748 }
749 }
750
751 if (orderByComparator != null) {
752 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
753 orderByComparator);
754 }
755
756 else {
757 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
758 }
759
760 String sql = query.toString();
761
762 Session session = null;
763
764 try {
765 session = openSession();
766
767 Query q = session.createQuery(sql);
768
769 QueryPos qPos = QueryPos.getInstance(q);
770
771 if (uuid != null) {
772 qPos.add(uuid);
773 }
774
775 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
776 end);
777 }
778 catch (Exception e) {
779 throw processException(e);
780 }
781 finally {
782 if (list == null) {
783 FinderCacheUtil.removeResult(finderPath, finderArgs);
784 }
785 else {
786 cacheResult(list);
787
788 FinderCacheUtil.putResult(finderPath, finderArgs, list);
789 }
790
791 closeSession(session);
792 }
793 }
794
795 return list;
796 }
797
798
807 public MBCategory findByUuid_First(String uuid,
808 OrderByComparator orderByComparator)
809 throws NoSuchCategoryException, SystemException {
810 MBCategory mbCategory = fetchByUuid_First(uuid, orderByComparator);
811
812 if (mbCategory != null) {
813 return mbCategory;
814 }
815
816 StringBundler msg = new StringBundler(4);
817
818 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
819
820 msg.append("uuid=");
821 msg.append(uuid);
822
823 msg.append(StringPool.CLOSE_CURLY_BRACE);
824
825 throw new NoSuchCategoryException(msg.toString());
826 }
827
828
836 public MBCategory fetchByUuid_First(String uuid,
837 OrderByComparator orderByComparator) throws SystemException {
838 List<MBCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
839
840 if (!list.isEmpty()) {
841 return list.get(0);
842 }
843
844 return null;
845 }
846
847
856 public MBCategory findByUuid_Last(String uuid,
857 OrderByComparator orderByComparator)
858 throws NoSuchCategoryException, SystemException {
859 MBCategory mbCategory = fetchByUuid_Last(uuid, orderByComparator);
860
861 if (mbCategory != null) {
862 return mbCategory;
863 }
864
865 StringBundler msg = new StringBundler(4);
866
867 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
868
869 msg.append("uuid=");
870 msg.append(uuid);
871
872 msg.append(StringPool.CLOSE_CURLY_BRACE);
873
874 throw new NoSuchCategoryException(msg.toString());
875 }
876
877
885 public MBCategory fetchByUuid_Last(String uuid,
886 OrderByComparator orderByComparator) throws SystemException {
887 int count = countByUuid(uuid);
888
889 List<MBCategory> list = findByUuid(uuid, count - 1, count,
890 orderByComparator);
891
892 if (!list.isEmpty()) {
893 return list.get(0);
894 }
895
896 return null;
897 }
898
899
909 public MBCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
910 OrderByComparator orderByComparator)
911 throws NoSuchCategoryException, SystemException {
912 MBCategory mbCategory = findByPrimaryKey(categoryId);
913
914 Session session = null;
915
916 try {
917 session = openSession();
918
919 MBCategory[] array = new MBCategoryImpl[3];
920
921 array[0] = getByUuid_PrevAndNext(session, mbCategory, uuid,
922 orderByComparator, true);
923
924 array[1] = mbCategory;
925
926 array[2] = getByUuid_PrevAndNext(session, mbCategory, uuid,
927 orderByComparator, false);
928
929 return array;
930 }
931 catch (Exception e) {
932 throw processException(e);
933 }
934 finally {
935 closeSession(session);
936 }
937 }
938
939 protected MBCategory getByUuid_PrevAndNext(Session session,
940 MBCategory mbCategory, String uuid,
941 OrderByComparator orderByComparator, boolean previous) {
942 StringBundler query = null;
943
944 if (orderByComparator != null) {
945 query = new StringBundler(6 +
946 (orderByComparator.getOrderByFields().length * 6));
947 }
948 else {
949 query = new StringBundler(3);
950 }
951
952 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
953
954 if (uuid == null) {
955 query.append(_FINDER_COLUMN_UUID_UUID_1);
956 }
957 else {
958 if (uuid.equals(StringPool.BLANK)) {
959 query.append(_FINDER_COLUMN_UUID_UUID_3);
960 }
961 else {
962 query.append(_FINDER_COLUMN_UUID_UUID_2);
963 }
964 }
965
966 if (orderByComparator != null) {
967 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
968
969 if (orderByConditionFields.length > 0) {
970 query.append(WHERE_AND);
971 }
972
973 for (int i = 0; i < orderByConditionFields.length; i++) {
974 query.append(_ORDER_BY_ENTITY_ALIAS);
975 query.append(orderByConditionFields[i]);
976
977 if ((i + 1) < orderByConditionFields.length) {
978 if (orderByComparator.isAscending() ^ previous) {
979 query.append(WHERE_GREATER_THAN_HAS_NEXT);
980 }
981 else {
982 query.append(WHERE_LESSER_THAN_HAS_NEXT);
983 }
984 }
985 else {
986 if (orderByComparator.isAscending() ^ previous) {
987 query.append(WHERE_GREATER_THAN);
988 }
989 else {
990 query.append(WHERE_LESSER_THAN);
991 }
992 }
993 }
994
995 query.append(ORDER_BY_CLAUSE);
996
997 String[] orderByFields = orderByComparator.getOrderByFields();
998
999 for (int i = 0; i < orderByFields.length; i++) {
1000 query.append(_ORDER_BY_ENTITY_ALIAS);
1001 query.append(orderByFields[i]);
1002
1003 if ((i + 1) < orderByFields.length) {
1004 if (orderByComparator.isAscending() ^ previous) {
1005 query.append(ORDER_BY_ASC_HAS_NEXT);
1006 }
1007 else {
1008 query.append(ORDER_BY_DESC_HAS_NEXT);
1009 }
1010 }
1011 else {
1012 if (orderByComparator.isAscending() ^ previous) {
1013 query.append(ORDER_BY_ASC);
1014 }
1015 else {
1016 query.append(ORDER_BY_DESC);
1017 }
1018 }
1019 }
1020 }
1021
1022 else {
1023 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1024 }
1025
1026 String sql = query.toString();
1027
1028 Query q = session.createQuery(sql);
1029
1030 q.setFirstResult(0);
1031 q.setMaxResults(2);
1032
1033 QueryPos qPos = QueryPos.getInstance(q);
1034
1035 if (uuid != null) {
1036 qPos.add(uuid);
1037 }
1038
1039 if (orderByComparator != null) {
1040 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
1041
1042 for (Object value : values) {
1043 qPos.add(value);
1044 }
1045 }
1046
1047 List<MBCategory> list = q.list();
1048
1049 if (list.size() == 2) {
1050 return list.get(1);
1051 }
1052 else {
1053 return null;
1054 }
1055 }
1056
1057
1066 public MBCategory findByUUID_G(String uuid, long groupId)
1067 throws NoSuchCategoryException, SystemException {
1068 MBCategory mbCategory = fetchByUUID_G(uuid, groupId);
1069
1070 if (mbCategory == null) {
1071 StringBundler msg = new StringBundler(6);
1072
1073 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1074
1075 msg.append("uuid=");
1076 msg.append(uuid);
1077
1078 msg.append(", groupId=");
1079 msg.append(groupId);
1080
1081 msg.append(StringPool.CLOSE_CURLY_BRACE);
1082
1083 if (_log.isWarnEnabled()) {
1084 _log.warn(msg.toString());
1085 }
1086
1087 throw new NoSuchCategoryException(msg.toString());
1088 }
1089
1090 return mbCategory;
1091 }
1092
1093
1101 public MBCategory fetchByUUID_G(String uuid, long groupId)
1102 throws SystemException {
1103 return fetchByUUID_G(uuid, groupId, true);
1104 }
1105
1106
1115 public MBCategory fetchByUUID_G(String uuid, long groupId,
1116 boolean retrieveFromCache) throws SystemException {
1117 Object[] finderArgs = new Object[] { uuid, groupId };
1118
1119 Object result = null;
1120
1121 if (retrieveFromCache) {
1122 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1123 finderArgs, this);
1124 }
1125
1126 if (result instanceof MBCategory) {
1127 MBCategory mbCategory = (MBCategory)result;
1128
1129 if (!Validator.equals(uuid, mbCategory.getUuid()) ||
1130 (groupId != mbCategory.getGroupId())) {
1131 result = null;
1132 }
1133 }
1134
1135 if (result == null) {
1136 StringBundler query = new StringBundler(4);
1137
1138 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1139
1140 if (uuid == null) {
1141 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1142 }
1143 else {
1144 if (uuid.equals(StringPool.BLANK)) {
1145 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1146 }
1147 else {
1148 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1149 }
1150 }
1151
1152 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1153
1154 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1155
1156 String sql = query.toString();
1157
1158 Session session = null;
1159
1160 try {
1161 session = openSession();
1162
1163 Query q = session.createQuery(sql);
1164
1165 QueryPos qPos = QueryPos.getInstance(q);
1166
1167 if (uuid != null) {
1168 qPos.add(uuid);
1169 }
1170
1171 qPos.add(groupId);
1172
1173 List<MBCategory> list = q.list();
1174
1175 result = list;
1176
1177 MBCategory mbCategory = null;
1178
1179 if (list.isEmpty()) {
1180 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1181 finderArgs, list);
1182 }
1183 else {
1184 mbCategory = list.get(0);
1185
1186 cacheResult(mbCategory);
1187
1188 if ((mbCategory.getUuid() == null) ||
1189 !mbCategory.getUuid().equals(uuid) ||
1190 (mbCategory.getGroupId() != groupId)) {
1191 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1192 finderArgs, mbCategory);
1193 }
1194 }
1195
1196 return mbCategory;
1197 }
1198 catch (Exception e) {
1199 throw processException(e);
1200 }
1201 finally {
1202 if (result == null) {
1203 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1204 finderArgs);
1205 }
1206
1207 closeSession(session);
1208 }
1209 }
1210 else {
1211 if (result instanceof List<?>) {
1212 return null;
1213 }
1214 else {
1215 return (MBCategory)result;
1216 }
1217 }
1218 }
1219
1220
1227 public List<MBCategory> findByGroupId(long groupId)
1228 throws SystemException {
1229 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1230 }
1231
1232
1245 public List<MBCategory> findByGroupId(long groupId, int start, int end)
1246 throws SystemException {
1247 return findByGroupId(groupId, start, end, null);
1248 }
1249
1250
1264 public List<MBCategory> findByGroupId(long groupId, int start, int end,
1265 OrderByComparator orderByComparator) throws SystemException {
1266 FinderPath finderPath = null;
1267 Object[] finderArgs = null;
1268
1269 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1270 (orderByComparator == null)) {
1271 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1272 finderArgs = new Object[] { groupId };
1273 }
1274 else {
1275 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1276 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1277 }
1278
1279 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
1280 finderArgs, this);
1281
1282 if ((list != null) && !list.isEmpty()) {
1283 for (MBCategory mbCategory : list) {
1284 if ((groupId != mbCategory.getGroupId())) {
1285 list = null;
1286
1287 break;
1288 }
1289 }
1290 }
1291
1292 if (list == null) {
1293 StringBundler query = null;
1294
1295 if (orderByComparator != null) {
1296 query = new StringBundler(3 +
1297 (orderByComparator.getOrderByFields().length * 3));
1298 }
1299 else {
1300 query = new StringBundler(3);
1301 }
1302
1303 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1304
1305 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1306
1307 if (orderByComparator != null) {
1308 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1309 orderByComparator);
1310 }
1311
1312 else {
1313 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1314 }
1315
1316 String sql = query.toString();
1317
1318 Session session = null;
1319
1320 try {
1321 session = openSession();
1322
1323 Query q = session.createQuery(sql);
1324
1325 QueryPos qPos = QueryPos.getInstance(q);
1326
1327 qPos.add(groupId);
1328
1329 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
1330 end);
1331 }
1332 catch (Exception e) {
1333 throw processException(e);
1334 }
1335 finally {
1336 if (list == null) {
1337 FinderCacheUtil.removeResult(finderPath, finderArgs);
1338 }
1339 else {
1340 cacheResult(list);
1341
1342 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1343 }
1344
1345 closeSession(session);
1346 }
1347 }
1348
1349 return list;
1350 }
1351
1352
1361 public MBCategory findByGroupId_First(long groupId,
1362 OrderByComparator orderByComparator)
1363 throws NoSuchCategoryException, SystemException {
1364 MBCategory mbCategory = fetchByGroupId_First(groupId, orderByComparator);
1365
1366 if (mbCategory != null) {
1367 return mbCategory;
1368 }
1369
1370 StringBundler msg = new StringBundler(4);
1371
1372 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1373
1374 msg.append("groupId=");
1375 msg.append(groupId);
1376
1377 msg.append(StringPool.CLOSE_CURLY_BRACE);
1378
1379 throw new NoSuchCategoryException(msg.toString());
1380 }
1381
1382
1390 public MBCategory fetchByGroupId_First(long groupId,
1391 OrderByComparator orderByComparator) throws SystemException {
1392 List<MBCategory> list = findByGroupId(groupId, 0, 1, orderByComparator);
1393
1394 if (!list.isEmpty()) {
1395 return list.get(0);
1396 }
1397
1398 return null;
1399 }
1400
1401
1410 public MBCategory findByGroupId_Last(long groupId,
1411 OrderByComparator orderByComparator)
1412 throws NoSuchCategoryException, SystemException {
1413 MBCategory mbCategory = fetchByGroupId_Last(groupId, orderByComparator);
1414
1415 if (mbCategory != null) {
1416 return mbCategory;
1417 }
1418
1419 StringBundler msg = new StringBundler(4);
1420
1421 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1422
1423 msg.append("groupId=");
1424 msg.append(groupId);
1425
1426 msg.append(StringPool.CLOSE_CURLY_BRACE);
1427
1428 throw new NoSuchCategoryException(msg.toString());
1429 }
1430
1431
1439 public MBCategory fetchByGroupId_Last(long groupId,
1440 OrderByComparator orderByComparator) throws SystemException {
1441 int count = countByGroupId(groupId);
1442
1443 List<MBCategory> list = findByGroupId(groupId, count - 1, count,
1444 orderByComparator);
1445
1446 if (!list.isEmpty()) {
1447 return list.get(0);
1448 }
1449
1450 return null;
1451 }
1452
1453
1463 public MBCategory[] findByGroupId_PrevAndNext(long categoryId,
1464 long groupId, OrderByComparator orderByComparator)
1465 throws NoSuchCategoryException, SystemException {
1466 MBCategory mbCategory = findByPrimaryKey(categoryId);
1467
1468 Session session = null;
1469
1470 try {
1471 session = openSession();
1472
1473 MBCategory[] array = new MBCategoryImpl[3];
1474
1475 array[0] = getByGroupId_PrevAndNext(session, mbCategory, groupId,
1476 orderByComparator, true);
1477
1478 array[1] = mbCategory;
1479
1480 array[2] = getByGroupId_PrevAndNext(session, mbCategory, groupId,
1481 orderByComparator, false);
1482
1483 return array;
1484 }
1485 catch (Exception e) {
1486 throw processException(e);
1487 }
1488 finally {
1489 closeSession(session);
1490 }
1491 }
1492
1493 protected MBCategory getByGroupId_PrevAndNext(Session session,
1494 MBCategory mbCategory, long groupId,
1495 OrderByComparator orderByComparator, boolean previous) {
1496 StringBundler query = null;
1497
1498 if (orderByComparator != null) {
1499 query = new StringBundler(6 +
1500 (orderByComparator.getOrderByFields().length * 6));
1501 }
1502 else {
1503 query = new StringBundler(3);
1504 }
1505
1506 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1507
1508 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1509
1510 if (orderByComparator != null) {
1511 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1512
1513 if (orderByConditionFields.length > 0) {
1514 query.append(WHERE_AND);
1515 }
1516
1517 for (int i = 0; i < orderByConditionFields.length; i++) {
1518 query.append(_ORDER_BY_ENTITY_ALIAS);
1519 query.append(orderByConditionFields[i]);
1520
1521 if ((i + 1) < orderByConditionFields.length) {
1522 if (orderByComparator.isAscending() ^ previous) {
1523 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1524 }
1525 else {
1526 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1527 }
1528 }
1529 else {
1530 if (orderByComparator.isAscending() ^ previous) {
1531 query.append(WHERE_GREATER_THAN);
1532 }
1533 else {
1534 query.append(WHERE_LESSER_THAN);
1535 }
1536 }
1537 }
1538
1539 query.append(ORDER_BY_CLAUSE);
1540
1541 String[] orderByFields = orderByComparator.getOrderByFields();
1542
1543 for (int i = 0; i < orderByFields.length; i++) {
1544 query.append(_ORDER_BY_ENTITY_ALIAS);
1545 query.append(orderByFields[i]);
1546
1547 if ((i + 1) < orderByFields.length) {
1548 if (orderByComparator.isAscending() ^ previous) {
1549 query.append(ORDER_BY_ASC_HAS_NEXT);
1550 }
1551 else {
1552 query.append(ORDER_BY_DESC_HAS_NEXT);
1553 }
1554 }
1555 else {
1556 if (orderByComparator.isAscending() ^ previous) {
1557 query.append(ORDER_BY_ASC);
1558 }
1559 else {
1560 query.append(ORDER_BY_DESC);
1561 }
1562 }
1563 }
1564 }
1565
1566 else {
1567 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1568 }
1569
1570 String sql = query.toString();
1571
1572 Query q = session.createQuery(sql);
1573
1574 q.setFirstResult(0);
1575 q.setMaxResults(2);
1576
1577 QueryPos qPos = QueryPos.getInstance(q);
1578
1579 qPos.add(groupId);
1580
1581 if (orderByComparator != null) {
1582 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
1583
1584 for (Object value : values) {
1585 qPos.add(value);
1586 }
1587 }
1588
1589 List<MBCategory> list = q.list();
1590
1591 if (list.size() == 2) {
1592 return list.get(1);
1593 }
1594 else {
1595 return null;
1596 }
1597 }
1598
1599
1606 public List<MBCategory> filterFindByGroupId(long groupId)
1607 throws SystemException {
1608 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1609 QueryUtil.ALL_POS, null);
1610 }
1611
1612
1625 public List<MBCategory> filterFindByGroupId(long groupId, int start, int end)
1626 throws SystemException {
1627 return filterFindByGroupId(groupId, start, end, null);
1628 }
1629
1630
1644 public List<MBCategory> filterFindByGroupId(long groupId, int start,
1645 int end, OrderByComparator orderByComparator) throws SystemException {
1646 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1647 return findByGroupId(groupId, start, end, orderByComparator);
1648 }
1649
1650 StringBundler query = null;
1651
1652 if (orderByComparator != null) {
1653 query = new StringBundler(3 +
1654 (orderByComparator.getOrderByFields().length * 3));
1655 }
1656 else {
1657 query = new StringBundler(3);
1658 }
1659
1660 if (getDB().isSupportsInlineDistinct()) {
1661 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
1662 }
1663 else {
1664 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1665 }
1666
1667 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1668
1669 if (!getDB().isSupportsInlineDistinct()) {
1670 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1671 }
1672
1673 if (orderByComparator != null) {
1674 if (getDB().isSupportsInlineDistinct()) {
1675 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1676 orderByComparator);
1677 }
1678 else {
1679 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1680 orderByComparator);
1681 }
1682 }
1683
1684 else {
1685 if (getDB().isSupportsInlineDistinct()) {
1686 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1687 }
1688 else {
1689 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
1690 }
1691 }
1692
1693 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1694 MBCategory.class.getName(),
1695 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1696
1697 Session session = null;
1698
1699 try {
1700 session = openSession();
1701
1702 SQLQuery q = session.createSQLQuery(sql);
1703
1704 if (getDB().isSupportsInlineDistinct()) {
1705 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
1706 }
1707 else {
1708 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
1709 }
1710
1711 QueryPos qPos = QueryPos.getInstance(q);
1712
1713 qPos.add(groupId);
1714
1715 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
1716 }
1717 catch (Exception e) {
1718 throw processException(e);
1719 }
1720 finally {
1721 closeSession(session);
1722 }
1723 }
1724
1725
1735 public MBCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
1736 long groupId, OrderByComparator orderByComparator)
1737 throws NoSuchCategoryException, SystemException {
1738 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1739 return findByGroupId_PrevAndNext(categoryId, groupId,
1740 orderByComparator);
1741 }
1742
1743 MBCategory mbCategory = findByPrimaryKey(categoryId);
1744
1745 Session session = null;
1746
1747 try {
1748 session = openSession();
1749
1750 MBCategory[] array = new MBCategoryImpl[3];
1751
1752 array[0] = filterGetByGroupId_PrevAndNext(session, mbCategory,
1753 groupId, orderByComparator, true);
1754
1755 array[1] = mbCategory;
1756
1757 array[2] = filterGetByGroupId_PrevAndNext(session, mbCategory,
1758 groupId, orderByComparator, false);
1759
1760 return array;
1761 }
1762 catch (Exception e) {
1763 throw processException(e);
1764 }
1765 finally {
1766 closeSession(session);
1767 }
1768 }
1769
1770 protected MBCategory filterGetByGroupId_PrevAndNext(Session session,
1771 MBCategory mbCategory, long groupId,
1772 OrderByComparator orderByComparator, boolean previous) {
1773 StringBundler query = null;
1774
1775 if (orderByComparator != null) {
1776 query = new StringBundler(6 +
1777 (orderByComparator.getOrderByFields().length * 6));
1778 }
1779 else {
1780 query = new StringBundler(3);
1781 }
1782
1783 if (getDB().isSupportsInlineDistinct()) {
1784 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
1785 }
1786 else {
1787 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1788 }
1789
1790 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1791
1792 if (!getDB().isSupportsInlineDistinct()) {
1793 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1794 }
1795
1796 if (orderByComparator != null) {
1797 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1798
1799 if (orderByConditionFields.length > 0) {
1800 query.append(WHERE_AND);
1801 }
1802
1803 for (int i = 0; i < orderByConditionFields.length; i++) {
1804 if (getDB().isSupportsInlineDistinct()) {
1805 query.append(_ORDER_BY_ENTITY_ALIAS);
1806 }
1807 else {
1808 query.append(_ORDER_BY_ENTITY_TABLE);
1809 }
1810
1811 query.append(orderByConditionFields[i]);
1812
1813 if ((i + 1) < orderByConditionFields.length) {
1814 if (orderByComparator.isAscending() ^ previous) {
1815 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1816 }
1817 else {
1818 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1819 }
1820 }
1821 else {
1822 if (orderByComparator.isAscending() ^ previous) {
1823 query.append(WHERE_GREATER_THAN);
1824 }
1825 else {
1826 query.append(WHERE_LESSER_THAN);
1827 }
1828 }
1829 }
1830
1831 query.append(ORDER_BY_CLAUSE);
1832
1833 String[] orderByFields = orderByComparator.getOrderByFields();
1834
1835 for (int i = 0; i < orderByFields.length; i++) {
1836 if (getDB().isSupportsInlineDistinct()) {
1837 query.append(_ORDER_BY_ENTITY_ALIAS);
1838 }
1839 else {
1840 query.append(_ORDER_BY_ENTITY_TABLE);
1841 }
1842
1843 query.append(orderByFields[i]);
1844
1845 if ((i + 1) < orderByFields.length) {
1846 if (orderByComparator.isAscending() ^ previous) {
1847 query.append(ORDER_BY_ASC_HAS_NEXT);
1848 }
1849 else {
1850 query.append(ORDER_BY_DESC_HAS_NEXT);
1851 }
1852 }
1853 else {
1854 if (orderByComparator.isAscending() ^ previous) {
1855 query.append(ORDER_BY_ASC);
1856 }
1857 else {
1858 query.append(ORDER_BY_DESC);
1859 }
1860 }
1861 }
1862 }
1863
1864 else {
1865 if (getDB().isSupportsInlineDistinct()) {
1866 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
1867 }
1868 else {
1869 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
1870 }
1871 }
1872
1873 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1874 MBCategory.class.getName(),
1875 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1876
1877 SQLQuery q = session.createSQLQuery(sql);
1878
1879 q.setFirstResult(0);
1880 q.setMaxResults(2);
1881
1882 if (getDB().isSupportsInlineDistinct()) {
1883 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
1884 }
1885 else {
1886 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
1887 }
1888
1889 QueryPos qPos = QueryPos.getInstance(q);
1890
1891 qPos.add(groupId);
1892
1893 if (orderByComparator != null) {
1894 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
1895
1896 for (Object value : values) {
1897 qPos.add(value);
1898 }
1899 }
1900
1901 List<MBCategory> list = q.list();
1902
1903 if (list.size() == 2) {
1904 return list.get(1);
1905 }
1906 else {
1907 return null;
1908 }
1909 }
1910
1911
1918 public List<MBCategory> findByCompanyId(long companyId)
1919 throws SystemException {
1920 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1921 null);
1922 }
1923
1924
1937 public List<MBCategory> findByCompanyId(long companyId, int start, int end)
1938 throws SystemException {
1939 return findByCompanyId(companyId, start, end, null);
1940 }
1941
1942
1956 public List<MBCategory> findByCompanyId(long companyId, int start, int end,
1957 OrderByComparator orderByComparator) throws SystemException {
1958 FinderPath finderPath = null;
1959 Object[] finderArgs = null;
1960
1961 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1962 (orderByComparator == null)) {
1963 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1964 finderArgs = new Object[] { companyId };
1965 }
1966 else {
1967 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1968 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1969 }
1970
1971 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
1972 finderArgs, this);
1973
1974 if ((list != null) && !list.isEmpty()) {
1975 for (MBCategory mbCategory : list) {
1976 if ((companyId != mbCategory.getCompanyId())) {
1977 list = null;
1978
1979 break;
1980 }
1981 }
1982 }
1983
1984 if (list == null) {
1985 StringBundler query = null;
1986
1987 if (orderByComparator != null) {
1988 query = new StringBundler(3 +
1989 (orderByComparator.getOrderByFields().length * 3));
1990 }
1991 else {
1992 query = new StringBundler(3);
1993 }
1994
1995 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
1996
1997 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1998
1999 if (orderByComparator != null) {
2000 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2001 orderByComparator);
2002 }
2003
2004 else {
2005 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2006 }
2007
2008 String sql = query.toString();
2009
2010 Session session = null;
2011
2012 try {
2013 session = openSession();
2014
2015 Query q = session.createQuery(sql);
2016
2017 QueryPos qPos = QueryPos.getInstance(q);
2018
2019 qPos.add(companyId);
2020
2021 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
2022 end);
2023 }
2024 catch (Exception e) {
2025 throw processException(e);
2026 }
2027 finally {
2028 if (list == null) {
2029 FinderCacheUtil.removeResult(finderPath, finderArgs);
2030 }
2031 else {
2032 cacheResult(list);
2033
2034 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2035 }
2036
2037 closeSession(session);
2038 }
2039 }
2040
2041 return list;
2042 }
2043
2044
2053 public MBCategory findByCompanyId_First(long companyId,
2054 OrderByComparator orderByComparator)
2055 throws NoSuchCategoryException, SystemException {
2056 MBCategory mbCategory = fetchByCompanyId_First(companyId,
2057 orderByComparator);
2058
2059 if (mbCategory != null) {
2060 return mbCategory;
2061 }
2062
2063 StringBundler msg = new StringBundler(4);
2064
2065 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2066
2067 msg.append("companyId=");
2068 msg.append(companyId);
2069
2070 msg.append(StringPool.CLOSE_CURLY_BRACE);
2071
2072 throw new NoSuchCategoryException(msg.toString());
2073 }
2074
2075
2083 public MBCategory fetchByCompanyId_First(long companyId,
2084 OrderByComparator orderByComparator) throws SystemException {
2085 List<MBCategory> list = findByCompanyId(companyId, 0, 1,
2086 orderByComparator);
2087
2088 if (!list.isEmpty()) {
2089 return list.get(0);
2090 }
2091
2092 return null;
2093 }
2094
2095
2104 public MBCategory findByCompanyId_Last(long companyId,
2105 OrderByComparator orderByComparator)
2106 throws NoSuchCategoryException, SystemException {
2107 MBCategory mbCategory = fetchByCompanyId_Last(companyId,
2108 orderByComparator);
2109
2110 if (mbCategory != null) {
2111 return mbCategory;
2112 }
2113
2114 StringBundler msg = new StringBundler(4);
2115
2116 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2117
2118 msg.append("companyId=");
2119 msg.append(companyId);
2120
2121 msg.append(StringPool.CLOSE_CURLY_BRACE);
2122
2123 throw new NoSuchCategoryException(msg.toString());
2124 }
2125
2126
2134 public MBCategory fetchByCompanyId_Last(long companyId,
2135 OrderByComparator orderByComparator) throws SystemException {
2136 int count = countByCompanyId(companyId);
2137
2138 List<MBCategory> list = findByCompanyId(companyId, count - 1, count,
2139 orderByComparator);
2140
2141 if (!list.isEmpty()) {
2142 return list.get(0);
2143 }
2144
2145 return null;
2146 }
2147
2148
2158 public MBCategory[] findByCompanyId_PrevAndNext(long categoryId,
2159 long companyId, OrderByComparator orderByComparator)
2160 throws NoSuchCategoryException, SystemException {
2161 MBCategory mbCategory = findByPrimaryKey(categoryId);
2162
2163 Session session = null;
2164
2165 try {
2166 session = openSession();
2167
2168 MBCategory[] array = new MBCategoryImpl[3];
2169
2170 array[0] = getByCompanyId_PrevAndNext(session, mbCategory,
2171 companyId, orderByComparator, true);
2172
2173 array[1] = mbCategory;
2174
2175 array[2] = getByCompanyId_PrevAndNext(session, mbCategory,
2176 companyId, orderByComparator, false);
2177
2178 return array;
2179 }
2180 catch (Exception e) {
2181 throw processException(e);
2182 }
2183 finally {
2184 closeSession(session);
2185 }
2186 }
2187
2188 protected MBCategory getByCompanyId_PrevAndNext(Session session,
2189 MBCategory mbCategory, long companyId,
2190 OrderByComparator orderByComparator, boolean previous) {
2191 StringBundler query = null;
2192
2193 if (orderByComparator != null) {
2194 query = new StringBundler(6 +
2195 (orderByComparator.getOrderByFields().length * 6));
2196 }
2197 else {
2198 query = new StringBundler(3);
2199 }
2200
2201 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
2202
2203 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2204
2205 if (orderByComparator != null) {
2206 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2207
2208 if (orderByConditionFields.length > 0) {
2209 query.append(WHERE_AND);
2210 }
2211
2212 for (int i = 0; i < orderByConditionFields.length; i++) {
2213 query.append(_ORDER_BY_ENTITY_ALIAS);
2214 query.append(orderByConditionFields[i]);
2215
2216 if ((i + 1) < orderByConditionFields.length) {
2217 if (orderByComparator.isAscending() ^ previous) {
2218 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2219 }
2220 else {
2221 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2222 }
2223 }
2224 else {
2225 if (orderByComparator.isAscending() ^ previous) {
2226 query.append(WHERE_GREATER_THAN);
2227 }
2228 else {
2229 query.append(WHERE_LESSER_THAN);
2230 }
2231 }
2232 }
2233
2234 query.append(ORDER_BY_CLAUSE);
2235
2236 String[] orderByFields = orderByComparator.getOrderByFields();
2237
2238 for (int i = 0; i < orderByFields.length; i++) {
2239 query.append(_ORDER_BY_ENTITY_ALIAS);
2240 query.append(orderByFields[i]);
2241
2242 if ((i + 1) < orderByFields.length) {
2243 if (orderByComparator.isAscending() ^ previous) {
2244 query.append(ORDER_BY_ASC_HAS_NEXT);
2245 }
2246 else {
2247 query.append(ORDER_BY_DESC_HAS_NEXT);
2248 }
2249 }
2250 else {
2251 if (orderByComparator.isAscending() ^ previous) {
2252 query.append(ORDER_BY_ASC);
2253 }
2254 else {
2255 query.append(ORDER_BY_DESC);
2256 }
2257 }
2258 }
2259 }
2260
2261 else {
2262 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2263 }
2264
2265 String sql = query.toString();
2266
2267 Query q = session.createQuery(sql);
2268
2269 q.setFirstResult(0);
2270 q.setMaxResults(2);
2271
2272 QueryPos qPos = QueryPos.getInstance(q);
2273
2274 qPos.add(companyId);
2275
2276 if (orderByComparator != null) {
2277 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
2278
2279 for (Object value : values) {
2280 qPos.add(value);
2281 }
2282 }
2283
2284 List<MBCategory> list = q.list();
2285
2286 if (list.size() == 2) {
2287 return list.get(1);
2288 }
2289 else {
2290 return null;
2291 }
2292 }
2293
2294
2302 public List<MBCategory> findByG_P(long groupId, long parentCategoryId)
2303 throws SystemException {
2304 return findByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS,
2305 QueryUtil.ALL_POS, null);
2306 }
2307
2308
2322 public List<MBCategory> findByG_P(long groupId, long parentCategoryId,
2323 int start, int end) throws SystemException {
2324 return findByG_P(groupId, parentCategoryId, start, end, null);
2325 }
2326
2327
2342 public List<MBCategory> findByG_P(long groupId, long parentCategoryId,
2343 int start, int end, OrderByComparator orderByComparator)
2344 throws SystemException {
2345 FinderPath finderPath = null;
2346 Object[] finderArgs = null;
2347
2348 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2349 (orderByComparator == null)) {
2350 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
2351 finderArgs = new Object[] { groupId, parentCategoryId };
2352 }
2353 else {
2354 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
2355 finderArgs = new Object[] {
2356 groupId, parentCategoryId,
2357
2358 start, end, orderByComparator
2359 };
2360 }
2361
2362 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
2363 finderArgs, this);
2364
2365 if ((list != null) && !list.isEmpty()) {
2366 for (MBCategory mbCategory : list) {
2367 if ((groupId != mbCategory.getGroupId()) ||
2368 (parentCategoryId != mbCategory.getParentCategoryId())) {
2369 list = null;
2370
2371 break;
2372 }
2373 }
2374 }
2375
2376 if (list == null) {
2377 StringBundler query = null;
2378
2379 if (orderByComparator != null) {
2380 query = new StringBundler(4 +
2381 (orderByComparator.getOrderByFields().length * 3));
2382 }
2383 else {
2384 query = new StringBundler(4);
2385 }
2386
2387 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
2388
2389 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2390
2391 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
2392
2393 if (orderByComparator != null) {
2394 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2395 orderByComparator);
2396 }
2397
2398 else {
2399 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2400 }
2401
2402 String sql = query.toString();
2403
2404 Session session = null;
2405
2406 try {
2407 session = openSession();
2408
2409 Query q = session.createQuery(sql);
2410
2411 QueryPos qPos = QueryPos.getInstance(q);
2412
2413 qPos.add(groupId);
2414
2415 qPos.add(parentCategoryId);
2416
2417 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
2418 end);
2419 }
2420 catch (Exception e) {
2421 throw processException(e);
2422 }
2423 finally {
2424 if (list == null) {
2425 FinderCacheUtil.removeResult(finderPath, finderArgs);
2426 }
2427 else {
2428 cacheResult(list);
2429
2430 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2431 }
2432
2433 closeSession(session);
2434 }
2435 }
2436
2437 return list;
2438 }
2439
2440
2450 public MBCategory findByG_P_First(long groupId, long parentCategoryId,
2451 OrderByComparator orderByComparator)
2452 throws NoSuchCategoryException, SystemException {
2453 MBCategory mbCategory = fetchByG_P_First(groupId, parentCategoryId,
2454 orderByComparator);
2455
2456 if (mbCategory != null) {
2457 return mbCategory;
2458 }
2459
2460 StringBundler msg = new StringBundler(6);
2461
2462 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2463
2464 msg.append("groupId=");
2465 msg.append(groupId);
2466
2467 msg.append(", parentCategoryId=");
2468 msg.append(parentCategoryId);
2469
2470 msg.append(StringPool.CLOSE_CURLY_BRACE);
2471
2472 throw new NoSuchCategoryException(msg.toString());
2473 }
2474
2475
2484 public MBCategory fetchByG_P_First(long groupId, long parentCategoryId,
2485 OrderByComparator orderByComparator) throws SystemException {
2486 List<MBCategory> list = findByG_P(groupId, parentCategoryId, 0, 1,
2487 orderByComparator);
2488
2489 if (!list.isEmpty()) {
2490 return list.get(0);
2491 }
2492
2493 return null;
2494 }
2495
2496
2506 public MBCategory findByG_P_Last(long groupId, long parentCategoryId,
2507 OrderByComparator orderByComparator)
2508 throws NoSuchCategoryException, SystemException {
2509 MBCategory mbCategory = fetchByG_P_Last(groupId, parentCategoryId,
2510 orderByComparator);
2511
2512 if (mbCategory != null) {
2513 return mbCategory;
2514 }
2515
2516 StringBundler msg = new StringBundler(6);
2517
2518 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2519
2520 msg.append("groupId=");
2521 msg.append(groupId);
2522
2523 msg.append(", parentCategoryId=");
2524 msg.append(parentCategoryId);
2525
2526 msg.append(StringPool.CLOSE_CURLY_BRACE);
2527
2528 throw new NoSuchCategoryException(msg.toString());
2529 }
2530
2531
2540 public MBCategory fetchByG_P_Last(long groupId, long parentCategoryId,
2541 OrderByComparator orderByComparator) throws SystemException {
2542 int count = countByG_P(groupId, parentCategoryId);
2543
2544 List<MBCategory> list = findByG_P(groupId, parentCategoryId, count - 1,
2545 count, orderByComparator);
2546
2547 if (!list.isEmpty()) {
2548 return list.get(0);
2549 }
2550
2551 return null;
2552 }
2553
2554
2565 public MBCategory[] findByG_P_PrevAndNext(long categoryId, long groupId,
2566 long parentCategoryId, OrderByComparator orderByComparator)
2567 throws NoSuchCategoryException, SystemException {
2568 MBCategory mbCategory = findByPrimaryKey(categoryId);
2569
2570 Session session = null;
2571
2572 try {
2573 session = openSession();
2574
2575 MBCategory[] array = new MBCategoryImpl[3];
2576
2577 array[0] = getByG_P_PrevAndNext(session, mbCategory, groupId,
2578 parentCategoryId, orderByComparator, true);
2579
2580 array[1] = mbCategory;
2581
2582 array[2] = getByG_P_PrevAndNext(session, mbCategory, groupId,
2583 parentCategoryId, orderByComparator, false);
2584
2585 return array;
2586 }
2587 catch (Exception e) {
2588 throw processException(e);
2589 }
2590 finally {
2591 closeSession(session);
2592 }
2593 }
2594
2595 protected MBCategory getByG_P_PrevAndNext(Session session,
2596 MBCategory mbCategory, long groupId, long parentCategoryId,
2597 OrderByComparator orderByComparator, boolean previous) {
2598 StringBundler query = null;
2599
2600 if (orderByComparator != null) {
2601 query = new StringBundler(6 +
2602 (orderByComparator.getOrderByFields().length * 6));
2603 }
2604 else {
2605 query = new StringBundler(3);
2606 }
2607
2608 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
2609
2610 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2611
2612 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
2613
2614 if (orderByComparator != null) {
2615 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2616
2617 if (orderByConditionFields.length > 0) {
2618 query.append(WHERE_AND);
2619 }
2620
2621 for (int i = 0; i < orderByConditionFields.length; i++) {
2622 query.append(_ORDER_BY_ENTITY_ALIAS);
2623 query.append(orderByConditionFields[i]);
2624
2625 if ((i + 1) < orderByConditionFields.length) {
2626 if (orderByComparator.isAscending() ^ previous) {
2627 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2628 }
2629 else {
2630 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2631 }
2632 }
2633 else {
2634 if (orderByComparator.isAscending() ^ previous) {
2635 query.append(WHERE_GREATER_THAN);
2636 }
2637 else {
2638 query.append(WHERE_LESSER_THAN);
2639 }
2640 }
2641 }
2642
2643 query.append(ORDER_BY_CLAUSE);
2644
2645 String[] orderByFields = orderByComparator.getOrderByFields();
2646
2647 for (int i = 0; i < orderByFields.length; i++) {
2648 query.append(_ORDER_BY_ENTITY_ALIAS);
2649 query.append(orderByFields[i]);
2650
2651 if ((i + 1) < orderByFields.length) {
2652 if (orderByComparator.isAscending() ^ previous) {
2653 query.append(ORDER_BY_ASC_HAS_NEXT);
2654 }
2655 else {
2656 query.append(ORDER_BY_DESC_HAS_NEXT);
2657 }
2658 }
2659 else {
2660 if (orderByComparator.isAscending() ^ previous) {
2661 query.append(ORDER_BY_ASC);
2662 }
2663 else {
2664 query.append(ORDER_BY_DESC);
2665 }
2666 }
2667 }
2668 }
2669
2670 else {
2671 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2672 }
2673
2674 String sql = query.toString();
2675
2676 Query q = session.createQuery(sql);
2677
2678 q.setFirstResult(0);
2679 q.setMaxResults(2);
2680
2681 QueryPos qPos = QueryPos.getInstance(q);
2682
2683 qPos.add(groupId);
2684
2685 qPos.add(parentCategoryId);
2686
2687 if (orderByComparator != null) {
2688 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
2689
2690 for (Object value : values) {
2691 qPos.add(value);
2692 }
2693 }
2694
2695 List<MBCategory> list = q.list();
2696
2697 if (list.size() == 2) {
2698 return list.get(1);
2699 }
2700 else {
2701 return null;
2702 }
2703 }
2704
2705
2717 public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds)
2718 throws SystemException {
2719 return findByG_P(groupId, parentCategoryIds, QueryUtil.ALL_POS,
2720 QueryUtil.ALL_POS, null);
2721 }
2722
2723
2737 public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds,
2738 int start, int end) throws SystemException {
2739 return findByG_P(groupId, parentCategoryIds, start, end, null);
2740 }
2741
2742
2757 public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds,
2758 int start, int end, OrderByComparator orderByComparator)
2759 throws SystemException {
2760 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
2761 Object[] finderArgs = null;
2762
2763 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2764 (orderByComparator == null)) {
2765 finderArgs = new Object[] {
2766 groupId, StringUtil.merge(parentCategoryIds)
2767 };
2768 }
2769 else {
2770 finderArgs = new Object[] {
2771 groupId, StringUtil.merge(parentCategoryIds),
2772
2773 start, end, orderByComparator
2774 };
2775 }
2776
2777 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
2778 finderArgs, this);
2779
2780 if ((list != null) && !list.isEmpty()) {
2781 for (MBCategory mbCategory : list) {
2782 if ((groupId != mbCategory.getGroupId()) ||
2783 !ArrayUtil.contains(parentCategoryIds,
2784 mbCategory.getParentCategoryId())) {
2785 list = null;
2786
2787 break;
2788 }
2789 }
2790 }
2791
2792 if (list == null) {
2793 StringBundler query = new StringBundler();
2794
2795 query.append(_SQL_SELECT_MBCATEGORY_WHERE);
2796
2797 boolean conjunctionable = false;
2798
2799 if (conjunctionable) {
2800 query.append(WHERE_AND);
2801 }
2802
2803 query.append(_FINDER_COLUMN_G_P_GROUPID_5);
2804
2805 conjunctionable = true;
2806
2807 if ((parentCategoryIds == null) || (parentCategoryIds.length > 0)) {
2808 if (conjunctionable) {
2809 query.append(WHERE_AND);
2810 }
2811
2812 query.append(StringPool.OPEN_PARENTHESIS);
2813
2814 for (int i = 0; i < parentCategoryIds.length; i++) {
2815 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_5);
2816
2817 if ((i + 1) < parentCategoryIds.length) {
2818 query.append(WHERE_OR);
2819 }
2820 }
2821
2822 query.append(StringPool.CLOSE_PARENTHESIS);
2823
2824 conjunctionable = true;
2825 }
2826
2827 if (orderByComparator != null) {
2828 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2829 orderByComparator);
2830 }
2831
2832 else {
2833 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2834 }
2835
2836 String sql = query.toString();
2837
2838 Session session = null;
2839
2840 try {
2841 session = openSession();
2842
2843 Query q = session.createQuery(sql);
2844
2845 QueryPos qPos = QueryPos.getInstance(q);
2846
2847 qPos.add(groupId);
2848
2849 if (parentCategoryIds != null) {
2850 qPos.add(parentCategoryIds);
2851 }
2852
2853 list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start,
2854 end);
2855 }
2856 catch (Exception e) {
2857 throw processException(e);
2858 }
2859 finally {
2860 if (list == null) {
2861 FinderCacheUtil.removeResult(finderPath, finderArgs);
2862 }
2863 else {
2864 cacheResult(list);
2865
2866 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2867 }
2868
2869 closeSession(session);
2870 }
2871 }
2872
2873 return list;
2874 }
2875
2876
2884 public List<MBCategory> filterFindByG_P(long groupId, long parentCategoryId)
2885 throws SystemException {
2886 return filterFindByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS,
2887 QueryUtil.ALL_POS, null);
2888 }
2889
2890
2904 public List<MBCategory> filterFindByG_P(long groupId,
2905 long parentCategoryId, int start, int end) throws SystemException {
2906 return filterFindByG_P(groupId, parentCategoryId, start, end, null);
2907 }
2908
2909
2924 public List<MBCategory> filterFindByG_P(long groupId,
2925 long parentCategoryId, int start, int end,
2926 OrderByComparator orderByComparator) throws SystemException {
2927 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2928 return findByG_P(groupId, parentCategoryId, start, end,
2929 orderByComparator);
2930 }
2931
2932 StringBundler query = null;
2933
2934 if (orderByComparator != null) {
2935 query = new StringBundler(4 +
2936 (orderByComparator.getOrderByFields().length * 3));
2937 }
2938 else {
2939 query = new StringBundler(4);
2940 }
2941
2942 if (getDB().isSupportsInlineDistinct()) {
2943 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
2944 }
2945 else {
2946 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2947 }
2948
2949 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2950
2951 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
2952
2953 if (!getDB().isSupportsInlineDistinct()) {
2954 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2955 }
2956
2957 if (orderByComparator != null) {
2958 if (getDB().isSupportsInlineDistinct()) {
2959 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2960 orderByComparator);
2961 }
2962 else {
2963 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2964 orderByComparator);
2965 }
2966 }
2967
2968 else {
2969 if (getDB().isSupportsInlineDistinct()) {
2970 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
2971 }
2972 else {
2973 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
2974 }
2975 }
2976
2977 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2978 MBCategory.class.getName(),
2979 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2980
2981 Session session = null;
2982
2983 try {
2984 session = openSession();
2985
2986 SQLQuery q = session.createSQLQuery(sql);
2987
2988 if (getDB().isSupportsInlineDistinct()) {
2989 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
2990 }
2991 else {
2992 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
2993 }
2994
2995 QueryPos qPos = QueryPos.getInstance(q);
2996
2997 qPos.add(groupId);
2998
2999 qPos.add(parentCategoryId);
3000
3001 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
3002 }
3003 catch (Exception e) {
3004 throw processException(e);
3005 }
3006 finally {
3007 closeSession(session);
3008 }
3009 }
3010
3011
3022 public MBCategory[] filterFindByG_P_PrevAndNext(long categoryId,
3023 long groupId, long parentCategoryId, OrderByComparator orderByComparator)
3024 throws NoSuchCategoryException, SystemException {
3025 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3026 return findByG_P_PrevAndNext(categoryId, groupId, parentCategoryId,
3027 orderByComparator);
3028 }
3029
3030 MBCategory mbCategory = findByPrimaryKey(categoryId);
3031
3032 Session session = null;
3033
3034 try {
3035 session = openSession();
3036
3037 MBCategory[] array = new MBCategoryImpl[3];
3038
3039 array[0] = filterGetByG_P_PrevAndNext(session, mbCategory, groupId,
3040 parentCategoryId, orderByComparator, true);
3041
3042 array[1] = mbCategory;
3043
3044 array[2] = filterGetByG_P_PrevAndNext(session, mbCategory, groupId,
3045 parentCategoryId, orderByComparator, false);
3046
3047 return array;
3048 }
3049 catch (Exception e) {
3050 throw processException(e);
3051 }
3052 finally {
3053 closeSession(session);
3054 }
3055 }
3056
3057 protected MBCategory filterGetByG_P_PrevAndNext(Session session,
3058 MBCategory mbCategory, long groupId, long parentCategoryId,
3059 OrderByComparator orderByComparator, boolean previous) {
3060 StringBundler query = null;
3061
3062 if (orderByComparator != null) {
3063 query = new StringBundler(6 +
3064 (orderByComparator.getOrderByFields().length * 6));
3065 }
3066 else {
3067 query = new StringBundler(3);
3068 }
3069
3070 if (getDB().isSupportsInlineDistinct()) {
3071 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
3072 }
3073 else {
3074 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3075 }
3076
3077 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3078
3079 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
3080
3081 if (!getDB().isSupportsInlineDistinct()) {
3082 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3083 }
3084
3085 if (orderByComparator != null) {
3086 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3087
3088 if (orderByConditionFields.length > 0) {
3089 query.append(WHERE_AND);
3090 }
3091
3092 for (int i = 0; i < orderByConditionFields.length; i++) {
3093 if (getDB().isSupportsInlineDistinct()) {
3094 query.append(_ORDER_BY_ENTITY_ALIAS);
3095 }
3096 else {
3097 query.append(_ORDER_BY_ENTITY_TABLE);
3098 }
3099
3100 query.append(orderByConditionFields[i]);
3101
3102 if ((i + 1) < orderByConditionFields.length) {
3103 if (orderByComparator.isAscending() ^ previous) {
3104 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3105 }
3106 else {
3107 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3108 }
3109 }
3110 else {
3111 if (orderByComparator.isAscending() ^ previous) {
3112 query.append(WHERE_GREATER_THAN);
3113 }
3114 else {
3115 query.append(WHERE_LESSER_THAN);
3116 }
3117 }
3118 }
3119
3120 query.append(ORDER_BY_CLAUSE);
3121
3122 String[] orderByFields = orderByComparator.getOrderByFields();
3123
3124 for (int i = 0; i < orderByFields.length; i++) {
3125 if (getDB().isSupportsInlineDistinct()) {
3126 query.append(_ORDER_BY_ENTITY_ALIAS);
3127 }
3128 else {
3129 query.append(_ORDER_BY_ENTITY_TABLE);
3130 }
3131
3132 query.append(orderByFields[i]);
3133
3134 if ((i + 1) < orderByFields.length) {
3135 if (orderByComparator.isAscending() ^ previous) {
3136 query.append(ORDER_BY_ASC_HAS_NEXT);
3137 }
3138 else {
3139 query.append(ORDER_BY_DESC_HAS_NEXT);
3140 }
3141 }
3142 else {
3143 if (orderByComparator.isAscending() ^ previous) {
3144 query.append(ORDER_BY_ASC);
3145 }
3146 else {
3147 query.append(ORDER_BY_DESC);
3148 }
3149 }
3150 }
3151 }
3152
3153 else {
3154 if (getDB().isSupportsInlineDistinct()) {
3155 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
3156 }
3157 else {
3158 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
3159 }
3160 }
3161
3162 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3163 MBCategory.class.getName(),
3164 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3165
3166 SQLQuery q = session.createSQLQuery(sql);
3167
3168 q.setFirstResult(0);
3169 q.setMaxResults(2);
3170
3171 if (getDB().isSupportsInlineDistinct()) {
3172 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
3173 }
3174 else {
3175 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
3176 }
3177
3178 QueryPos qPos = QueryPos.getInstance(q);
3179
3180 qPos.add(groupId);
3181
3182 qPos.add(parentCategoryId);
3183
3184 if (orderByComparator != null) {
3185 Object[] values = orderByComparator.getOrderByConditionValues(mbCategory);
3186
3187 for (Object value : values) {
3188 qPos.add(value);
3189 }
3190 }
3191
3192 List<MBCategory> list = q.list();
3193
3194 if (list.size() == 2) {
3195 return list.get(1);
3196 }
3197 else {
3198 return null;
3199 }
3200 }
3201
3202
3210 public List<MBCategory> filterFindByG_P(long groupId,
3211 long[] parentCategoryIds) throws SystemException {
3212 return filterFindByG_P(groupId, parentCategoryIds, QueryUtil.ALL_POS,
3213 QueryUtil.ALL_POS, null);
3214 }
3215
3216
3230 public List<MBCategory> filterFindByG_P(long groupId,
3231 long[] parentCategoryIds, int start, int end) throws SystemException {
3232 return filterFindByG_P(groupId, parentCategoryIds, start, end, null);
3233 }
3234
3235
3250 public List<MBCategory> filterFindByG_P(long groupId,
3251 long[] parentCategoryIds, int start, int end,
3252 OrderByComparator orderByComparator) throws SystemException {
3253 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3254 return findByG_P(groupId, parentCategoryIds, start, end,
3255 orderByComparator);
3256 }
3257
3258 StringBundler query = new StringBundler();
3259
3260 if (getDB().isSupportsInlineDistinct()) {
3261 query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE);
3262 }
3263 else {
3264 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3265 }
3266
3267 boolean conjunctionable = false;
3268
3269 if (conjunctionable) {
3270 query.append(WHERE_AND);
3271 }
3272
3273 query.append(_FINDER_COLUMN_G_P_GROUPID_5);
3274
3275 conjunctionable = true;
3276
3277 if ((parentCategoryIds == null) || (parentCategoryIds.length > 0)) {
3278 if (conjunctionable) {
3279 query.append(WHERE_AND);
3280 }
3281
3282 query.append(StringPool.OPEN_PARENTHESIS);
3283
3284 for (int i = 0; i < parentCategoryIds.length; i++) {
3285 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_5);
3286
3287 if ((i + 1) < parentCategoryIds.length) {
3288 query.append(WHERE_OR);
3289 }
3290 }
3291
3292 query.append(StringPool.CLOSE_PARENTHESIS);
3293
3294 conjunctionable = true;
3295 }
3296
3297 if (!getDB().isSupportsInlineDistinct()) {
3298 query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3299 }
3300
3301 if (orderByComparator != null) {
3302 if (getDB().isSupportsInlineDistinct()) {
3303 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3304 orderByComparator);
3305 }
3306 else {
3307 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3308 orderByComparator);
3309 }
3310 }
3311
3312 else {
3313 if (getDB().isSupportsInlineDistinct()) {
3314 query.append(MBCategoryModelImpl.ORDER_BY_JPQL);
3315 }
3316 else {
3317 query.append(MBCategoryModelImpl.ORDER_BY_SQL);
3318 }
3319 }
3320
3321 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3322 MBCategory.class.getName(),
3323 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3324
3325 Session session = null;
3326
3327 try {
3328 session = openSession();
3329
3330 SQLQuery q = session.createSQLQuery(sql);
3331
3332 if (getDB().isSupportsInlineDistinct()) {
3333 q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class);
3334 }
3335 else {
3336 q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class);
3337 }
3338
3339 QueryPos qPos = QueryPos.getInstance(q);
3340
3341 qPos.add(groupId);
3342
3343 if (parentCategoryIds != null) {
3344 qPos.add(parentCategoryIds);
3345 }
3346
3347 return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end);
3348 }
3349 catch (Exception e) {
3350 throw processException(e);
3351 }
3352 finally {
3353 closeSession(session);
3354 }
3355 }
3356
3357
3363 public List<MBCategory> findAll() throws SystemException {
3364 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3365 }
3366
3367
3379 public List<MBCategory> findAll(int start, int end)
3380 throws SystemException {
3381 return findAll(start, end, null);
3382 }
3383
3384
3397 public List<MBCategory> findAll(int start, int end,
3398 OrderByComparator orderByComparator) throws SystemException {
3399 FinderPath finderPath = null;
3400 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3401
3402 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3403 (orderByComparator == null)) {
3404 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3405 finderArgs = FINDER_ARGS_EMPTY;
3406 }
3407 else {
3408 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3409 finderArgs = new Object[] { start, end, orderByComparator };
3410 }
3411
3412 List<MBCategory> list = (List<MBCategory>)FinderCacheUtil.getResult(finderPath,
3413 finderArgs, this);
3414
3415 if (list == null) {
3416 StringBundler query = null;
3417 String sql = null;
3418
3419 if (orderByComparator != null) {
3420 query = new StringBundler(2 +
3421 (orderByComparator.getOrderByFields().length * 3));
3422
3423 query.append(_SQL_SELECT_MBCATEGORY);
3424
3425 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3426 orderByComparator);
3427
3428 sql = query.toString();
3429 }
3430 else {
3431 sql = _SQL_SELECT_MBCATEGORY.concat(MBCategoryModelImpl.ORDER_BY_JPQL);
3432 }
3433
3434 Session session = null;
3435
3436 try {
3437 session = openSession();
3438
3439 Query q = session.createQuery(sql);
3440
3441 if (orderByComparator == null) {
3442 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
3443 start, end, false);
3444
3445 Collections.sort(list);
3446 }
3447 else {
3448 list = (List<MBCategory>)QueryUtil.list(q, getDialect(),
3449 start, end);
3450 }
3451 }
3452 catch (Exception e) {
3453 throw processException(e);
3454 }
3455 finally {
3456 if (list == null) {
3457 FinderCacheUtil.removeResult(finderPath, finderArgs);
3458 }
3459 else {
3460 cacheResult(list);
3461
3462 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3463 }
3464
3465 closeSession(session);
3466 }
3467 }
3468
3469 return list;
3470 }
3471
3472
3478 public void removeByUuid(String uuid) throws SystemException {
3479 for (MBCategory mbCategory : findByUuid(uuid)) {
3480 remove(mbCategory);
3481 }
3482 }
3483
3484
3492 public MBCategory removeByUUID_G(String uuid, long groupId)
3493 throws NoSuchCategoryException, SystemException {
3494 MBCategory mbCategory = findByUUID_G(uuid, groupId);
3495
3496 return remove(mbCategory);
3497 }
3498
3499
3505 public void removeByGroupId(long groupId) throws SystemException {
3506 for (MBCategory mbCategory : findByGroupId(groupId)) {
3507 remove(mbCategory);
3508 }
3509 }
3510
3511
3517 public void removeByCompanyId(long companyId) throws SystemException {
3518 for (MBCategory mbCategory : findByCompanyId(companyId)) {
3519 remove(mbCategory);
3520 }
3521 }
3522
3523
3530 public void removeByG_P(long groupId, long parentCategoryId)
3531 throws SystemException {
3532 for (MBCategory mbCategory : findByG_P(groupId, parentCategoryId)) {
3533 remove(mbCategory);
3534 }
3535 }
3536
3537
3542 public void removeAll() throws SystemException {
3543 for (MBCategory mbCategory : findAll()) {
3544 remove(mbCategory);
3545 }
3546 }
3547
3548
3555 public int countByUuid(String uuid) throws SystemException {
3556 Object[] finderArgs = new Object[] { uuid };
3557
3558 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3559 finderArgs, this);
3560
3561 if (count == null) {
3562 StringBundler query = new StringBundler(2);
3563
3564 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
3565
3566 if (uuid == null) {
3567 query.append(_FINDER_COLUMN_UUID_UUID_1);
3568 }
3569 else {
3570 if (uuid.equals(StringPool.BLANK)) {
3571 query.append(_FINDER_COLUMN_UUID_UUID_3);
3572 }
3573 else {
3574 query.append(_FINDER_COLUMN_UUID_UUID_2);
3575 }
3576 }
3577
3578 String sql = query.toString();
3579
3580 Session session = null;
3581
3582 try {
3583 session = openSession();
3584
3585 Query q = session.createQuery(sql);
3586
3587 QueryPos qPos = QueryPos.getInstance(q);
3588
3589 if (uuid != null) {
3590 qPos.add(uuid);
3591 }
3592
3593 count = (Long)q.uniqueResult();
3594 }
3595 catch (Exception e) {
3596 throw processException(e);
3597 }
3598 finally {
3599 if (count == null) {
3600 count = Long.valueOf(0);
3601 }
3602
3603 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3604 finderArgs, count);
3605
3606 closeSession(session);
3607 }
3608 }
3609
3610 return count.intValue();
3611 }
3612
3613
3621 public int countByUUID_G(String uuid, long groupId)
3622 throws SystemException {
3623 Object[] finderArgs = new Object[] { uuid, groupId };
3624
3625 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3626 finderArgs, this);
3627
3628 if (count == null) {
3629 StringBundler query = new StringBundler(3);
3630
3631 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
3632
3633 if (uuid == null) {
3634 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3635 }
3636 else {
3637 if (uuid.equals(StringPool.BLANK)) {
3638 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3639 }
3640 else {
3641 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3642 }
3643 }
3644
3645 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3646
3647 String sql = query.toString();
3648
3649 Session session = null;
3650
3651 try {
3652 session = openSession();
3653
3654 Query q = session.createQuery(sql);
3655
3656 QueryPos qPos = QueryPos.getInstance(q);
3657
3658 if (uuid != null) {
3659 qPos.add(uuid);
3660 }
3661
3662 qPos.add(groupId);
3663
3664 count = (Long)q.uniqueResult();
3665 }
3666 catch (Exception e) {
3667 throw processException(e);
3668 }
3669 finally {
3670 if (count == null) {
3671 count = Long.valueOf(0);
3672 }
3673
3674 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3675 finderArgs, count);
3676
3677 closeSession(session);
3678 }
3679 }
3680
3681 return count.intValue();
3682 }
3683
3684
3691 public int countByGroupId(long groupId) throws SystemException {
3692 Object[] finderArgs = new Object[] { groupId };
3693
3694 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
3695 finderArgs, this);
3696
3697 if (count == null) {
3698 StringBundler query = new StringBundler(2);
3699
3700 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
3701
3702 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3703
3704 String sql = query.toString();
3705
3706 Session session = null;
3707
3708 try {
3709 session = openSession();
3710
3711 Query q = session.createQuery(sql);
3712
3713 QueryPos qPos = QueryPos.getInstance(q);
3714
3715 qPos.add(groupId);
3716
3717 count = (Long)q.uniqueResult();
3718 }
3719 catch (Exception e) {
3720 throw processException(e);
3721 }
3722 finally {
3723 if (count == null) {
3724 count = Long.valueOf(0);
3725 }
3726
3727 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
3728 finderArgs, count);
3729
3730 closeSession(session);
3731 }
3732 }
3733
3734 return count.intValue();
3735 }
3736
3737
3744 public int filterCountByGroupId(long groupId) throws SystemException {
3745 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3746 return countByGroupId(groupId);
3747 }
3748
3749 StringBundler query = new StringBundler(2);
3750
3751 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
3752
3753 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3754
3755 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3756 MBCategory.class.getName(),
3757 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3758
3759 Session session = null;
3760
3761 try {
3762 session = openSession();
3763
3764 SQLQuery q = session.createSQLQuery(sql);
3765
3766 q.addScalar(COUNT_COLUMN_NAME,
3767 com.liferay.portal.kernel.dao.orm.Type.LONG);
3768
3769 QueryPos qPos = QueryPos.getInstance(q);
3770
3771 qPos.add(groupId);
3772
3773 Long count = (Long)q.uniqueResult();
3774
3775 return count.intValue();
3776 }
3777 catch (Exception e) {
3778 throw processException(e);
3779 }
3780 finally {
3781 closeSession(session);
3782 }
3783 }
3784
3785
3792 public int countByCompanyId(long companyId) throws SystemException {
3793 Object[] finderArgs = new Object[] { companyId };
3794
3795 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3796 finderArgs, this);
3797
3798 if (count == null) {
3799 StringBundler query = new StringBundler(2);
3800
3801 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
3802
3803 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3804
3805 String sql = query.toString();
3806
3807 Session session = null;
3808
3809 try {
3810 session = openSession();
3811
3812 Query q = session.createQuery(sql);
3813
3814 QueryPos qPos = QueryPos.getInstance(q);
3815
3816 qPos.add(companyId);
3817
3818 count = (Long)q.uniqueResult();
3819 }
3820 catch (Exception e) {
3821 throw processException(e);
3822 }
3823 finally {
3824 if (count == null) {
3825 count = Long.valueOf(0);
3826 }
3827
3828 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3829 finderArgs, count);
3830
3831 closeSession(session);
3832 }
3833 }
3834
3835 return count.intValue();
3836 }
3837
3838
3846 public int countByG_P(long groupId, long parentCategoryId)
3847 throws SystemException {
3848 Object[] finderArgs = new Object[] { groupId, parentCategoryId };
3849
3850 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
3851 finderArgs, this);
3852
3853 if (count == null) {
3854 StringBundler query = new StringBundler(3);
3855
3856 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
3857
3858 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3859
3860 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
3861
3862 String sql = query.toString();
3863
3864 Session session = null;
3865
3866 try {
3867 session = openSession();
3868
3869 Query q = session.createQuery(sql);
3870
3871 QueryPos qPos = QueryPos.getInstance(q);
3872
3873 qPos.add(groupId);
3874
3875 qPos.add(parentCategoryId);
3876
3877 count = (Long)q.uniqueResult();
3878 }
3879 catch (Exception e) {
3880 throw processException(e);
3881 }
3882 finally {
3883 if (count == null) {
3884 count = Long.valueOf(0);
3885 }
3886
3887 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
3888 count);
3889
3890 closeSession(session);
3891 }
3892 }
3893
3894 return count.intValue();
3895 }
3896
3897
3905 public int countByG_P(long groupId, long[] parentCategoryIds)
3906 throws SystemException {
3907 Object[] finderArgs = new Object[] {
3908 groupId, StringUtil.merge(parentCategoryIds)
3909 };
3910
3911 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P,
3912 finderArgs, this);
3913
3914 if (count == null) {
3915 StringBundler query = new StringBundler();
3916
3917 query.append(_SQL_COUNT_MBCATEGORY_WHERE);
3918
3919 boolean conjunctionable = false;
3920
3921 if (conjunctionable) {
3922 query.append(WHERE_AND);
3923 }
3924
3925 query.append(_FINDER_COLUMN_G_P_GROUPID_5);
3926
3927 conjunctionable = true;
3928
3929 if ((parentCategoryIds == null) || (parentCategoryIds.length > 0)) {
3930 if (conjunctionable) {
3931 query.append(WHERE_AND);
3932 }
3933
3934 query.append(StringPool.OPEN_PARENTHESIS);
3935
3936 for (int i = 0; i < parentCategoryIds.length; i++) {
3937 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_5);
3938
3939 if ((i + 1) < parentCategoryIds.length) {
3940 query.append(WHERE_OR);
3941 }
3942 }
3943
3944 query.append(StringPool.CLOSE_PARENTHESIS);
3945
3946 conjunctionable = true;
3947 }
3948
3949 String sql = query.toString();
3950
3951 Session session = null;
3952
3953 try {
3954 session = openSession();
3955
3956 Query q = session.createQuery(sql);
3957
3958 QueryPos qPos = QueryPos.getInstance(q);
3959
3960 qPos.add(groupId);
3961
3962 if (parentCategoryIds != null) {
3963 qPos.add(parentCategoryIds);
3964 }
3965
3966 count = (Long)q.uniqueResult();
3967 }
3968 catch (Exception e) {
3969 throw processException(e);
3970 }
3971 finally {
3972 if (count == null) {
3973 count = Long.valueOf(0);
3974 }
3975
3976 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P,
3977 finderArgs, count);
3978
3979 closeSession(session);
3980 }
3981 }
3982
3983 return count.intValue();
3984 }
3985
3986
3994 public int filterCountByG_P(long groupId, long parentCategoryId)
3995 throws SystemException {
3996 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3997 return countByG_P(groupId, parentCategoryId);
3998 }
3999
4000 StringBundler query = new StringBundler(3);
4001
4002 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
4003
4004 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4005
4006 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2);
4007
4008 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4009 MBCategory.class.getName(),
4010 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4011
4012 Session session = null;
4013
4014 try {
4015 session = openSession();
4016
4017 SQLQuery q = session.createSQLQuery(sql);
4018
4019 q.addScalar(COUNT_COLUMN_NAME,
4020 com.liferay.portal.kernel.dao.orm.Type.LONG);
4021
4022 QueryPos qPos = QueryPos.getInstance(q);
4023
4024 qPos.add(groupId);
4025
4026 qPos.add(parentCategoryId);
4027
4028 Long count = (Long)q.uniqueResult();
4029
4030 return count.intValue();
4031 }
4032 catch (Exception e) {
4033 throw processException(e);
4034 }
4035 finally {
4036 closeSession(session);
4037 }
4038 }
4039
4040
4048 public int filterCountByG_P(long groupId, long[] parentCategoryIds)
4049 throws SystemException {
4050 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4051 return countByG_P(groupId, parentCategoryIds);
4052 }
4053
4054 StringBundler query = new StringBundler();
4055
4056 query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE);
4057
4058 boolean conjunctionable = false;
4059
4060 if (conjunctionable) {
4061 query.append(WHERE_AND);
4062 }
4063
4064 query.append(_FINDER_COLUMN_G_P_GROUPID_5);
4065
4066 conjunctionable = true;
4067
4068 if ((parentCategoryIds == null) || (parentCategoryIds.length > 0)) {
4069 if (conjunctionable) {
4070 query.append(WHERE_AND);
4071 }
4072
4073 query.append(StringPool.OPEN_PARENTHESIS);
4074
4075 for (int i = 0; i < parentCategoryIds.length; i++) {
4076 query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_5);
4077
4078 if ((i + 1) < parentCategoryIds.length) {
4079 query.append(WHERE_OR);
4080 }
4081 }
4082
4083 query.append(StringPool.CLOSE_PARENTHESIS);
4084
4085 conjunctionable = true;
4086 }
4087
4088 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4089 MBCategory.class.getName(),
4090 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4091
4092 Session session = null;
4093
4094 try {
4095 session = openSession();
4096
4097 SQLQuery q = session.createSQLQuery(sql);
4098
4099 q.addScalar(COUNT_COLUMN_NAME,
4100 com.liferay.portal.kernel.dao.orm.Type.LONG);
4101
4102 QueryPos qPos = QueryPos.getInstance(q);
4103
4104 qPos.add(groupId);
4105
4106 if (parentCategoryIds != null) {
4107 qPos.add(parentCategoryIds);
4108 }
4109
4110 Long count = (Long)q.uniqueResult();
4111
4112 return count.intValue();
4113 }
4114 catch (Exception e) {
4115 throw processException(e);
4116 }
4117 finally {
4118 closeSession(session);
4119 }
4120 }
4121
4122
4128 public int countAll() throws SystemException {
4129 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4130 FINDER_ARGS_EMPTY, this);
4131
4132 if (count == null) {
4133 Session session = null;
4134
4135 try {
4136 session = openSession();
4137
4138 Query q = session.createQuery(_SQL_COUNT_MBCATEGORY);
4139
4140 count = (Long)q.uniqueResult();
4141 }
4142 catch (Exception e) {
4143 throw processException(e);
4144 }
4145 finally {
4146 if (count == null) {
4147 count = Long.valueOf(0);
4148 }
4149
4150 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4151 FINDER_ARGS_EMPTY, count);
4152
4153 closeSession(session);
4154 }
4155 }
4156
4157 return count.intValue();
4158 }
4159
4160
4163 public void afterPropertiesSet() {
4164 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4165 com.liferay.portal.util.PropsUtil.get(
4166 "value.object.listener.com.liferay.portlet.messageboards.model.MBCategory")));
4167
4168 if (listenerClassNames.length > 0) {
4169 try {
4170 List<ModelListener<MBCategory>> listenersList = new ArrayList<ModelListener<MBCategory>>();
4171
4172 for (String listenerClassName : listenerClassNames) {
4173 listenersList.add((ModelListener<MBCategory>)InstanceFactory.newInstance(
4174 listenerClassName));
4175 }
4176
4177 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4178 }
4179 catch (Exception e) {
4180 _log.error(e);
4181 }
4182 }
4183 }
4184
4185 public void destroy() {
4186 EntityCacheUtil.removeCache(MBCategoryImpl.class.getName());
4187 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4188 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4189 }
4190
4191 @BeanReference(type = MBBanPersistence.class)
4192 protected MBBanPersistence mbBanPersistence;
4193 @BeanReference(type = MBCategoryPersistence.class)
4194 protected MBCategoryPersistence mbCategoryPersistence;
4195 @BeanReference(type = MBDiscussionPersistence.class)
4196 protected MBDiscussionPersistence mbDiscussionPersistence;
4197 @BeanReference(type = MBMailingListPersistence.class)
4198 protected MBMailingListPersistence mbMailingListPersistence;
4199 @BeanReference(type = MBMessagePersistence.class)
4200 protected MBMessagePersistence mbMessagePersistence;
4201 @BeanReference(type = MBStatsUserPersistence.class)
4202 protected MBStatsUserPersistence mbStatsUserPersistence;
4203 @BeanReference(type = MBThreadPersistence.class)
4204 protected MBThreadPersistence mbThreadPersistence;
4205 @BeanReference(type = MBThreadFlagPersistence.class)
4206 protected MBThreadFlagPersistence mbThreadFlagPersistence;
4207 @BeanReference(type = GroupPersistence.class)
4208 protected GroupPersistence groupPersistence;
4209 @BeanReference(type = ResourcePersistence.class)
4210 protected ResourcePersistence resourcePersistence;
4211 @BeanReference(type = SubscriptionPersistence.class)
4212 protected SubscriptionPersistence subscriptionPersistence;
4213 @BeanReference(type = UserPersistence.class)
4214 protected UserPersistence userPersistence;
4215 @BeanReference(type = AssetTagPersistence.class)
4216 protected AssetTagPersistence assetTagPersistence;
4217 @BeanReference(type = ExpandoValuePersistence.class)
4218 protected ExpandoValuePersistence expandoValuePersistence;
4219 private static final String _SQL_SELECT_MBCATEGORY = "SELECT mbCategory FROM MBCategory mbCategory";
4220 private static final String _SQL_SELECT_MBCATEGORY_WHERE = "SELECT mbCategory FROM MBCategory mbCategory WHERE ";
4221 private static final String _SQL_COUNT_MBCATEGORY = "SELECT COUNT(mbCategory) FROM MBCategory mbCategory";
4222 private static final String _SQL_COUNT_MBCATEGORY_WHERE = "SELECT COUNT(mbCategory) FROM MBCategory mbCategory WHERE ";
4223 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbCategory.uuid IS NULL";
4224 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbCategory.uuid = ?";
4225 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = ?)";
4226 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbCategory.uuid IS NULL AND ";
4227 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbCategory.uuid = ? AND ";
4228 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = ?) AND ";
4229 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbCategory.groupId = ?";
4230 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbCategory.groupId = ?";
4231 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "mbCategory.companyId = ?";
4232 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "mbCategory.groupId = ? AND ";
4233 private static final String _FINDER_COLUMN_G_P_GROUPID_5 = "(" +
4234 _removeConjunction(_FINDER_COLUMN_G_P_GROUPID_2) + ")";
4235 private static final String _FINDER_COLUMN_G_P_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ?";
4236 private static final String _FINDER_COLUMN_G_P_PARENTCATEGORYID_5 = "(" +
4237 _removeConjunction(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2) + ")";
4238
4239 private static String _removeConjunction(String sql) {
4240 int pos = sql.indexOf(" AND ");
4241
4242 if (pos != -1) {
4243 sql = sql.substring(0, pos);
4244 }
4245
4246 return sql;
4247 }
4248
4249 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbCategory.categoryId";
4250 private static final String _FILTER_SQL_SELECT_MBCATEGORY_WHERE = "SELECT DISTINCT {mbCategory.*} FROM MBCategory mbCategory WHERE ";
4251 private static final String _FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
4252 "SELECT {MBCategory.*} FROM (SELECT DISTINCT mbCategory.categoryId FROM MBCategory mbCategory WHERE ";
4253 private static final String _FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
4254 ") TEMP_TABLE INNER JOIN MBCategory ON TEMP_TABLE.categoryId = MBCategory.categoryId";
4255 private static final String _FILTER_SQL_COUNT_MBCATEGORY_WHERE = "SELECT COUNT(DISTINCT mbCategory.categoryId) AS COUNT_VALUE FROM MBCategory mbCategory WHERE ";
4256 private static final String _FILTER_ENTITY_ALIAS = "mbCategory";
4257 private static final String _FILTER_ENTITY_TABLE = "MBCategory";
4258 private static final String _ORDER_BY_ENTITY_ALIAS = "mbCategory.";
4259 private static final String _ORDER_BY_ENTITY_TABLE = "MBCategory.";
4260 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBCategory exists with the primary key ";
4261 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBCategory exists with the key {";
4262 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4263 private static Log _log = LogFactoryUtil.getLog(MBCategoryPersistenceImpl.class);
4264 private static MBCategory _nullMBCategory = new MBCategoryImpl() {
4265 @Override
4266 public Object clone() {
4267 return this;
4268 }
4269
4270 @Override
4271 public CacheModel<MBCategory> toCacheModel() {
4272 return _nullMBCategoryCacheModel;
4273 }
4274 };
4275
4276 private static CacheModel<MBCategory> _nullMBCategoryCacheModel = new CacheModel<MBCategory>() {
4277 public MBCategory toEntityModel() {
4278 return _nullMBCategory;
4279 }
4280 };
4281 }