/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portlet.messageboards.service.persistence.impl; import aQute.bnd.annotation.ProviderType; import com.liferay.message.boards.kernel.exception.NoSuchCategoryException; import com.liferay.message.boards.kernel.model.MBCategory; import com.liferay.message.boards.kernel.service.persistence.MBCategoryPersistence; import com.liferay.portal.kernel.bean.BeanReference; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.EntityCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderCache; import com.liferay.portal.kernel.dao.orm.FinderCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderPath; import com.liferay.portal.kernel.dao.orm.Query; import com.liferay.portal.kernel.dao.orm.QueryPos; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.SQLQuery; import com.liferay.portal.kernel.dao.orm.Session; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.service.ServiceContextThreadLocal; import com.liferay.portal.kernel.service.persistence.CompanyProvider; import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper; import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl; import com.liferay.portal.kernel.util.ArrayUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.ReflectionUtil; import com.liferay.portal.kernel.util.SetUtil; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.uuid.PortalUUIDUtil; import com.liferay.portlet.messageboards.model.impl.MBCategoryImpl; import com.liferay.portlet.messageboards.model.impl.MBCategoryModelImpl; import java.io.Serializable; import java.lang.reflect.Field; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; /** * The persistence implementation for the message boards category service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see MBCategoryPersistence * @see com.liferay.message.boards.kernel.service.persistence.MBCategoryUtil * @generated */ @ProviderType public class MBCategoryPersistenceImpl extends BasePersistenceImpl<MBCategory> implements MBCategoryPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link MBCategoryUtil} to access the message boards category persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = MBCategoryImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] { String.class.getName() }, MBCategoryModelImpl.UUID_COLUMN_BITMASK | MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | MBCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] { String.class.getName() }); /** * Returns all the message boards categories where uuid = ?. * * @param uuid the uuid * @return the matching message boards categories */ @Override public List<MBCategory> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the message boards categories where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByUuid(String uuid, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByUuid(String uuid, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if (!Objects.equals(uuid, mbCategory.getUuid())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByUuid_First(String uuid, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByUuid_First(uuid, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByUuid_First(String uuid, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByUuid_Last(String uuid, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByUuid_Last(uuid, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByUuid_Last(String uuid, OrderByComparator<MBCategory> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<MBCategory> list = findByUuid(uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message boards categories before and after the current message boards category in the ordered set where uuid = ?. * * @param categoryId the primary key of the current message boards category * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] findByUuid_PrevAndNext(long categoryId, String uuid, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = getByUuid_PrevAndNext(session, mbCategory, uuid, orderByComparator, true); array[1] = mbCategory; array[2] = getByUuid_PrevAndNext(session, mbCategory, uuid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory getByUuid_PrevAndNext(Session session, MBCategory mbCategory, String uuid, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message boards categories where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (MBCategory mbCategory : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where uuid = ?. * * @param uuid the uuid * @return the number of matching message boards categories */ @Override public int countByUuid(String uuid) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID; Object[] finderArgs = new Object[] { uuid }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_MBCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbCategory.uuid IS NULL"; private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbCategory.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = '')"; public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G", new String[] { String.class.getName(), Long.class.getName() }, MBCategoryModelImpl.UUID_COLUMN_BITMASK | MBCategoryModelImpl.GROUPID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns the message boards category where uuid = ? and groupId = ? or throws a {@link NoSuchCategoryException} if it could not be found. * * @param uuid the uuid * @param groupId the group ID * @return the matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByUUID_G(String uuid, long groupId) throws NoSuchCategoryException { MBCategory mbCategory = fetchByUUID_G(uuid, groupId); if (mbCategory == null) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchCategoryException(msg.toString()); } return mbCategory; } /** * Returns the message boards category where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param uuid the uuid * @param groupId the group ID * @return the matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByUUID_G(String uuid, long groupId) { return fetchByUUID_G(uuid, groupId, true); } /** * Returns the message boards category where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param uuid the uuid * @param groupId the group ID * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByUUID_G(String uuid, long groupId, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { uuid, groupId }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, this); } if (result instanceof MBCategory) { MBCategory mbCategory = (MBCategory)result; if (!Objects.equals(uuid, mbCategory.getUuid()) || (groupId != mbCategory.getGroupId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_MBCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_G_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_G_UUID_2); } query.append(_FINDER_COLUMN_UUID_G_GROUPID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(groupId); List<MBCategory> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, list); } else { MBCategory mbCategory = list.get(0); result = mbCategory; cacheResult(mbCategory); if ((mbCategory.getUuid() == null) || !mbCategory.getUuid().equals(uuid) || (mbCategory.getGroupId() != groupId)) { finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, mbCategory); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (MBCategory)result; } } /** * Removes the message boards category where uuid = ? and groupId = ? from the database. * * @param uuid the uuid * @param groupId the group ID * @return the message boards category that was removed */ @Override public MBCategory removeByUUID_G(String uuid, long groupId) throws NoSuchCategoryException { MBCategory mbCategory = findByUUID_G(uuid, groupId); return remove(mbCategory); } /** * Returns the number of message boards categories where uuid = ? and groupId = ?. * * @param uuid the uuid * @param groupId the group ID * @return the number of matching message boards categories */ @Override public int countByUUID_G(String uuid, long groupId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G; Object[] finderArgs = new Object[] { uuid, groupId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_G_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_G_UUID_2); } query.append(_FINDER_COLUMN_UUID_G_GROUPID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(groupId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbCategory.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbCategory.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbCategory.groupId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName() }, MBCategoryModelImpl.UUID_COLUMN_BITMASK | MBCategoryModelImpl.COMPANYID_COLUMN_BITMASK | MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | MBCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns all the message boards categories where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching message boards categories */ @Override public List<MBCategory> findByUuid_C(String uuid, long companyId) { return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByUuid_C(String uuid, long companyId, int start, int end) { return findByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the message boards categories where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByUuid_C(uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if (!Objects.equals(uuid, mbCategory.getUuid()) || (companyId != mbCategory.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByUuid_C_First(String uuid, long companyId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByUuid_C_First(uuid, companyId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByUuid_C_First(String uuid, long companyId, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByUuid_C_Last(String uuid, long companyId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByUuid_C_Last(uuid, companyId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByUuid_C_Last(String uuid, long companyId, OrderByComparator<MBCategory> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<MBCategory> list = findByUuid_C(uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message boards categories before and after the current message boards category in the ordered set where uuid = ? and companyId = ?. * * @param categoryId the primary key of the current message boards category * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] findByUuid_C_PrevAndNext(long categoryId, String uuid, long companyId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = getByUuid_C_PrevAndNext(session, mbCategory, uuid, companyId, orderByComparator, true); array[1] = mbCategory; array[2] = getByUuid_C_PrevAndNext(session, mbCategory, uuid, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory getByUuid_C_PrevAndNext(Session session, MBCategory mbCategory, String uuid, long companyId, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message boards categories where uuid = ? and companyId = ? from the database. * * @param uuid the uuid * @param companyId the company ID */ @Override public void removeByUuid_C(String uuid, long companyId) { for (MBCategory mbCategory : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching message boards categories */ @Override public int countByUuid_C(String uuid, long companyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C; Object[] finderArgs = new Object[] { uuid, companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mbCategory.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbCategory.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbCategory.uuid IS NULL OR mbCategory.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbCategory.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId", new String[] { Long.class.getName() }, MBCategoryModelImpl.GROUPID_COLUMN_BITMASK | MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | MBCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId", new String[] { Long.class.getName() }); /** * Returns all the message boards categories where groupId = ?. * * @param groupId the group ID * @return the matching message boards categories */ @Override public List<MBCategory> findByGroupId(long groupId) { return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByGroupId(long groupId, int start, int end) { return findByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the message boards categories where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByGroupId(long groupId, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByGroupId(groupId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByGroupId(long groupId, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID; finderArgs = new Object[] { groupId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID; finderArgs = new Object[] { groupId, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((groupId != mbCategory.getGroupId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByGroupId_First(long groupId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByGroupId_First(groupId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByGroupId_First(long groupId, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByGroupId(groupId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByGroupId_Last(long groupId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByGroupId_Last(groupId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByGroupId_Last(long groupId, OrderByComparator<MBCategory> orderByComparator) { int count = countByGroupId(groupId); if (count == 0) { return null; } List<MBCategory> list = findByGroupId(groupId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message boards categories before and after the current message boards category in the ordered set where groupId = ?. * * @param categoryId the primary key of the current message boards category * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] findByGroupId_PrevAndNext(long categoryId, long groupId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = getByGroupId_PrevAndNext(session, mbCategory, groupId, orderByComparator, true); array[1] = mbCategory; array[2] = getByGroupId_PrevAndNext(session, mbCategory, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory getByGroupId_PrevAndNext(Session session, MBCategory mbCategory, long groupId, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards categories that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByGroupId(long groupId) { return filterFindByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByGroupId(long groupId, int start, int end) { return filterFindByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permissions to view where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByGroupId(long groupId, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId(groupId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards categories before and after the current message boards category in the ordered set of message boards categories that the user has permission to view where groupId = ?. * * @param categoryId the primary key of the current message boards category * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] filterFindByGroupId_PrevAndNext(long categoryId, long groupId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId_PrevAndNext(categoryId, groupId, orderByComparator); } MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = filterGetByGroupId_PrevAndNext(session, mbCategory, groupId, orderByComparator, true); array[1] = mbCategory; array[2] = filterGetByGroupId_PrevAndNext(session, mbCategory, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory filterGetByGroupId_PrevAndNext(Session session, MBCategory mbCategory, long groupId, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message boards categories where groupId = ? from the database. * * @param groupId the group ID */ @Override public void removeByGroupId(long groupId) { for (MBCategory mbCategory : findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where groupId = ?. * * @param groupId the group ID * @return the number of matching message boards categories */ @Override public int countByGroupId(long groupId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID; Object[] finderArgs = new Object[] { groupId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByGroupId(long groupId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByGroupId(groupId); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbCategory.groupId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId", new String[] { Long.class.getName() }, MBCategoryModelImpl.COMPANYID_COLUMN_BITMASK | MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | MBCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId", new String[] { Long.class.getName() }); /** * Returns all the message boards categories where companyId = ?. * * @param companyId the company ID * @return the matching message boards categories */ @Override public List<MBCategory> findByCompanyId(long companyId) { return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByCompanyId(long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the message boards categories where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByCompanyId(long companyId, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByCompanyId(companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByCompanyId(long companyId, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID; finderArgs = new Object[] { companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID; finderArgs = new Object[] { companyId, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((companyId != mbCategory.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByCompanyId_First(long companyId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByCompanyId_First(companyId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByCompanyId_First(long companyId, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByCompanyId(companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByCompanyId_Last(long companyId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByCompanyId_Last(companyId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByCompanyId_Last(long companyId, OrderByComparator<MBCategory> orderByComparator) { int count = countByCompanyId(companyId); if (count == 0) { return null; } List<MBCategory> list = findByCompanyId(companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message boards categories before and after the current message boards category in the ordered set where companyId = ?. * * @param categoryId the primary key of the current message boards category * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] findByCompanyId_PrevAndNext(long categoryId, long companyId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = getByCompanyId_PrevAndNext(session, mbCategory, companyId, orderByComparator, true); array[1] = mbCategory; array[2] = getByCompanyId_PrevAndNext(session, mbCategory, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory getByCompanyId_PrevAndNext(Session session, MBCategory mbCategory, long companyId, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message boards categories where companyId = ? from the database. * * @param companyId the company ID */ @Override public void removeByCompanyId(long companyId) { for (MBCategory mbCategory : findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where companyId = ?. * * @param companyId the company ID * @return the number of matching message boards categories */ @Override public int countByCompanyId(long companyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID; Object[] finderArgs = new Object[] { companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "mbCategory.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P", new String[] { Long.class.getName(), Long.class.getName() }, MBCategoryModelImpl.GROUPID_COLUMN_BITMASK | MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | MBCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P", new String[] { Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_P", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the message boards categories where groupId = ? and parentCategoryId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @return the matching message boards categories */ @Override public List<MBCategory> findByG_P(long groupId, long parentCategoryId) { return findByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByG_P(long groupId, long parentCategoryId, int start, int end) { return findByG_P(groupId, parentCategoryId, start, end, null); } /** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_P(long groupId, long parentCategoryId, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByG_P(groupId, parentCategoryId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_P(long groupId, long parentCategoryId, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P; finderArgs = new Object[] { groupId, parentCategoryId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P; finderArgs = new Object[] { groupId, parentCategoryId, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((groupId != mbCategory.getGroupId()) || (parentCategoryId != mbCategory.getParentCategoryId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_GROUPID_2); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where groupId = ? and parentCategoryId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByG_P_First(long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByG_P_First(groupId, parentCategoryId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where groupId = ? and parentCategoryId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByG_P_First(long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByG_P(groupId, parentCategoryId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where groupId = ? and parentCategoryId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByG_P_Last(long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByG_P_Last(groupId, parentCategoryId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where groupId = ? and parentCategoryId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByG_P_Last(long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) { int count = countByG_P(groupId, parentCategoryId); if (count == 0) { return null; } List<MBCategory> list = findByG_P(groupId, parentCategoryId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message boards categories before and after the current message boards category in the ordered set where groupId = ? and parentCategoryId = ?. * * @param categoryId the primary key of the current message boards category * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] findByG_P_PrevAndNext(long categoryId, long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = getByG_P_PrevAndNext(session, mbCategory, groupId, parentCategoryId, orderByComparator, true); array[1] = mbCategory; array[2] = getByG_P_PrevAndNext(session, mbCategory, groupId, parentCategoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory getByG_P_PrevAndNext(Session session, MBCategory mbCategory, long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_GROUPID_2); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P(long groupId, long parentCategoryId) { return filterFindByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P(long groupId, long parentCategoryId, int start, int end) { return filterFindByG_P(groupId, parentCategoryId, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permissions to view where groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P(long groupId, long parentCategoryId, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P(groupId, parentCategoryId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_GROUPID_2); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards categories before and after the current message boards category in the ordered set of message boards categories that the user has permission to view where groupId = ? and parentCategoryId = ?. * * @param categoryId the primary key of the current message boards category * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] filterFindByG_P_PrevAndNext(long categoryId, long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_PrevAndNext(categoryId, groupId, parentCategoryId, orderByComparator); } MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = filterGetByG_P_PrevAndNext(session, mbCategory, groupId, parentCategoryId, orderByComparator, true); array[1] = mbCategory; array[2] = filterGetByG_P_PrevAndNext(session, mbCategory, groupId, parentCategoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory filterGetByG_P_PrevAndNext(Session session, MBCategory mbCategory, long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_GROUPID_2); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ?. * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P(long groupId, long[] parentCategoryIds) { return filterFindByG_P(groupId, parentCategoryIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P(long groupId, long[] parentCategoryIds, int start, int end) { return filterFindByG_P(groupId, parentCategoryIds, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P(long groupId, long[] parentCategoryIds, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P(groupId, parentCategoryIds, start, end, orderByComparator); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the message boards categories where groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @return the matching message boards categories */ @Override public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds) { return findByG_P(groupId, parentCategoryIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds, int start, int end) { return findByG_P(groupId, parentCategoryIds, start, end, null); } /** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByG_P(groupId, parentCategoryIds, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } if (parentCategoryIds.length == 1) { return findByG_P(groupId, parentCategoryIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds) }; } else { finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds), start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((groupId != mbCategory.getGroupId()) || !ArrayUtil.contains(parentCategoryIds, mbCategory.getParentCategoryId())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the message boards categories where groupId = ? and parentCategoryId = ? from the database. * * @param groupId the group ID * @param parentCategoryId the parent category ID */ @Override public void removeByG_P(long groupId, long parentCategoryId) { for (MBCategory mbCategory : findByG_P(groupId, parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where groupId = ? and parentCategoryId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @return the number of matching message boards categories */ @Override public int countByG_P(long groupId, long parentCategoryId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P; Object[] finderArgs = new Object[] { groupId, parentCategoryId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_GROUPID_2); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories where groupId = ? and parentCategoryId = any ?. * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @return the number of matching message boards categories */ @Override public int countByG_P(long groupId, long[] parentCategoryIds) { if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } Object[] finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds) }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories that the user has permission to view where groupId = ? and parentCategoryId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByG_P(long groupId, long parentCategoryId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_P(groupId, parentCategoryId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_GROUPID_2); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ?. * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByG_P(long groupId, long[] parentCategoryIds) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_P(groupId, parentCategoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "mbCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_G_P_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ?"; private static final String _FINDER_COLUMN_G_P_PARENTCATEGORYID_7 = "mbCategory.parentCategoryId IN ("; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName() }, MBCategoryModelImpl.GROUPID_COLUMN_BITMASK | MBCategoryModelImpl.STATUS_COLUMN_BITMASK | MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | MBCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S", new String[] { Long.class.getName(), Integer.class.getName() }); /** * Returns all the message boards categories where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @return the matching message boards categories */ @Override public List<MBCategory> findByG_S(long groupId, int status) { return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where groupId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByG_S(long groupId, int status, int start, int end) { return findByG_S(groupId, status, start, end, null); } /** * Returns an ordered range of all the message boards categories where groupId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_S(long groupId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByG_S(groupId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where groupId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_S(long groupId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S; finderArgs = new Object[] { groupId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S; finderArgs = new Object[] { groupId, status, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((groupId != mbCategory.getGroupId()) || (status != mbCategory.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByG_S_First(long groupId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByG_S_First(groupId, status, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByG_S_First(long groupId, int status, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByG_S(groupId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByG_S_Last(long groupId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByG_S_Last(groupId, status, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByG_S_Last(long groupId, int status, OrderByComparator<MBCategory> orderByComparator) { int count = countByG_S(groupId, status); if (count == 0) { return null; } List<MBCategory> list = findByG_S(groupId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message boards categories before and after the current message boards category in the ordered set where groupId = ? and status = ?. * * @param categoryId the primary key of the current message boards category * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] findByG_S_PrevAndNext(long categoryId, long groupId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = getByG_S_PrevAndNext(session, mbCategory, groupId, status, orderByComparator, true); array[1] = mbCategory; array[2] = getByG_S_PrevAndNext(session, mbCategory, groupId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory getByG_S_PrevAndNext(Session session, MBCategory mbCategory, long groupId, int status, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards categories that the user has permission to view where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_S(long groupId, int status) { return filterFindByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where groupId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_S(long groupId, int status, int start, int end) { return filterFindByG_S(groupId, status, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permissions to view where groupId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_S(long groupId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S(groupId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards categories before and after the current message boards category in the ordered set of message boards categories that the user has permission to view where groupId = ? and status = ?. * * @param categoryId the primary key of the current message boards category * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] filterFindByG_S_PrevAndNext(long categoryId, long groupId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S_PrevAndNext(categoryId, groupId, status, orderByComparator); } MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = filterGetByG_S_PrevAndNext(session, mbCategory, groupId, status, orderByComparator, true); array[1] = mbCategory; array[2] = filterGetByG_S_PrevAndNext(session, mbCategory, groupId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory filterGetByG_S_PrevAndNext(Session session, MBCategory mbCategory, long groupId, int status, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message boards categories where groupId = ? and status = ? from the database. * * @param groupId the group ID * @param status the status */ @Override public void removeByG_S(long groupId, int status) { for (MBCategory mbCategory : findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @return the number of matching message boards categories */ @Override public int countByG_S(long groupId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S; Object[] finderArgs = new Object[] { groupId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories that the user has permission to view where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByG_S(long groupId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_S(groupId, status); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbCategory.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S", new String[] { Long.class.getName(), Integer.class.getName() }, MBCategoryModelImpl.COMPANYID_COLUMN_BITMASK | MBCategoryModelImpl.STATUS_COLUMN_BITMASK | MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | MBCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S", new String[] { Long.class.getName(), Integer.class.getName() }); /** * Returns all the message boards categories where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @return the matching message boards categories */ @Override public List<MBCategory> findByC_S(long companyId, int status) { return findByC_S(companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where companyId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByC_S(long companyId, int status, int start, int end) { return findByC_S(companyId, status, start, end, null); } /** * Returns an ordered range of all the message boards categories where companyId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByC_S(long companyId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByC_S(companyId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where companyId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByC_S(long companyId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S; finderArgs = new Object[] { companyId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S; finderArgs = new Object[] { companyId, status, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((companyId != mbCategory.getCompanyId()) || (status != mbCategory.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_C_S_COMPANYID_2); query.append(_FINDER_COLUMN_C_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(status); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByC_S_First(long companyId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByC_S_First(companyId, status, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByC_S_First(long companyId, int status, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByC_S(companyId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByC_S_Last(long companyId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByC_S_Last(companyId, status, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByC_S_Last(long companyId, int status, OrderByComparator<MBCategory> orderByComparator) { int count = countByC_S(companyId, status); if (count == 0) { return null; } List<MBCategory> list = findByC_S(companyId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message boards categories before and after the current message boards category in the ordered set where companyId = ? and status = ?. * * @param categoryId the primary key of the current message boards category * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] findByC_S_PrevAndNext(long categoryId, long companyId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = getByC_S_PrevAndNext(session, mbCategory, companyId, status, orderByComparator, true); array[1] = mbCategory; array[2] = getByC_S_PrevAndNext(session, mbCategory, companyId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory getByC_S_PrevAndNext(Session session, MBCategory mbCategory, long companyId, int status, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_C_S_COMPANYID_2); query.append(_FINDER_COLUMN_C_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message boards categories where companyId = ? and status = ? from the database. * * @param companyId the company ID * @param status the status */ @Override public void removeByC_S(long companyId, int status) { for (MBCategory mbCategory : findByC_S(companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @return the number of matching message boards categories */ @Override public int countByC_S(long companyId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S; Object[] finderArgs = new Object[] { companyId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_C_S_COMPANYID_2); query.append(_FINDER_COLUMN_C_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "mbCategory.companyId = ? AND "; private static final String _FINDER_COLUMN_C_S_STATUS_2 = "mbCategory.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNotC_G_P", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByNotC_G_P", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); /** * Returns all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @return the matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P(long categoryId, long groupId, long parentCategoryId) { return findByNotC_G_P(categoryId, groupId, parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P(long categoryId, long groupId, long parentCategoryId, int start, int end) { return findByNotC_G_P(categoryId, groupId, parentCategoryId, start, end, null); } /** * Returns an ordered range of all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P(long categoryId, long groupId, long parentCategoryId, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByNotC_G_P(categoryId, groupId, parentCategoryId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P(long categoryId, long groupId, long parentCategoryId, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P; finderArgs = new Object[] { categoryId, groupId, parentCategoryId, start, end, orderByComparator }; List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((categoryId == mbCategory.getCategoryId()) || (groupId != mbCategory.getGroupId()) || (parentCategoryId != mbCategory.getParentCategoryId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2); query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(groupId); qPos.add(parentCategoryId); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByNotC_G_P_First(long categoryId, long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByNotC_G_P_First(categoryId, groupId, parentCategoryId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(", groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByNotC_G_P_First(long categoryId, long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByNotC_G_P(categoryId, groupId, parentCategoryId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByNotC_G_P_Last(long categoryId, long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByNotC_G_P_Last(categoryId, groupId, parentCategoryId, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(", groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByNotC_G_P_Last(long categoryId, long groupId, long parentCategoryId, OrderByComparator<MBCategory> orderByComparator) { int count = countByNotC_G_P(categoryId, groupId, parentCategoryId); if (count == 0) { return null; } List<MBCategory> list = findByNotC_G_P(categoryId, groupId, parentCategoryId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns all the message boards categories that the user has permission to view where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P(long categoryId, long groupId, long parentCategoryId) { return filterFindByNotC_G_P(categoryId, groupId, parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P(long categoryId, long groupId, long parentCategoryId, int start, int end) { return filterFindByNotC_G_P(categoryId, groupId, parentCategoryId, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permissions to view where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P(long categoryId, long groupId, long parentCategoryId, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByNotC_G_P(categoryId, groupId, parentCategoryId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2); query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(groupId); qPos.add(parentCategoryId); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the message boards categories that the user has permission to view where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ?. * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds) { return filterFindByNotC_G_P(categoryIds, groupId, parentCategoryIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds, int start, int end) { return filterFindByNotC_G_P(categoryIds, groupId, parentCategoryIds, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permission to view where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByNotC_G_P(categoryIds, groupId, parentCategoryIds, start, end, orderByComparator); } if (categoryIds == null) { categoryIds = new long[0]; } else if (categoryIds.length > 1) { categoryIds = ArrayUtil.unique(categoryIds); Arrays.sort(categoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } if (categoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_7); query.append(StringUtil.merge(categoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the message boards categories where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @return the matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds) { return findByNotC_G_P(categoryIds, groupId, parentCategoryIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds, int start, int end) { return findByNotC_G_P(categoryIds, groupId, parentCategoryIds, start, end, null); } /** * Returns an ordered range of all the message boards categories where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByNotC_G_P(categoryIds, groupId, parentCategoryIds, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { if (categoryIds == null) { categoryIds = new long[0]; } else if (categoryIds.length > 1) { categoryIds = ArrayUtil.unique(categoryIds); Arrays.sort(categoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } if ((categoryIds.length == 1) && (parentCategoryIds.length == 1)) { return findByNotC_G_P(categoryIds[0], groupId, parentCategoryIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { StringUtil.merge(categoryIds), groupId, StringUtil.merge(parentCategoryIds) }; } else { finderArgs = new Object[] { StringUtil.merge(categoryIds), groupId, StringUtil.merge(parentCategoryIds), start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if (!ArrayUtil.contains(categoryIds, mbCategory.getCategoryId()) || (groupId != mbCategory.getGroupId()) || !ArrayUtil.contains(parentCategoryIds, mbCategory.getParentCategoryId())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBCATEGORY_WHERE); if (categoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_7); query.append(StringUtil.merge(categoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ? from the database. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID */ @Override public void removeByNotC_G_P(long categoryId, long groupId, long parentCategoryId) { for (MBCategory mbCategory : findByNotC_G_P(categoryId, groupId, parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @return the number of matching message boards categories */ @Override public int countByNotC_G_P(long categoryId, long groupId, long parentCategoryId) { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P; Object[] finderArgs = new Object[] { categoryId, groupId, parentCategoryId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2); query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(groupId); qPos.add(parentCategoryId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ?. * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @return the number of matching message boards categories */ @Override public int countByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds) { if (categoryIds == null) { categoryIds = new long[0]; } else if (categoryIds.length > 1) { categoryIds = ArrayUtil.unique(categoryIds); Arrays.sort(categoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } Object[] finderArgs = new Object[] { StringUtil.merge(categoryIds), groupId, StringUtil.merge(parentCategoryIds) }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBCATEGORY_WHERE); if (categoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_7); query.append(StringUtil.merge(categoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories that the user has permission to view where categoryId ≠ ? and groupId = ? and parentCategoryId = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByNotC_G_P(long categoryId, long groupId, long parentCategoryId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByNotC_G_P(categoryId, groupId, parentCategoryId); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2); query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(groupId); qPos.add(parentCategoryId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of message boards categories that the user has permission to view where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ?. * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByNotC_G_P(long[] categoryIds, long groupId, long[] parentCategoryIds) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByNotC_G_P(categoryIds, groupId, parentCategoryIds); } if (categoryIds == null) { categoryIds = new long[0]; } else if (categoryIds.length > 1) { categoryIds = ArrayUtil.unique(categoryIds); Arrays.sort(categoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); if (categoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_CATEGORYID_7); query.append(StringUtil.merge(categoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_NOTC_G_P_CATEGORYID_2 = "mbCategory.categoryId != ? AND "; private static final String _FINDER_COLUMN_NOTC_G_P_CATEGORYID_7 = "mbCategory.categoryId NOT IN ("; private static final String _FINDER_COLUMN_NOTC_G_P_GROUPID_2 = "mbCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ?"; private static final String _FINDER_COLUMN_NOTC_G_P_PARENTCATEGORYID_7 = "mbCategory.parentCategoryId IN ("; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBCategoryModelImpl.GROUPID_COLUMN_BITMASK | MBCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | MBCategoryModelImpl.STATUS_COLUMN_BITMASK | MBCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_P_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the message boards categories where groupId = ? and parentCategoryId = ? and status = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @return the matching message boards categories */ @Override public List<MBCategory> findByG_P_S(long groupId, long parentCategoryId, int status) { return findByG_P_S(groupId, parentCategoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByG_P_S(long groupId, long parentCategoryId, int status, int start, int end) { return findByG_P_S(groupId, parentCategoryId, status, start, end, null); } /** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_P_S(long groupId, long parentCategoryId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByG_P_S(groupId, parentCategoryId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_P_S(long groupId, long parentCategoryId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S; finderArgs = new Object[] { groupId, parentCategoryId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S; finderArgs = new Object[] { groupId, parentCategoryId, status, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((groupId != mbCategory.getGroupId()) || (parentCategoryId != mbCategory.getParentCategoryId()) || (status != mbCategory.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where groupId = ? and parentCategoryId = ? and status = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByG_P_S_First(long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByG_P_S_First(groupId, parentCategoryId, status, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where groupId = ? and parentCategoryId = ? and status = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByG_P_S_First(long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByG_P_S(groupId, parentCategoryId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where groupId = ? and parentCategoryId = ? and status = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByG_P_S_Last(long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByG_P_S_Last(groupId, parentCategoryId, status, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where groupId = ? and parentCategoryId = ? and status = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByG_P_S_Last(long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) { int count = countByG_P_S(groupId, parentCategoryId, status); if (count == 0) { return null; } List<MBCategory> list = findByG_P_S(groupId, parentCategoryId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message boards categories before and after the current message boards category in the ordered set where groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the primary key of the current message boards category * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] findByG_P_S_PrevAndNext(long categoryId, long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = getByG_P_S_PrevAndNext(session, mbCategory, groupId, parentCategoryId, status, orderByComparator, true); array[1] = mbCategory; array[2] = getByG_P_S_PrevAndNext(session, mbCategory, groupId, parentCategoryId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory getByG_P_S_PrevAndNext(Session session, MBCategory mbCategory, long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = ? and status = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P_S(long groupId, long parentCategoryId, int status) { return filterFindByG_P_S(groupId, parentCategoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P_S(long groupId, long parentCategoryId, int status, int start, int end) { return filterFindByG_P_S(groupId, parentCategoryId, status, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permissions to view where groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P_S(long groupId, long parentCategoryId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_S(groupId, parentCategoryId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards categories before and after the current message boards category in the ordered set of message boards categories that the user has permission to view where groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the primary key of the current message boards category * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory[] filterFindByG_P_S_PrevAndNext(long categoryId, long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_S_PrevAndNext(categoryId, groupId, parentCategoryId, status, orderByComparator); } MBCategory mbCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); MBCategory[] array = new MBCategoryImpl[3]; array[0] = filterGetByG_P_S_PrevAndNext(session, mbCategory, groupId, parentCategoryId, status, orderByComparator, true); array[1] = mbCategory; array[2] = filterGetByG_P_S_PrevAndNext(session, mbCategory, groupId, parentCategoryId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBCategory filterGetByG_P_S_PrevAndNext(Session session, MBCategory mbCategory, long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(7 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbCategory); for (Object value : values) { qPos.add(value); } } List<MBCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ? and status = ?. * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P_S(long groupId, long[] parentCategoryIds, int status) { return filterFindByG_P_S(groupId, parentCategoryIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P_S(long groupId, long[] parentCategoryIds, int status, int start, int end) { return filterFindByG_P_S(groupId, parentCategoryIds, status, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByG_P_S(long groupId, long[] parentCategoryIds, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_S(groupId, parentCategoryIds, status, start, end, orderByComparator); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the message boards categories where groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @return the matching message boards categories */ @Override public List<MBCategory> findByG_P_S(long groupId, long[] parentCategoryIds, int status) { return findByG_P_S(groupId, parentCategoryIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByG_P_S(long groupId, long[] parentCategoryIds, int status, int start, int end) { return findByG_P_S(groupId, parentCategoryIds, status, start, end, null); } /** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_P_S(long groupId, long[] parentCategoryIds, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByG_P_S(groupId, parentCategoryIds, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = ? and status = ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByG_P_S(long groupId, long[] parentCategoryIds, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } if (parentCategoryIds.length == 1) { return findByG_P_S(groupId, parentCategoryIds[0], status, start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds), status }; } else { finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds), status, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((groupId != mbCategory.getGroupId()) || !ArrayUtil.contains(parentCategoryIds, mbCategory.getParentCategoryId()) || (status != mbCategory.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the message boards categories where groupId = ? and parentCategoryId = ? and status = ? from the database. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status */ @Override public void removeByG_P_S(long groupId, long parentCategoryId, int status) { for (MBCategory mbCategory : findByG_P_S(groupId, parentCategoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where groupId = ? and parentCategoryId = ? and status = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @return the number of matching message boards categories */ @Override public int countByG_P_S(long groupId, long parentCategoryId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_S; Object[] finderArgs = new Object[] { groupId, parentCategoryId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories where groupId = ? and parentCategoryId = any ? and status = ?. * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @return the number of matching message boards categories */ @Override public int countByG_P_S(long groupId, long[] parentCategoryIds, int status) { if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } Object[] finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds), status }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories that the user has permission to view where groupId = ? and parentCategoryId = ? and status = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByG_P_S(long groupId, long parentCategoryId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_P_S(groupId, parentCategoryId, status); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ? and status = ?. * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByG_P_S(long groupId, long[] parentCategoryIds, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_P_S(groupId, parentCategoryIds, status); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_S_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_P_S_GROUPID_2 = "mbCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_G_P_S_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ? AND "; private static final String _FINDER_COLUMN_G_P_S_PARENTCATEGORYID_7 = "mbCategory.parentCategoryId IN ("; private static final String _FINDER_COLUMN_G_P_S_STATUS_2 = "mbCategory.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, MBCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNotC_G_P_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S = new FinderPath(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByNotC_G_P_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @return the matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status) { return findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status, int start, int end) { return findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, start, end, null); } /** * Returns an ordered range of all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S; finderArgs = new Object[] { categoryId, groupId, parentCategoryId, status, start, end, orderByComparator }; List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if ((categoryId == mbCategory.getCategoryId()) || (groupId != mbCategory.getGroupId()) || (parentCategoryId != mbCategory.getParentCategoryId()) || (status != mbCategory.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(6); } query.append(_SQL_SELECT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first message boards category in the ordered set where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByNotC_G_P_S_First(long categoryId, long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByNotC_G_P_S_First(categoryId, groupId, parentCategoryId, status, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(", groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first message boards category in the ordered set where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByNotC_G_P_S_First(long categoryId, long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) { List<MBCategory> list = findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message boards category in the ordered set where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category * @throws NoSuchCategoryException if a matching message boards category could not be found */ @Override public MBCategory findByNotC_G_P_S_Last(long categoryId, long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) throws NoSuchCategoryException { MBCategory mbCategory = fetchByNotC_G_P_S_Last(categoryId, groupId, parentCategoryId, status, orderByComparator); if (mbCategory != null) { return mbCategory; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(", groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last message boards category in the ordered set where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards category, or <code>null</code> if a matching message boards category could not be found */ @Override public MBCategory fetchByNotC_G_P_S_Last(long categoryId, long groupId, long parentCategoryId, int status, OrderByComparator<MBCategory> orderByComparator) { int count = countByNotC_G_P_S(categoryId, groupId, parentCategoryId, status); if (count == 0) { return null; } List<MBCategory> list = findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns all the message boards categories that the user has permission to view where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status) { return filterFindByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status, int start, int end) { return filterFindByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permissions to view where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(7); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the message boards categories that the user has permission to view where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ? and status = ?. * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @return the matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status) { return filterFindByNotC_G_P_S(categoryIds, groupId, parentCategoryIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories that the user has permission to view where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status, int start, int end) { return filterFindByNotC_G_P_S(categoryIds, groupId, parentCategoryIds, status, start, end, null); } /** * Returns an ordered range of all the message boards categories that the user has permission to view where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view */ @Override public List<MBCategory> filterFindByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByNotC_G_P_S(categoryIds, groupId, parentCategoryIds, status, start, end, orderByComparator); } if (categoryIds == null) { categoryIds = new long[0]; } else if (categoryIds.length > 1) { categoryIds = ArrayUtil.unique(categoryIds); Arrays.sort(categoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } if (categoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7); query.append(StringUtil.merge(categoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the message boards categories where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @return the matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status) { return findByNotC_G_P_S(categoryIds, groupId, parentCategoryIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status, int start, int end) { return findByNotC_G_P_S(categoryIds, groupId, parentCategoryIds, status, start, end, null); } /** * Returns an ordered range of all the message boards categories where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findByNotC_G_P_S(categoryIds, groupId, parentCategoryIds, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching message boards categories */ @Override public List<MBCategory> findByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status, int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { if (categoryIds == null) { categoryIds = new long[0]; } else if (categoryIds.length > 1) { categoryIds = ArrayUtil.unique(categoryIds); Arrays.sort(categoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } if ((categoryIds.length == 1) && (parentCategoryIds.length == 1)) { return findByNotC_G_P_S(categoryIds[0], groupId, parentCategoryIds[0], status, start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { StringUtil.merge(categoryIds), groupId, StringUtil.merge(parentCategoryIds), status }; } else { finderArgs = new Object[] { StringUtil.merge(categoryIds), groupId, StringUtil.merge(parentCategoryIds), status, start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBCategory mbCategory : list) { if (!ArrayUtil.contains(categoryIds, mbCategory.getCategoryId()) || (groupId != mbCategory.getGroupId()) || !ArrayUtil.contains(parentCategoryIds, mbCategory.getParentCategoryId()) || (status != mbCategory.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBCATEGORY_WHERE); if (categoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7); query.append(StringUtil.merge(categoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_NOTC_G_P_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ? from the database. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status */ @Override public void removeByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status) { for (MBCategory mbCategory : findByNotC_G_P_S(categoryId, groupId, parentCategoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbCategory); } } /** * Returns the number of message boards categories where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @return the number of matching message boards categories */ @Override public int countByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status) { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S; Object[] finderArgs = new Object[] { categoryId, groupId, parentCategoryId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ? and status = ?. * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @return the number of matching message boards categories */ @Override public int countByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status) { if (categoryIds == null) { categoryIds = new long[0]; } else if (categoryIds.length > 1) { categoryIds = ArrayUtil.unique(categoryIds); Arrays.sort(categoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } Object[] finderArgs = new Object[] { StringUtil.merge(categoryIds), groupId, StringUtil.merge(parentCategoryIds), status }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBCATEGORY_WHERE); if (categoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7); query.append(StringUtil.merge(categoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_NOTC_G_P_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards categories that the user has permission to view where categoryId ≠ ? and groupId = ? and parentCategoryId = ? and status = ?. * * @param categoryId the category ID * @param groupId the group ID * @param parentCategoryId the parent category ID * @param status the status * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByNotC_G_P_S(long categoryId, long groupId, long parentCategoryId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByNotC_G_P_S(categoryId, groupId, parentCategoryId, status); } StringBundler query = new StringBundler(5); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of message boards categories that the user has permission to view where categoryId ≠ all ? and groupId = ? and parentCategoryId = any ? and status = ?. * * @param categoryIds the category IDs * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param status the status * @return the number of matching message boards categories that the user has permission to view */ @Override public int filterCountByNotC_G_P_S(long[] categoryIds, long groupId, long[] parentCategoryIds, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByNotC_G_P_S(categoryIds, groupId, parentCategoryIds, status); } if (categoryIds == null) { categoryIds = new long[0]; } else if (categoryIds.length > 1) { categoryIds = ArrayUtil.unique(categoryIds); Arrays.sort(categoryIds); } if (parentCategoryIds == null) { parentCategoryIds = new long[0]; } else if (parentCategoryIds.length > 1) { parentCategoryIds = ArrayUtil.unique(parentCategoryIds); Arrays.sort(parentCategoryIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); if (categoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7); query.append(StringUtil.merge(categoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_S_GROUPID_2); if (parentCategoryIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7); query.append(StringUtil.merge(parentCategoryIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_NOTC_G_P_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_2 = "mbCategory.categoryId != ? AND "; private static final String _FINDER_COLUMN_NOTC_G_P_S_CATEGORYID_7 = "mbCategory.categoryId NOT IN ("; private static final String _FINDER_COLUMN_NOTC_G_P_S_GROUPID_2 = "mbCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_2 = "mbCategory.parentCategoryId = ? AND "; private static final String _FINDER_COLUMN_NOTC_G_P_S_PARENTCATEGORYID_7 = "mbCategory.parentCategoryId IN ("; private static final String _FINDER_COLUMN_NOTC_G_P_S_STATUS_2 = "mbCategory.status = ?"; public MBCategoryPersistenceImpl() { setModelClass(MBCategory.class); try { Field field = ReflectionUtil.getDeclaredField(BasePersistenceImpl.class, "_dbColumnNames"); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("uuid", "uuid_"); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * Caches the message boards category in the entity cache if it is enabled. * * @param mbCategory the message boards category */ @Override public void cacheResult(MBCategory mbCategory) { entityCache.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory); finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, new Object[] { mbCategory.getUuid(), mbCategory.getGroupId() }, mbCategory); mbCategory.resetOriginalValues(); } /** * Caches the message boards categories in the entity cache if it is enabled. * * @param mbCategories the message boards categories */ @Override public void cacheResult(List<MBCategory> mbCategories) { for (MBCategory mbCategory : mbCategories) { if (entityCache.getResult( MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, mbCategory.getPrimaryKey()) == null) { cacheResult(mbCategory); } else { mbCategory.resetOriginalValues(); } } } /** * Clears the cache for all message boards categories. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(MBCategoryImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the message boards category. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(MBCategory mbCategory) { entityCache.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, mbCategory.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((MBCategoryModelImpl)mbCategory, true); } @Override public void clearCache(List<MBCategory> mbCategories) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (MBCategory mbCategory : mbCategories) { entityCache.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, mbCategory.getPrimaryKey()); clearUniqueFindersCache((MBCategoryModelImpl)mbCategory, true); } } protected void cacheUniqueFindersCache( MBCategoryModelImpl mbCategoryModelImpl) { Object[] args = new Object[] { mbCategoryModelImpl.getUuid(), mbCategoryModelImpl.getGroupId() }; finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args, mbCategoryModelImpl, false); } protected void clearUniqueFindersCache( MBCategoryModelImpl mbCategoryModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { mbCategoryModelImpl.getUuid(), mbCategoryModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); } if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalUuid(), mbCategoryModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); } } /** * Creates a new message boards category with the primary key. Does not add the message boards category to the database. * * @param categoryId the primary key for the new message boards category * @return the new message boards category */ @Override public MBCategory create(long categoryId) { MBCategory mbCategory = new MBCategoryImpl(); mbCategory.setNew(true); mbCategory.setPrimaryKey(categoryId); String uuid = PortalUUIDUtil.generate(); mbCategory.setUuid(uuid); mbCategory.setCompanyId(companyProvider.getCompanyId()); return mbCategory; } /** * Removes the message boards category with the primary key from the database. Also notifies the appropriate model listeners. * * @param categoryId the primary key of the message boards category * @return the message boards category that was removed * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory remove(long categoryId) throws NoSuchCategoryException { return remove((Serializable)categoryId); } /** * Removes the message boards category with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the message boards category * @return the message boards category that was removed * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory remove(Serializable primaryKey) throws NoSuchCategoryException { Session session = null; try { session = openSession(); MBCategory mbCategory = (MBCategory)session.get(MBCategoryImpl.class, primaryKey); if (mbCategory == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(mbCategory); } catch (NoSuchCategoryException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected MBCategory removeImpl(MBCategory mbCategory) { mbCategory = toUnwrappedModel(mbCategory); Session session = null; try { session = openSession(); if (!session.contains(mbCategory)) { mbCategory = (MBCategory)session.get(MBCategoryImpl.class, mbCategory.getPrimaryKeyObj()); } if (mbCategory != null) { session.delete(mbCategory); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (mbCategory != null) { clearCache(mbCategory); } return mbCategory; } @Override public MBCategory updateImpl(MBCategory mbCategory) { mbCategory = toUnwrappedModel(mbCategory); boolean isNew = mbCategory.isNew(); MBCategoryModelImpl mbCategoryModelImpl = (MBCategoryModelImpl)mbCategory; if (Validator.isNull(mbCategory.getUuid())) { String uuid = PortalUUIDUtil.generate(); mbCategory.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (mbCategory.getCreateDate() == null)) { if (serviceContext == null) { mbCategory.setCreateDate(now); } else { mbCategory.setCreateDate(serviceContext.getCreateDate(now)); } } if (!mbCategoryModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { mbCategory.setModifiedDate(now); } else { mbCategory.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (mbCategory.isNew()) { session.save(mbCategory); mbCategory.setNew(false); } else { mbCategory = (MBCategory)session.merge(mbCategory); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!MBCategoryModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { mbCategoryModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { mbCategoryModelImpl.getUuid(), mbCategoryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { mbCategoryModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { mbCategoryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { mbCategoryModelImpl.getGroupId(), mbCategoryModelImpl.getParentCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P, args); args = new Object[] { mbCategoryModelImpl.getGroupId(), mbCategoryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); args = new Object[] { mbCategoryModelImpl.getCompanyId(), mbCategoryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S, args); args = new Object[] { mbCategoryModelImpl.getGroupId(), mbCategoryModelImpl.getParentCategoryId(), mbCategoryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S, args); finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL, FINDER_ARGS_EMPTY); } else { if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { mbCategoryModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalUuid(), mbCategoryModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { mbCategoryModelImpl.getUuid(), mbCategoryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { mbCategoryModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); } if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { mbCategoryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); } if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalGroupId(), mbCategoryModelImpl.getOriginalParentCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P, args); args = new Object[] { mbCategoryModelImpl.getGroupId(), mbCategoryModelImpl.getParentCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P, args); } if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalGroupId(), mbCategoryModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); args = new Object[] { mbCategoryModelImpl.getGroupId(), mbCategoryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); } if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalCompanyId(), mbCategoryModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S, args); args = new Object[] { mbCategoryModelImpl.getCompanyId(), mbCategoryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S, args); } if ((mbCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbCategoryModelImpl.getOriginalGroupId(), mbCategoryModelImpl.getOriginalParentCategoryId(), mbCategoryModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S, args); args = new Object[] { mbCategoryModelImpl.getGroupId(), mbCategoryModelImpl.getParentCategoryId(), mbCategoryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S, args); } } entityCache.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, mbCategory.getPrimaryKey(), mbCategory, false); clearUniqueFindersCache(mbCategoryModelImpl, false); cacheUniqueFindersCache(mbCategoryModelImpl); mbCategory.resetOriginalValues(); return mbCategory; } protected MBCategory toUnwrappedModel(MBCategory mbCategory) { if (mbCategory instanceof MBCategoryImpl) { return mbCategory; } MBCategoryImpl mbCategoryImpl = new MBCategoryImpl(); mbCategoryImpl.setNew(mbCategory.isNew()); mbCategoryImpl.setPrimaryKey(mbCategory.getPrimaryKey()); mbCategoryImpl.setUuid(mbCategory.getUuid()); mbCategoryImpl.setCategoryId(mbCategory.getCategoryId()); mbCategoryImpl.setGroupId(mbCategory.getGroupId()); mbCategoryImpl.setCompanyId(mbCategory.getCompanyId()); mbCategoryImpl.setUserId(mbCategory.getUserId()); mbCategoryImpl.setUserName(mbCategory.getUserName()); mbCategoryImpl.setCreateDate(mbCategory.getCreateDate()); mbCategoryImpl.setModifiedDate(mbCategory.getModifiedDate()); mbCategoryImpl.setParentCategoryId(mbCategory.getParentCategoryId()); mbCategoryImpl.setName(mbCategory.getName()); mbCategoryImpl.setDescription(mbCategory.getDescription()); mbCategoryImpl.setDisplayStyle(mbCategory.getDisplayStyle()); mbCategoryImpl.setThreadCount(mbCategory.getThreadCount()); mbCategoryImpl.setMessageCount(mbCategory.getMessageCount()); mbCategoryImpl.setLastPostDate(mbCategory.getLastPostDate()); mbCategoryImpl.setLastPublishDate(mbCategory.getLastPublishDate()); mbCategoryImpl.setStatus(mbCategory.getStatus()); mbCategoryImpl.setStatusByUserId(mbCategory.getStatusByUserId()); mbCategoryImpl.setStatusByUserName(mbCategory.getStatusByUserName()); mbCategoryImpl.setStatusDate(mbCategory.getStatusDate()); return mbCategoryImpl; } /** * Returns the message boards category with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found. * * @param primaryKey the primary key of the message boards category * @return the message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory findByPrimaryKey(Serializable primaryKey) throws NoSuchCategoryException { MBCategory mbCategory = fetchByPrimaryKey(primaryKey); if (mbCategory == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return mbCategory; } /** * Returns the message boards category with the primary key or throws a {@link NoSuchCategoryException} if it could not be found. * * @param categoryId the primary key of the message boards category * @return the message boards category * @throws NoSuchCategoryException if a message boards category with the primary key could not be found */ @Override public MBCategory findByPrimaryKey(long categoryId) throws NoSuchCategoryException { return findByPrimaryKey((Serializable)categoryId); } /** * Returns the message boards category with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the message boards category * @return the message boards category, or <code>null</code> if a message boards category with the primary key could not be found */ @Override public MBCategory fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, primaryKey); if (serializable == nullModel) { return null; } MBCategory mbCategory = (MBCategory)serializable; if (mbCategory == null) { Session session = null; try { session = openSession(); mbCategory = (MBCategory)session.get(MBCategoryImpl.class, primaryKey); if (mbCategory != null) { cacheResult(mbCategory); } else { entityCache.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return mbCategory; } /** * Returns the message boards category with the primary key or returns <code>null</code> if it could not be found. * * @param categoryId the primary key of the message boards category * @return the message boards category, or <code>null</code> if a message boards category with the primary key could not be found */ @Override public MBCategory fetchByPrimaryKey(long categoryId) { return fetchByPrimaryKey((Serializable)categoryId); } @Override public Map<Serializable, MBCategory> fetchByPrimaryKeys( Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, MBCategory> map = new HashMap<Serializable, MBCategory>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); MBCategory mbCategory = fetchByPrimaryKey(primaryKey); if (mbCategory != null) { map.put(primaryKey, mbCategory); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (MBCategory)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_MBCATEGORY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (MBCategory mbCategory : (List<MBCategory>)q.list()) { map.put(mbCategory.getPrimaryKeyObj(), mbCategory); cacheResult(mbCategory); uncachedPrimaryKeys.remove(mbCategory.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(MBCategoryModelImpl.ENTITY_CACHE_ENABLED, MBCategoryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the message boards categories. * * @return the message boards categories */ @Override public List<MBCategory> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards categories. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @return the range of message boards categories */ @Override public List<MBCategory> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the message boards categories. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of message boards categories */ @Override public List<MBCategory> findAll(int start, int end, OrderByComparator<MBCategory> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the message boards categories. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MBCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of message boards categories */ @Override public List<MBCategory> findAll(int start, int end, OrderByComparator<MBCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL; finderArgs = new Object[] { start, end, orderByComparator }; } List<MBCategory> list = null; if (retrieveFromCache) { list = (List<MBCategory>)finderCache.getResult(finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_MBCATEGORY); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_MBCATEGORY; if (pagination) { sql = sql.concat(MBCategoryModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the message boards categories from the database. * */ @Override public void removeAll() { for (MBCategory mbCategory : findAll()) { remove(mbCategory); } } /** * Returns the number of message boards categories. * * @return the number of message boards categories */ @Override public int countAll() { Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_MBCATEGORY); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } @Override public Set<String> getBadColumnNames() { return _badColumnNames; } @Override protected Map<String, Integer> getTableColumnsMap() { return MBCategoryModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the message boards category persistence. */ public void afterPropertiesSet() { } public void destroy() { entityCache.removeCache(MBCategoryImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; protected EntityCache entityCache = EntityCacheUtil.getEntityCache(); protected FinderCache finderCache = FinderCacheUtil.getFinderCache(); private static final String _SQL_SELECT_MBCATEGORY = "SELECT mbCategory FROM MBCategory mbCategory"; private static final String _SQL_SELECT_MBCATEGORY_WHERE_PKS_IN = "SELECT mbCategory FROM MBCategory mbCategory WHERE categoryId IN ("; private static final String _SQL_SELECT_MBCATEGORY_WHERE = "SELECT mbCategory FROM MBCategory mbCategory WHERE "; private static final String _SQL_COUNT_MBCATEGORY = "SELECT COUNT(mbCategory) FROM MBCategory mbCategory"; private static final String _SQL_COUNT_MBCATEGORY_WHERE = "SELECT COUNT(mbCategory) FROM MBCategory mbCategory WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbCategory.categoryId"; private static final String _FILTER_SQL_SELECT_MBCATEGORY_WHERE = "SELECT DISTINCT {mbCategory.*} FROM MBCategory mbCategory WHERE "; private static final String _FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {MBCategory.*} FROM (SELECT DISTINCT mbCategory.categoryId FROM MBCategory mbCategory WHERE "; private static final String _FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN MBCategory ON TEMP_TABLE.categoryId = MBCategory.categoryId"; private static final String _FILTER_SQL_COUNT_MBCATEGORY_WHERE = "SELECT COUNT(DISTINCT mbCategory.categoryId) AS COUNT_VALUE FROM MBCategory mbCategory WHERE "; private static final String _FILTER_ENTITY_ALIAS = "mbCategory"; private static final String _FILTER_ENTITY_TABLE = "MBCategory"; private static final String _ORDER_BY_ENTITY_ALIAS = "mbCategory."; private static final String _ORDER_BY_ENTITY_TABLE = "MBCategory."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBCategory exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBCategory exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(MBCategoryPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] { "uuid" }); }