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