/** * 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.NoSuchMessageException; import com.liferay.message.boards.kernel.model.MBMessage; import com.liferay.message.boards.kernel.service.persistence.MBMessagePersistence; 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.exception.SystemException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.sanitizer.Sanitizer; import com.liferay.portal.kernel.sanitizer.SanitizerException; import com.liferay.portal.kernel.sanitizer.SanitizerUtil; import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal; 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.ContentTypes; import com.liferay.portal.kernel.util.GetterUtil; 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.MBMessageImpl; import com.liferay.portlet.messageboards.model.impl.MBMessageModelImpl; 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 message service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see MBMessagePersistence * @see com.liferay.message.boards.kernel.service.persistence.MBMessageUtil * @generated */ @ProviderType public class MBMessagePersistenceImpl extends BasePersistenceImpl<MBMessage> implements MBMessagePersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link MBMessageUtil} to access the message-boards message persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = MBMessageImpl.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(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.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(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.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(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] { String.class.getName() }, MBMessageModelImpl.UUID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] { String.class.getName() }); /** * Returns all the message-boards messages where uuid = ?. * * @param uuid the uuid * @return the matching message-boards messages */ @Override public List<MBMessage> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByUuid(String uuid, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByUuid(String uuid, int start, int end, OrderByComparator<MBMessage> 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<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if (!Objects.equals(uuid, mbMessage.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_MBMESSAGE_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(MBMessageModelImpl.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<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByUuid_First(String uuid, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByUuid_First(uuid, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByUuid_First(String uuid, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByUuid_Last(String uuid, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByUuid_Last(uuid, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByUuid_Last(String uuid, OrderByComparator<MBMessage> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<MBMessage> list = findByUuid(uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where uuid = ?. * * @param messageId the primary key of the current message-boards message * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByUuid_PrevAndNext(long messageId, String uuid, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByUuid_PrevAndNext(session, mbMessage, uuid, orderByComparator, true); array[1] = mbMessage; array[2] = getByUuid_PrevAndNext(session, mbMessage, uuid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByUuid_PrevAndNext(Session session, MBMessage mbMessage, String uuid, OrderByComparator<MBMessage> 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_MBMESSAGE_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(MBMessageModelImpl.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(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (MBMessage mbMessage : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where uuid = ?. * * @param uuid the uuid * @return the number of matching message-boards messages */ @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_MBMESSAGE_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 = "mbMessage.uuid IS NULL"; private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMessage.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = '')"; public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G", new String[] { String.class.getName(), Long.class.getName() }, MBMessageModelImpl.UUID_COLUMN_BITMASK | MBMessageModelImpl.GROUPID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.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 message where uuid = ? and groupId = ? or throws a {@link NoSuchMessageException} if it could not be found. * * @param uuid the uuid * @param groupId the group ID * @return the matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByUUID_G(String uuid, long groupId) throws NoSuchMessageException { MBMessage mbMessage = fetchByUUID_G(uuid, groupId); if (mbMessage == 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 NoSuchMessageException(msg.toString()); } return mbMessage; } /** * Returns the message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByUUID_G(String uuid, long groupId) { return fetchByUUID_G(uuid, groupId, true); } /** * Returns the message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage 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 MBMessage) { MBMessage mbMessage = (MBMessage)result; if (!Objects.equals(uuid, mbMessage.getUuid()) || (groupId != mbMessage.getGroupId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_MBMESSAGE_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<MBMessage> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, list); } else { MBMessage mbMessage = list.get(0); result = mbMessage; cacheResult(mbMessage); if ((mbMessage.getUuid() == null) || !mbMessage.getUuid().equals(uuid) || (mbMessage.getGroupId() != groupId)) { finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, mbMessage); } } } 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 (MBMessage)result; } } /** * Removes the message-boards message where uuid = ? and groupId = ? from the database. * * @param uuid the uuid * @param groupId the group ID * @return the message-boards message that was removed */ @Override public MBMessage removeByUUID_G(String uuid, long groupId) throws NoSuchMessageException { MBMessage mbMessage = findByUUID_G(uuid, groupId); return remove(mbMessage); } /** * Returns the number of message-boards messages where uuid = ? and groupId = ?. * * @param uuid the uuid * @param groupId the group ID * @return the number of matching message-boards messages */ @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_MBMESSAGE_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 = "mbMessage.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMessage.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMessage.groupId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.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(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName() }, MBMessageModelImpl.UUID_COLUMN_BITMASK | MBMessageModelImpl.COMPANYID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.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 messages where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching message-boards messages */ @Override public List<MBMessage> 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 messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> 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 messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByUuid_C(uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<MBMessage> 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<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if (!Objects.equals(uuid, mbMessage.getUuid()) || (companyId != mbMessage.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_MBMESSAGE_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(MBMessageModelImpl.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<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByUuid_C_First(String uuid, long companyId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByUuid_C_First(uuid, companyId, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByUuid_C_First(String uuid, long companyId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByUuid_C_Last(String uuid, long companyId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByUuid_C_Last(uuid, companyId, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByUuid_C_Last(String uuid, long companyId, OrderByComparator<MBMessage> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<MBMessage> list = findByUuid_C(uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where uuid = ? and companyId = ?. * * @param messageId the primary key of the current message-boards message * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByUuid_C_PrevAndNext(long messageId, String uuid, long companyId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByUuid_C_PrevAndNext(session, mbMessage, uuid, companyId, orderByComparator, true); array[1] = mbMessage; array[2] = getByUuid_C_PrevAndNext(session, mbMessage, uuid, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByUuid_C_PrevAndNext(Session session, MBMessage mbMessage, String uuid, long companyId, OrderByComparator<MBMessage> 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_MBMESSAGE_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(MBMessageModelImpl.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(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages 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 (MBMessage mbMessage : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching message-boards messages */ @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_MBMESSAGE_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 = "mbMessage.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbMessage.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbMessage.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.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(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId", new String[] { Long.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId", new String[] { Long.class.getName() }); /** * Returns all the message-boards messages where groupId = ?. * * @param groupId the group ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByGroupId(long groupId) { return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByGroupId(long groupId, int start, int end) { return findByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByGroupId(long groupId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByGroupId(groupId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByGroupId(long groupId, int start, int end, OrderByComparator<MBMessage> 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<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByGroupId_First(long groupId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByGroupId_First(groupId, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByGroupId_First(long groupId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByGroupId(groupId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByGroupId_Last(long groupId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByGroupId_Last(groupId, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByGroupId_Last(long groupId, OrderByComparator<MBMessage> orderByComparator) { int count = countByGroupId(groupId); if (count == 0) { return null; } List<MBMessage> list = findByGroupId(groupId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ?. * * @param messageId the primary key of the current message-boards message * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByGroupId_PrevAndNext(long messageId, long groupId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByGroupId_PrevAndNext(session, mbMessage, groupId, orderByComparator, true); array[1] = mbMessage; array[2] = getByGroupId_PrevAndNext(session, mbMessage, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByGroupId_PrevAndNext(Session session, MBMessage mbMessage, long groupId, OrderByComparator<MBMessage> 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_MBMESSAGE_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(MBMessageModelImpl.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(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByGroupId(long groupId) { return filterFindByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByGroupId(long groupId, int start, int end) { return filterFindByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByGroupId(long groupId, int start, int end, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ?. * * @param messageId the primary key of the current message-boards message * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByGroupId_PrevAndNext(long messageId, long groupId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId_PrevAndNext(messageId, groupId, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByGroupId_PrevAndNext(session, mbMessage, groupId, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByGroupId_PrevAndNext(session, mbMessage, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByGroupId_PrevAndNext(Session session, MBMessage mbMessage, long groupId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where groupId = ? from the database. * * @param groupId the group ID */ @Override public void removeByGroupId(long groupId) { for (MBMessage mbMessage : findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ?. * * @param groupId the group ID * @return the number of matching message-boards messages */ @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_MBMESSAGE_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 messages that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the number of matching message-boards messages 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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 = "mbMessage.groupId = ? AND mbMessage.categoryId != -1"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.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(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId", new String[] { Long.class.getName() }, MBMessageModelImpl.COMPANYID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId", new String[] { Long.class.getName() }); /** * Returns all the message-boards messages where companyId = ?. * * @param companyId the company ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByCompanyId(long companyId) { return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByCompanyId(long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByCompanyId(long companyId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByCompanyId(companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByCompanyId(long companyId, int start, int end, OrderByComparator<MBMessage> 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<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((companyId != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByCompanyId_First(long companyId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByCompanyId_First(companyId, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByCompanyId_First(long companyId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByCompanyId(companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByCompanyId_Last(long companyId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByCompanyId_Last(companyId, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByCompanyId_Last(long companyId, OrderByComparator<MBMessage> orderByComparator) { int count = countByCompanyId(companyId); if (count == 0) { return null; } List<MBMessage> list = findByCompanyId(companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where companyId = ?. * * @param messageId the primary key of the current message-boards message * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByCompanyId_PrevAndNext(long messageId, long companyId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByCompanyId_PrevAndNext(session, mbMessage, companyId, orderByComparator, true); array[1] = mbMessage; array[2] = getByCompanyId_PrevAndNext(session, mbMessage, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByCompanyId_PrevAndNext(Session session, MBMessage mbMessage, long companyId, OrderByComparator<MBMessage> 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_MBMESSAGE_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(MBMessageModelImpl.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(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where companyId = ? from the database. * * @param companyId the company ID */ @Override public void removeByCompanyId(long companyId) { for (MBMessage mbMessage : findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where companyId = ?. * * @param companyId the company ID * @return the number of matching message-boards messages */ @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_MBMESSAGE_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 = "mbMessage.companyId = ? AND mbMessage.categoryId != -1"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId", new String[] { Long.class.getName() }, MBMessageModelImpl.USERID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId", new String[] { Long.class.getName() }); /** * Returns all the message-boards messages where userId = ?. * * @param userId the user ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByUserId(long userId) { return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where userId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByUserId(long userId, int start, int end) { return findByUserId(userId, start, end, null); } /** * Returns an ordered range of all the message-boards messages where userId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByUserId(long userId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByUserId(userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where userId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByUserId(long userId, int start, int end, OrderByComparator<MBMessage> 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_USERID; finderArgs = new Object[] { userId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID; finderArgs = new Object[] { userId, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((userId != mbMessage.getUserId())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_USERID_USERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(userId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where userId = ?. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByUserId_First(long userId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByUserId_First(userId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where userId = ?. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByUserId_First(long userId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByUserId(userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where userId = ?. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByUserId_Last(long userId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByUserId_Last(userId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where userId = ?. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByUserId_Last(long userId, OrderByComparator<MBMessage> orderByComparator) { int count = countByUserId(userId); if (count == 0) { return null; } List<MBMessage> list = findByUserId(userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where userId = ?. * * @param messageId the primary key of the current message-boards message * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByUserId_PrevAndNext(long messageId, long userId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByUserId_PrevAndNext(session, mbMessage, userId, orderByComparator, true); array[1] = mbMessage; array[2] = getByUserId_PrevAndNext(session, mbMessage, userId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByUserId_PrevAndNext(Session session, MBMessage mbMessage, long userId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_USERID_USERID_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(MBMessageModelImpl.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(userId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where userId = ? from the database. * * @param userId the user ID */ @Override public void removeByUserId(long userId) { for (MBMessage mbMessage : findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where userId = ?. * * @param userId the user ID * @return the number of matching message-boards messages */ @Override public int countByUserId(long userId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID; Object[] finderArgs = new Object[] { userId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_USERID_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); 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_USERID_USERID_2 = "mbMessage.userId = ? AND mbMessage.categoryId != -1"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByThreadId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByThreadId", new String[] { Long.class.getName() }, MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByThreadId", new String[] { Long.class.getName() }); /** * Returns all the message-boards messages where threadId = ?. * * @param threadId the thread ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByThreadId(long threadId) { return findByThreadId(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where threadId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByThreadId(long threadId, int start, int end) { return findByThreadId(threadId, start, end, null); } /** * Returns an ordered range of all the message-boards messages where threadId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByThreadId(long threadId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByThreadId(threadId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where threadId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByThreadId(long threadId, int start, int end, OrderByComparator<MBMessage> 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_THREADID; finderArgs = new Object[] { threadId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADID; finderArgs = new Object[] { threadId, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((threadId != mbMessage.getThreadId())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_THREADID_THREADID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(threadId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where threadId = ?. * * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByThreadId_First(long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByThreadId_First(threadId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where threadId = ?. * * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByThreadId_First(long threadId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByThreadId(threadId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where threadId = ?. * * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByThreadId_Last(long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByThreadId_Last(threadId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where threadId = ?. * * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByThreadId_Last(long threadId, OrderByComparator<MBMessage> orderByComparator) { int count = countByThreadId(threadId); if (count == 0) { return null; } List<MBMessage> list = findByThreadId(threadId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where threadId = ?. * * @param messageId the primary key of the current message-boards message * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByThreadId_PrevAndNext(long messageId, long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByThreadId_PrevAndNext(session, mbMessage, threadId, orderByComparator, true); array[1] = mbMessage; array[2] = getByThreadId_PrevAndNext(session, mbMessage, threadId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByThreadId_PrevAndNext(Session session, MBMessage mbMessage, long threadId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_THREADID_THREADID_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(MBMessageModelImpl.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(threadId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where threadId = ? from the database. * * @param threadId the thread ID */ @Override public void removeByThreadId(long threadId) { for (MBMessage mbMessage : findByThreadId(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where threadId = ?. * * @param threadId the thread ID * @return the number of matching message-boards messages */ @Override public int countByThreadId(long threadId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_THREADID; Object[] finderArgs = new Object[] { threadId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_THREADID_THREADID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(threadId); 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_THREADID_THREADID_2 = "mbMessage.threadId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByThreadReplies", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByThreadReplies", new String[] { Long.class.getName() }, MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByThreadReplies", new String[] { Long.class.getName() }); /** * Returns all the message-boards messages where threadId = ?. * * @param threadId the thread ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByThreadReplies(long threadId) { return findByThreadReplies(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where threadId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByThreadReplies(long threadId, int start, int end) { return findByThreadReplies(threadId, start, end, null); } /** * Returns an ordered range of all the message-boards messages where threadId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByThreadReplies(long threadId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByThreadReplies(threadId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where threadId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByThreadReplies(long threadId, int start, int end, OrderByComparator<MBMessage> 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_THREADREPLIES; finderArgs = new Object[] { threadId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADREPLIES; finderArgs = new Object[] { threadId, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((threadId != mbMessage.getThreadId())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(threadId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where threadId = ?. * * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByThreadReplies_First(long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByThreadReplies_First(threadId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where threadId = ?. * * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByThreadReplies_First(long threadId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByThreadReplies(threadId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where threadId = ?. * * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByThreadReplies_Last(long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByThreadReplies_Last(threadId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where threadId = ?. * * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByThreadReplies_Last(long threadId, OrderByComparator<MBMessage> orderByComparator) { int count = countByThreadReplies(threadId); if (count == 0) { return null; } List<MBMessage> list = findByThreadReplies(threadId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where threadId = ?. * * @param messageId the primary key of the current message-boards message * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByThreadReplies_PrevAndNext(long messageId, long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByThreadReplies_PrevAndNext(session, mbMessage, threadId, orderByComparator, true); array[1] = mbMessage; array[2] = getByThreadReplies_PrevAndNext(session, mbMessage, threadId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByThreadReplies_PrevAndNext(Session session, MBMessage mbMessage, long threadId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_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(MBMessageModelImpl.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(threadId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where threadId = ? from the database. * * @param threadId the thread ID */ @Override public void removeByThreadReplies(long threadId) { for (MBMessage mbMessage : findByThreadReplies(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where threadId = ?. * * @param threadId the thread ID * @return the number of matching message-boards messages */ @Override public int countByThreadReplies(long threadId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_THREADREPLIES; Object[] finderArgs = new Object[] { threadId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(threadId); 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_THREADREPLIES_THREADID_2 = "mbMessage.threadId = ? AND mbMessage.parentMessageId != 0"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U", 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_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U", new String[] { Long.class.getName(), Long.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.USERID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the message-boards messages where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByG_U(long groupId, long userId) { return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where groupId = ? and userId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByG_U(long groupId, long userId, int start, int end) { return findByG_U(groupId, userId, start, end, null); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and userId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByG_U(long groupId, long userId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByG_U(groupId, userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and userId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByG_U(long groupId, long userId, int start, int end, OrderByComparator<MBMessage> 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_U; finderArgs = new Object[] { groupId, userId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U; finderArgs = new Object[] { groupId, userId, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.getGroupId()) || (userId != mbMessage.getUserId())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(userId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_U_First(long groupId, long userId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_U_First(groupId, userId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_U_First(long groupId, long userId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByG_U(groupId, userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_U_Last(long groupId, long userId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_U_Last(groupId, userId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_U_Last(long groupId, long userId, OrderByComparator<MBMessage> orderByComparator) { int count = countByG_U(groupId, userId); if (count == 0) { return null; } List<MBMessage> list = findByG_U(groupId, userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ? and userId = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByG_U_PrevAndNext(long messageId, long groupId, long userId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByG_U_PrevAndNext(session, mbMessage, groupId, userId, orderByComparator, true); array[1] = mbMessage; array[2] = getByG_U_PrevAndNext(session, mbMessage, groupId, userId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByG_U_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long userId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_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(MBMessageModelImpl.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(userId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages that the user has permission to view where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @return the matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_U(long groupId, long userId) { return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages that the user has permission to view where groupId = ? and userId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_U(long groupId, long userId, int start, int end) { return filterFindByG_U(groupId, userId, start, end, null); } /** * Returns an ordered range of all the message-boards messages that the user has permissions to view where groupId = ? and userId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_U(long groupId, long userId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U(groupId, userId, 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ? and userId = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByG_U_PrevAndNext(long messageId, long groupId, long userId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_PrevAndNext(messageId, groupId, userId, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByG_U_PrevAndNext(session, mbMessage, groupId, userId, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByG_U_PrevAndNext(session, mbMessage, groupId, userId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByG_U_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long userId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where groupId = ? and userId = ? from the database. * * @param groupId the group ID * @param userId the user ID */ @Override public void removeByG_U(long groupId, long userId) { for (MBMessage mbMessage : findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @return the number of matching message-boards messages */ @Override public int countByG_U(long groupId, long userId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U; Object[] finderArgs = new Object[] { groupId, userId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_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(userId); 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 messages that the user has permission to view where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @return the number of matching message-boards messages that the user has permission to view */ @Override public int filterCountByG_U(long groupId, long userId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U(groupId, userId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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(userId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "mbMessage.groupId = ? AND "; private static final String _FINDER_COLUMN_G_U_USERID_2 = "mbMessage.userId = ? AND (mbMessage.categoryId != -1) AND (mbMessage.anonymous = [$FALSE$])"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C", 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_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C", new String[] { Long.class.getName(), Long.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the message-boards messages where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByG_C(long groupId, long categoryId) { return findByG_C(groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where groupId = ? and categoryId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByG_C(long groupId, long categoryId, int start, int end) { return findByG_C(groupId, categoryId, start, end, null); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByG_C(long groupId, long categoryId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByG_C(groupId, categoryId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByG_C(long groupId, long categoryId, int start, int end, OrderByComparator<MBMessage> 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_C; finderArgs = new Object[] { groupId, categoryId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C; finderArgs = new Object[] { groupId, categoryId, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.getGroupId()) || (categoryId != mbMessage.getCategoryId())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_GROUPID_2); query.append(_FINDER_COLUMN_G_C_CATEGORYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(categoryId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_First(long groupId, long categoryId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_First(groupId, categoryId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_First(long groupId, long categoryId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByG_C(groupId, categoryId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_Last(long groupId, long categoryId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_Last(groupId, categoryId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_Last(long groupId, long categoryId, OrderByComparator<MBMessage> orderByComparator) { int count = countByG_C(groupId, categoryId); if (count == 0) { return null; } List<MBMessage> list = findByG_C(groupId, categoryId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ? and categoryId = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByG_C_PrevAndNext(long messageId, long groupId, long categoryId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByG_C_PrevAndNext(session, mbMessage, groupId, categoryId, orderByComparator, true); array[1] = mbMessage; array[2] = getByG_C_PrevAndNext(session, mbMessage, groupId, categoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByG_C_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_GROUPID_2); query.append(_FINDER_COLUMN_G_C_CATEGORYID_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(MBMessageModelImpl.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(categoryId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @return the matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C(long groupId, long categoryId) { return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C(long groupId, long categoryId, int start, int end) { return filterFindByG_C(groupId, categoryId, start, end, null); } /** * Returns an ordered range of all the message-boards messages that the user has permissions to view where groupId = ? and categoryId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C(long groupId, long categoryId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C(groupId, categoryId, 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_GROUPID_2); query.append(_FINDER_COLUMN_G_C_CATEGORYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ? and categoryId = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByG_C_PrevAndNext(long messageId, long groupId, long categoryId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_PrevAndNext(messageId, groupId, categoryId, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByG_C_PrevAndNext(session, mbMessage, groupId, categoryId, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByG_C_PrevAndNext(session, mbMessage, groupId, categoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByG_C_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_GROUPID_2); query.append(_FINDER_COLUMN_G_C_CATEGORYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where groupId = ? and categoryId = ? from the database. * * @param groupId the group ID * @param categoryId the category ID */ @Override public void removeByG_C(long groupId, long categoryId) { for (MBMessage mbMessage : findByG_C(groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @return the number of matching message-boards messages */ @Override public int countByG_C(long groupId, long categoryId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C; Object[] finderArgs = new Object[] { groupId, categoryId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_GROUPID_2); query.append(_FINDER_COLUMN_G_C_CATEGORYID_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(categoryId); 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 messages that the user has permission to view where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @return the number of matching message-boards messages that the user has permission to view */ @Override public int filterCountByG_C(long groupId, long categoryId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C(groupId, categoryId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_GROUPID_2); query.append(_FINDER_COLUMN_G_C_CATEGORYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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(categoryId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMessage.groupId = ? AND "; private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMessage.categoryId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.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(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.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 messages where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> 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 messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> 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 messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByG_S(long groupId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByG_S(groupId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByG_S(long groupId, int status, int start, int end, OrderByComparator<MBMessage> 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<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.getGroupId()) || (status != mbMessage.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_MBMESSAGE_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(MBMessageModelImpl.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<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_S_First(long groupId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_S_First(groupId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_S_First(long groupId, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByG_S(groupId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_S_Last(long groupId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_S_Last(groupId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_S_Last(long groupId, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByG_S(groupId, status); if (count == 0) { return null; } List<MBMessage> list = findByG_S(groupId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByG_S_PrevAndNext(long messageId, long groupId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByG_S_PrevAndNext(session, mbMessage, groupId, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByG_S_PrevAndNext(session, mbMessage, groupId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByG_S_PrevAndNext(Session session, MBMessage mbMessage, long groupId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_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(MBMessageModelImpl.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(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages 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 messages that the user has permission to view */ @Override public List<MBMessage> 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 messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> 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 messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_S(long groupId, int status, int start, int end, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByG_S_PrevAndNext(long messageId, long groupId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S_PrevAndNext(messageId, groupId, status, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByG_S_PrevAndNext(session, mbMessage, groupId, status, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByG_S_PrevAndNext(session, mbMessage, groupId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByG_S_PrevAndNext(Session session, MBMessage mbMessage, long groupId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages 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 (MBMessage mbMessage : findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @return the number of matching message-boards messages */ @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_MBMESSAGE_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 messages 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 messages 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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 = "mbMessage.groupId = ? AND "; private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbMessage.status = ? AND mbMessage.categoryId != -1"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.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(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S", new String[] { Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.COMPANYID_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.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 messages where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> 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 messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> 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 messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByC_S(long companyId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByC_S(companyId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages 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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByC_S(long companyId, int status, int start, int end, OrderByComparator<MBMessage> 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<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((companyId != mbMessage.getCompanyId()) || (status != mbMessage.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_MBMESSAGE_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(MBMessageModelImpl.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<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByC_S_First(long companyId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByC_S_First(companyId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByC_S_First(long companyId, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByC_S(companyId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByC_S_Last(long companyId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByC_S_Last(companyId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } 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 NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByC_S_Last(long companyId, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByC_S(companyId, status); if (count == 0) { return null; } List<MBMessage> list = findByC_S(companyId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where companyId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByC_S_PrevAndNext(long messageId, long companyId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByC_S_PrevAndNext(session, mbMessage, companyId, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByC_S_PrevAndNext(session, mbMessage, companyId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByC_S_PrevAndNext(Session session, MBMessage mbMessage, long companyId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_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(MBMessageModelImpl.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(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages 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 (MBMessage mbMessage : findByC_S(companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @return the number of matching message-boards messages */ @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_MBMESSAGE_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 = "mbMessage.companyId = ? AND "; private static final String _FINDER_COLUMN_C_S_STATUS_2 = "mbMessage.status = ? AND mbMessage.categoryId != -1"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C", 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_U_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C", new String[] { Long.class.getName(), Long.class.getName() }, MBMessageModelImpl.USERID_COLUMN_BITMASK | MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C", new String[] { Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByU_C", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the message-boards messages where userId = ? and classNameId = ?. * * @param userId the user ID * @param classNameId the class name ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByU_C(long userId, long classNameId) { return findByU_C(userId, classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where userId = ? and classNameId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByU_C(long userId, long classNameId, int start, int end) { return findByU_C(userId, classNameId, start, end, null); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByU_C(long userId, long classNameId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByU_C(userId, classNameId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByU_C(long userId, long classNameId, int start, int end, OrderByComparator<MBMessage> 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_U_C; finderArgs = new Object[] { userId, classNameId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C; finderArgs = new Object[] { userId, classNameId, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((userId != mbMessage.getUserId()) || (classNameId != mbMessage.getClassNameId())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_USERID_2); query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(userId); qPos.add(classNameId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where userId = ? and classNameId = ?. * * @param userId the user ID * @param classNameId the class name ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByU_C_First(long userId, long classNameId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByU_C_First(userId, classNameId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where userId = ? and classNameId = ?. * * @param userId the user ID * @param classNameId the class name ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByU_C_First(long userId, long classNameId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByU_C(userId, classNameId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where userId = ? and classNameId = ?. * * @param userId the user ID * @param classNameId the class name ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByU_C_Last(long userId, long classNameId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByU_C_Last(userId, classNameId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where userId = ? and classNameId = ?. * * @param userId the user ID * @param classNameId the class name ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByU_C_Last(long userId, long classNameId, OrderByComparator<MBMessage> orderByComparator) { int count = countByU_C(userId, classNameId); if (count == 0) { return null; } List<MBMessage> list = findByU_C(userId, classNameId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where userId = ? and classNameId = ?. * * @param messageId the primary key of the current message-boards message * @param userId the user ID * @param classNameId the class name ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByU_C_PrevAndNext(long messageId, long userId, long classNameId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByU_C_PrevAndNext(session, mbMessage, userId, classNameId, orderByComparator, true); array[1] = mbMessage; array[2] = getByU_C_PrevAndNext(session, mbMessage, userId, classNameId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByU_C_PrevAndNext(Session session, MBMessage mbMessage, long userId, long classNameId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_USERID_2); query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_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(MBMessageModelImpl.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(userId); qPos.add(classNameId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages where userId = ? and classNameId = 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameIds the class name IDs * @return the matching message-boards messages */ @Override public List<MBMessage> findByU_C(long userId, long[] classNameIds) { return findByU_C(userId, classNameIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where userId = ? and classNameId = 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameIds the class name IDs * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByU_C(long userId, long[] classNameIds, int start, int end) { return findByU_C(userId, classNameIds, start, end, null); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameIds the class name IDs * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByU_C(long userId, long[] classNameIds, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByU_C(userId, classNameIds, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ?, 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByU_C(long userId, long[] classNameIds, int start, int end, OrderByComparator<MBMessage> orderByComparator, boolean retrieveFromCache) { if (classNameIds == null) { classNameIds = new long[0]; } else if (classNameIds.length > 1) { classNameIds = ArrayUtil.unique(classNameIds); Arrays.sort(classNameIds); } if (classNameIds.length == 1) { return findByU_C(userId, classNameIds[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[] { userId, StringUtil.merge(classNameIds) }; } else { finderArgs = new Object[] { userId, StringUtil.merge(classNameIds), start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((userId != mbMessage.getUserId()) || !ArrayUtil.contains(classNameIds, mbMessage.getClassNameId())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_USERID_2); if (classNameIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_7); query.append(StringUtil.merge(classNameIds)); 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(MBMessageModelImpl.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(userId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the message-boards messages where userId = ? and classNameId = ? from the database. * * @param userId the user ID * @param classNameId the class name ID */ @Override public void removeByU_C(long userId, long classNameId) { for (MBMessage mbMessage : findByU_C(userId, classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where userId = ? and classNameId = ?. * * @param userId the user ID * @param classNameId the class name ID * @return the number of matching message-boards messages */ @Override public int countByU_C(long userId, long classNameId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U_C; Object[] finderArgs = new Object[] { userId, classNameId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_USERID_2); query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(classNameId); 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 messages where userId = ? and classNameId = any ?. * * @param userId the user ID * @param classNameIds the class name IDs * @return the number of matching message-boards messages */ @Override public int countByU_C(long userId, long[] classNameIds) { if (classNameIds == null) { classNameIds = new long[0]; } else if (classNameIds.length > 1) { classNameIds = ArrayUtil.unique(classNameIds); Arrays.sort(classNameIds); } Object[] finderArgs = new Object[] { userId, StringUtil.merge(classNameIds) }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_C, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_USERID_2); if (classNameIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_7); query.append(StringUtil.merge(classNameIds)); 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(userId); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_C, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_C, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U_C_USERID_2 = "mbMessage.userId = ? AND "; private static final String _FINDER_COLUMN_U_C_CLASSNAMEID_2 = "mbMessage.classNameId = ?"; private static final String _FINDER_COLUMN_U_C_CLASSNAMEID_7 = "mbMessage.classNameId IN ("; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C", 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_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C", new String[] { Long.class.getName(), Long.class.getName() }, MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK | MBMessageModelImpl.CLASSPK_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the message-boards messages where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @return the matching message-boards messages */ @Override public List<MBMessage> findByC_C(long classNameId, long classPK) { return findByC_C(classNameId, classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where classNameId = ? and classPK = ?. * * <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 MBMessageModelImpl}. 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 classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByC_C(long classNameId, long classPK, int start, int end) { return findByC_C(classNameId, classPK, start, end, null); } /** * Returns an ordered range of all the message-boards messages where classNameId = ? and classPK = ?. * * <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 MBMessageModelImpl}. 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 classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByC_C(long classNameId, long classPK, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByC_C(classNameId, classPK, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where classNameId = ? and classPK = ?. * * <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 MBMessageModelImpl}. 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 classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByC_C(long classNameId, long classPK, int start, int end, OrderByComparator<MBMessage> 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_C; finderArgs = new Object[] { classNameId, classPK }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C; finderArgs = new Object[] { classNameId, classPK, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((classNameId != mbMessage.getClassNameId()) || (classPK != mbMessage.getClassPK())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_CLASSPK_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(classNameId); qPos.add(classPK); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByC_C_First(long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByC_C_First(classNameId, classPK, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByC_C_First(long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByC_C(classNameId, classPK, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByC_C_Last(long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByC_C_Last(classNameId, classPK, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByC_C_Last(long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) { int count = countByC_C(classNameId, classPK); if (count == 0) { return null; } List<MBMessage> list = findByC_C(classNameId, classPK, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where classNameId = ? and classPK = ?. * * @param messageId the primary key of the current message-boards message * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByC_C_PrevAndNext(long messageId, long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByC_C_PrevAndNext(session, mbMessage, classNameId, classPK, orderByComparator, true); array[1] = mbMessage; array[2] = getByC_C_PrevAndNext(session, mbMessage, classNameId, classPK, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByC_C_PrevAndNext(Session session, MBMessage mbMessage, long classNameId, long classPK, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_CLASSPK_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(MBMessageModelImpl.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(classNameId); qPos.add(classPK); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where classNameId = ? and classPK = ? from the database. * * @param classNameId the class name ID * @param classPK the class pk */ @Override public void removeByC_C(long classNameId, long classPK) { for (MBMessage mbMessage : findByC_C(classNameId, classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @return the number of matching message-boards messages */ @Override public int countByC_C(long classNameId, long classPK) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C; Object[] finderArgs = new Object[] { classNameId, classPK }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_CLASSPK_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); 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_C_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND "; private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "mbMessage.classPK = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_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_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_P", new String[] { Long.class.getName(), Long.class.getName() }, MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.PARENTMESSAGEID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_P", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the message-boards messages where threadId = ? and parentMessageId = ?. * * @param threadId the thread ID * @param parentMessageId the parent message ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByT_P(long threadId, long parentMessageId) { return findByT_P(threadId, parentMessageId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where threadId = ? and parentMessageId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param parentMessageId the parent message ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByT_P(long threadId, long parentMessageId, int start, int end) { return findByT_P(threadId, parentMessageId, start, end, null); } /** * Returns an ordered range of all the message-boards messages where threadId = ? and parentMessageId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param parentMessageId the parent message ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByT_P(long threadId, long parentMessageId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByT_P(threadId, parentMessageId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where threadId = ? and parentMessageId = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param parentMessageId the parent message ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByT_P(long threadId, long parentMessageId, int start, int end, OrderByComparator<MBMessage> 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_T_P; finderArgs = new Object[] { threadId, parentMessageId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_P; finderArgs = new Object[] { threadId, parentMessageId, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((threadId != mbMessage.getThreadId()) || (parentMessageId != mbMessage.getParentMessageId())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_P_THREADID_2); query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(threadId); qPos.add(parentMessageId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where threadId = ? and parentMessageId = ?. * * @param threadId the thread ID * @param parentMessageId the parent message ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByT_P_First(long threadId, long parentMessageId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByT_P_First(threadId, parentMessageId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(", parentMessageId="); msg.append(parentMessageId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where threadId = ? and parentMessageId = ?. * * @param threadId the thread ID * @param parentMessageId the parent message ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByT_P_First(long threadId, long parentMessageId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByT_P(threadId, parentMessageId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where threadId = ? and parentMessageId = ?. * * @param threadId the thread ID * @param parentMessageId the parent message ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByT_P_Last(long threadId, long parentMessageId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByT_P_Last(threadId, parentMessageId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(", parentMessageId="); msg.append(parentMessageId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where threadId = ? and parentMessageId = ?. * * @param threadId the thread ID * @param parentMessageId the parent message ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByT_P_Last(long threadId, long parentMessageId, OrderByComparator<MBMessage> orderByComparator) { int count = countByT_P(threadId, parentMessageId); if (count == 0) { return null; } List<MBMessage> list = findByT_P(threadId, parentMessageId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where threadId = ? and parentMessageId = ?. * * @param messageId the primary key of the current message-boards message * @param threadId the thread ID * @param parentMessageId the parent message ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByT_P_PrevAndNext(long messageId, long threadId, long parentMessageId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByT_P_PrevAndNext(session, mbMessage, threadId, parentMessageId, orderByComparator, true); array[1] = mbMessage; array[2] = getByT_P_PrevAndNext(session, mbMessage, threadId, parentMessageId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByT_P_PrevAndNext(Session session, MBMessage mbMessage, long threadId, long parentMessageId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_P_THREADID_2); query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_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(MBMessageModelImpl.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(threadId); qPos.add(parentMessageId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where threadId = ? and parentMessageId = ? from the database. * * @param threadId the thread ID * @param parentMessageId the parent message ID */ @Override public void removeByT_P(long threadId, long parentMessageId) { for (MBMessage mbMessage : findByT_P(threadId, parentMessageId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where threadId = ? and parentMessageId = ?. * * @param threadId the thread ID * @param parentMessageId the parent message ID * @return the number of matching message-boards messages */ @Override public int countByT_P(long threadId, long parentMessageId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_T_P; Object[] finderArgs = new Object[] { threadId, parentMessageId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_P_THREADID_2); query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(threadId); qPos.add(parentMessageId); 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_T_P_THREADID_2 = "mbMessage.threadId = ? AND "; private static final String _FINDER_COLUMN_T_P_PARENTMESSAGEID_2 = "mbMessage.parentMessageId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_A", new String[] { Long.class.getName(), Boolean.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_A", new String[] { Long.class.getName(), Boolean.class.getName() }, MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.ANSWER_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_A", new String[] { Long.class.getName(), Boolean.class.getName() }); /** * Returns all the message-boards messages where threadId = ? and answer = ?. * * @param threadId the thread ID * @param answer the answer * @return the matching message-boards messages */ @Override public List<MBMessage> findByT_A(long threadId, boolean answer) { return findByT_A(threadId, answer, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where threadId = ? and answer = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param answer the answer * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByT_A(long threadId, boolean answer, int start, int end) { return findByT_A(threadId, answer, start, end, null); } /** * Returns an ordered range of all the message-boards messages where threadId = ? and answer = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param answer the answer * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByT_A(long threadId, boolean answer, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByT_A(threadId, answer, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where threadId = ? and answer = ?. * * <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 MBMessageModelImpl}. 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 threadId the thread ID * @param answer the answer * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByT_A(long threadId, boolean answer, int start, int end, OrderByComparator<MBMessage> 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_T_A; finderArgs = new Object[] { threadId, answer }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A; finderArgs = new Object[] { threadId, answer, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((threadId != mbMessage.getThreadId()) || (answer != mbMessage.getAnswer())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_A_THREADID_2); query.append(_FINDER_COLUMN_T_A_ANSWER_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(threadId); qPos.add(answer); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where threadId = ? and answer = ?. * * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByT_A_First(long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByT_A_First(threadId, answer, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(", answer="); msg.append(answer); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where threadId = ? and answer = ?. * * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByT_A_First(long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByT_A(threadId, answer, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where threadId = ? and answer = ?. * * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByT_A_Last(long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByT_A_Last(threadId, answer, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(", answer="); msg.append(answer); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where threadId = ? and answer = ?. * * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByT_A_Last(long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) { int count = countByT_A(threadId, answer); if (count == 0) { return null; } List<MBMessage> list = findByT_A(threadId, answer, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where threadId = ? and answer = ?. * * @param messageId the primary key of the current message-boards message * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByT_A_PrevAndNext(long messageId, long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByT_A_PrevAndNext(session, mbMessage, threadId, answer, orderByComparator, true); array[1] = mbMessage; array[2] = getByT_A_PrevAndNext(session, mbMessage, threadId, answer, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByT_A_PrevAndNext(Session session, MBMessage mbMessage, long threadId, boolean answer, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_A_THREADID_2); query.append(_FINDER_COLUMN_T_A_ANSWER_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(MBMessageModelImpl.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(threadId); qPos.add(answer); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where threadId = ? and answer = ? from the database. * * @param threadId the thread ID * @param answer the answer */ @Override public void removeByT_A(long threadId, boolean answer) { for (MBMessage mbMessage : findByT_A(threadId, answer, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where threadId = ? and answer = ?. * * @param threadId the thread ID * @param answer the answer * @return the number of matching message-boards messages */ @Override public int countByT_A(long threadId, boolean answer) { FinderPath finderPath = FINDER_PATH_COUNT_BY_T_A; Object[] finderArgs = new Object[] { threadId, answer }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_A_THREADID_2); query.append(_FINDER_COLUMN_T_A_ANSWER_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(threadId); qPos.add(answer); 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_T_A_THREADID_2 = "mbMessage.threadId = ? AND "; private static final String _FINDER_COLUMN_T_A_ANSWER_2 = "mbMessage.answer = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_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_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_S", new String[] { Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_S", new String[] { Long.class.getName(), Integer.class.getName() }); /** * Returns all the message-boards messages where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByT_S(long threadId, int status) { return findByT_S(threadId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where threadId = ? 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 MBMessageModelImpl}. 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 threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByT_S(long threadId, int status, int start, int end) { return findByT_S(threadId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where threadId = ? 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 MBMessageModelImpl}. 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 threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByT_S(long threadId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByT_S(threadId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where threadId = ? 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 MBMessageModelImpl}. 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 threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByT_S(long threadId, int status, int start, int end, OrderByComparator<MBMessage> 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_T_S; finderArgs = new Object[] { threadId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S; finderArgs = new Object[] { threadId, status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((threadId != mbMessage.getThreadId()) || (status != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_S_THREADID_2); query.append(_FINDER_COLUMN_T_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(threadId); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByT_S_First(long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByT_S_First(threadId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByT_S_First(long threadId, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByT_S(threadId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByT_S_Last(long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByT_S_Last(threadId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByT_S_Last(long threadId, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByT_S(threadId, status); if (count == 0) { return null; } List<MBMessage> list = findByT_S(threadId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where threadId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param threadId the thread 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByT_S_PrevAndNext(long messageId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByT_S_PrevAndNext(session, mbMessage, threadId, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByT_S_PrevAndNext(session, mbMessage, threadId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByT_S_PrevAndNext(Session session, MBMessage mbMessage, long threadId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_S_THREADID_2); query.append(_FINDER_COLUMN_T_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(MBMessageModelImpl.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(threadId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where threadId = ? and status = ? from the database. * * @param threadId the thread ID * @param status the status */ @Override public void removeByT_S(long threadId, int status) { for (MBMessage mbMessage : findByT_S(threadId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @return the number of matching message-boards messages */ @Override public int countByT_S(long threadId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_T_S; Object[] finderArgs = new Object[] { threadId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_T_S_THREADID_2); query.append(_FINDER_COLUMN_T_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(threadId); 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_T_S_THREADID_2 = "mbMessage.threadId = ? AND "; private static final String _FINDER_COLUMN_T_S_STATUS_2 = "mbMessage.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TR_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByTR_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_TR_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTR_S", new String[] { Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_TR_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTR_S", new String[] { Long.class.getName(), Integer.class.getName() }); /** * Returns all the message-boards messages where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByTR_S(long threadId, int status) { return findByTR_S(threadId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where threadId = ? 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 MBMessageModelImpl}. 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 threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByTR_S(long threadId, int status, int start, int end) { return findByTR_S(threadId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where threadId = ? 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 MBMessageModelImpl}. 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 threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByTR_S(long threadId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByTR_S(threadId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where threadId = ? 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 MBMessageModelImpl}. 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 threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByTR_S(long threadId, int status, int start, int end, OrderByComparator<MBMessage> 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_TR_S; finderArgs = new Object[] { threadId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TR_S; finderArgs = new Object[] { threadId, status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((threadId != mbMessage.getThreadId()) || (status != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_TR_S_THREADID_2); query.append(_FINDER_COLUMN_TR_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(threadId); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByTR_S_First(long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByTR_S_First(threadId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByTR_S_First(long threadId, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByTR_S(threadId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByTR_S_Last(long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByTR_S_Last(threadId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("threadId="); msg.append(threadId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByTR_S_Last(long threadId, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByTR_S(threadId, status); if (count == 0) { return null; } List<MBMessage> list = findByTR_S(threadId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where threadId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param threadId the thread 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByTR_S_PrevAndNext(long messageId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByTR_S_PrevAndNext(session, mbMessage, threadId, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByTR_S_PrevAndNext(session, mbMessage, threadId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByTR_S_PrevAndNext(Session session, MBMessage mbMessage, long threadId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_TR_S_THREADID_2); query.append(_FINDER_COLUMN_TR_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(MBMessageModelImpl.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(threadId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where threadId = ? and status = ? from the database. * * @param threadId the thread ID * @param status the status */ @Override public void removeByTR_S(long threadId, int status) { for (MBMessage mbMessage : findByTR_S(threadId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where threadId = ? and status = ?. * * @param threadId the thread ID * @param status the status * @return the number of matching message-boards messages */ @Override public int countByTR_S(long threadId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_TR_S; Object[] finderArgs = new Object[] { threadId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_TR_S_THREADID_2); query.append(_FINDER_COLUMN_TR_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(threadId); 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_TR_S_THREADID_2 = "mbMessage.threadId = ? AND "; private static final String _FINDER_COLUMN_TR_S_STATUS_2 = "mbMessage.status = ? AND mbMessage.parentMessageId != 0"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_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_U_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.USERID_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the message-boards messages where groupId = ? and userId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByG_U_S(long groupId, long userId, int status) { return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where groupId = ? and userId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByG_U_S(long groupId, long userId, int status, int start, int end) { return findByG_U_S(groupId, userId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and userId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByG_U_S(long groupId, long userId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByG_U_S(groupId, userId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and userId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByG_U_S(long groupId, long userId, int status, int start, int end, OrderByComparator<MBMessage> 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_U_S; finderArgs = new Object[] { groupId, userId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S; finderArgs = new Object[] { groupId, userId, status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.getGroupId()) || (userId != mbMessage.getUserId()) || (status != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(userId); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where groupId = ? and userId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_U_S_First(long groupId, long userId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_U_S_First(groupId, userId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where groupId = ? and userId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_U_S_First(long groupId, long userId, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByG_U_S(groupId, userId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where groupId = ? and userId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_U_S_Last(long groupId, long userId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_U_S_Last(groupId, userId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where groupId = ? and userId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_U_S_Last(long groupId, long userId, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByG_U_S(groupId, userId, status); if (count == 0) { return null; } List<MBMessage> list = findByG_U_S(groupId, userId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ? and userId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param userId the user 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByG_U_S_PrevAndNext(long messageId, long groupId, long userId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByG_U_S_PrevAndNext(session, mbMessage, groupId, userId, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByG_U_S_PrevAndNext(session, mbMessage, groupId, userId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByG_U_S_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long userId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_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(MBMessageModelImpl.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(userId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages that the user has permission to view where groupId = ? and userId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_U_S(long groupId, long userId, int status) { return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages that the user has permission to view where groupId = ? and userId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_U_S(long groupId, long userId, int status, int start, int end) { return filterFindByG_U_S(groupId, userId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages that the user has permissions to view where groupId = ? and userId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_U_S(long groupId, long userId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_S(groupId, userId, 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ? and userId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param userId the user 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByG_U_S_PrevAndNext(long messageId, long groupId, long userId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_S_PrevAndNext(messageId, groupId, userId, status, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByG_U_S_PrevAndNext(session, mbMessage, groupId, userId, status, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByG_U_S_PrevAndNext(session, mbMessage, groupId, userId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByG_U_S_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long userId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where groupId = ? and userId = ? and status = ? from the database. * * @param groupId the group ID * @param userId the user ID * @param status the status */ @Override public void removeByG_U_S(long groupId, long userId, int status) { for (MBMessage mbMessage : findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ? and userId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the number of matching message-boards messages */ @Override public int countByG_U_S(long groupId, long userId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S; Object[] finderArgs = new Object[] { groupId, userId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_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(userId); 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 messages that the user has permission to view where groupId = ? and userId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the number of matching message-boards messages that the user has permission to view */ @Override public int filterCountByG_U_S(long groupId, long userId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U_S(groupId, userId, status); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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(userId); 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_U_S_GROUPID_2 = "mbMessage.groupId = ? AND "; private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "mbMessage.userId = ? AND "; private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "mbMessage.status = ? AND mbMessage.categoryId != -1"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_T", 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_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK | MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); /** * Returns all the message-boards messages where groupId = ? and categoryId = ? and threadId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @return the matching message-boards messages */ @Override public List<MBMessage> findByG_C_T(long groupId, long categoryId, long threadId) { return findByG_C_T(groupId, categoryId, threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByG_C_T(long groupId, long categoryId, long threadId, int start, int end) { return findByG_C_T(groupId, categoryId, threadId, start, end, null); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByG_C_T(long groupId, long categoryId, long threadId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByG_C_T(groupId, categoryId, threadId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByG_C_T(long groupId, long categoryId, long threadId, int start, int end, OrderByComparator<MBMessage> 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_C_T; finderArgs = new Object[] { groupId, categoryId, threadId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T; finderArgs = new Object[] { groupId, categoryId, threadId, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.getGroupId()) || (categoryId != mbMessage.getCategoryId()) || (threadId != mbMessage.getThreadId())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_THREADID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(categoryId); qPos.add(threadId); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where groupId = ? and categoryId = ? and threadId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_T_First(long groupId, long categoryId, long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_T_First(groupId, categoryId, threadId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(", threadId="); msg.append(threadId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_T_First(long groupId, long categoryId, long threadId, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByG_C_T(groupId, categoryId, threadId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_T_Last(long groupId, long categoryId, long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_T_Last(groupId, categoryId, threadId, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(", threadId="); msg.append(threadId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_T_Last(long groupId, long categoryId, long threadId, OrderByComparator<MBMessage> orderByComparator) { int count = countByG_C_T(groupId, categoryId, threadId); if (count == 0) { return null; } List<MBMessage> list = findByG_C_T(groupId, categoryId, threadId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByG_C_T_PrevAndNext(long messageId, long groupId, long categoryId, long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByG_C_T_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, orderByComparator, true); array[1] = mbMessage; array[2] = getByG_C_T_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByG_C_T_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, long threadId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_THREADID_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(MBMessageModelImpl.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(categoryId); qPos.add(threadId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @return the matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId, long threadId) { return filterFindByG_C_T(groupId, categoryId, threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId, long threadId, int start, int end) { return filterFindByG_C_T(groupId, categoryId, threadId, start, end, null); } /** * Returns an ordered range of all the message-boards messages that the user has permissions to view where groupId = ? and categoryId = ? and threadId = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId, long threadId, int start, int end, OrderByComparator<MBMessage> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_T(groupId, categoryId, threadId, 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_T_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_THREADID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(threadId); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByG_C_T_PrevAndNext(long messageId, long groupId, long categoryId, long threadId, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_T_PrevAndNext(messageId, groupId, categoryId, threadId, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByG_C_T_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByG_C_T_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByG_C_T_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, long threadId, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_T_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_THREADID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(threadId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID */ @Override public void removeByG_C_T(long groupId, long categoryId, long threadId) { for (MBMessage mbMessage : findByG_C_T(groupId, categoryId, threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ? and categoryId = ? and threadId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @return the number of matching message-boards messages */ @Override public int countByG_C_T(long groupId, long categoryId, long threadId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T; Object[] finderArgs = new Object[] { groupId, categoryId, threadId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_THREADID_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(categoryId); qPos.add(threadId); 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 messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @return the number of matching message-boards messages that the user has permission to view */ @Override public int filterCountByG_C_T(long groupId, long categoryId, long threadId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C_T(groupId, categoryId, threadId); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_THREADID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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(categoryId); qPos.add(threadId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "mbMessage.groupId = ? AND "; private static final String _FINDER_COLUMN_G_C_T_CATEGORYID_2 = "mbMessage.categoryId = ? AND "; private static final String _FINDER_COLUMN_G_C_T_THREADID_2 = "mbMessage.threadId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_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_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the message-boards messages where groupId = ? and categoryId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByG_C_S(long groupId, long categoryId, int status) { return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where groupId = ? and categoryId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByG_C_S(long groupId, long categoryId, int status, int start, int end) { return findByG_C_S(groupId, categoryId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByG_C_S(long groupId, long categoryId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByG_C_S(groupId, categoryId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByG_C_S(long groupId, long categoryId, int status, int start, int end, OrderByComparator<MBMessage> 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_C_S; finderArgs = new Object[] { groupId, categoryId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S; finderArgs = new Object[] { groupId, categoryId, status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.getGroupId()) || (categoryId != mbMessage.getCategoryId()) || (status != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(categoryId); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where groupId = ? and categoryId = ? and status = ?. * * @param groupId the group ID * @param categoryId the 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_S_First(long groupId, long categoryId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_S_First(groupId, categoryId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where groupId = ? and categoryId = ? and status = ?. * * @param groupId the group ID * @param categoryId the 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_S_First(long groupId, long categoryId, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByG_C_S(groupId, categoryId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ? and status = ?. * * @param groupId the group ID * @param categoryId the 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 message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_S_Last(long groupId, long categoryId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_S_Last(groupId, categoryId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ? and status = ?. * * @param groupId the group ID * @param categoryId the 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 message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_S_Last(long groupId, long categoryId, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByG_C_S(groupId, categoryId, status); if (count == 0) { return null; } List<MBMessage> list = findByG_C_S(groupId, categoryId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ? and categoryId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByG_C_S_PrevAndNext(long messageId, long groupId, long categoryId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByG_C_S_PrevAndNext(session, mbMessage, groupId, categoryId, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByG_C_S_PrevAndNext(session, mbMessage, groupId, categoryId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByG_C_S_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_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(MBMessageModelImpl.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(categoryId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param status the status * @return the matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId, int status) { return filterFindByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId, int status, int start, int end) { return filterFindByG_C_S(groupId, categoryId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages that the user has permissions to view where groupId = ? and categoryId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_S(groupId, categoryId, 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(status); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByG_C_S_PrevAndNext(long messageId, long groupId, long categoryId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_S_PrevAndNext(messageId, groupId, categoryId, status, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByG_C_S_PrevAndNext(session, mbMessage, groupId, categoryId, status, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByG_C_S_PrevAndNext(session, mbMessage, groupId, categoryId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByG_C_S_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where groupId = ? and categoryId = ? and status = ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @param status the status */ @Override public void removeByG_C_S(long groupId, long categoryId, int status) { for (MBMessage mbMessage : findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ? and categoryId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param status the status * @return the number of matching message-boards messages */ @Override public int countByG_C_S(long groupId, long categoryId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S; Object[] finderArgs = new Object[] { groupId, categoryId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_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(groupId); qPos.add(categoryId); 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 messages that the user has permission to view where groupId = ? and categoryId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param status the status * @return the number of matching message-boards messages that the user has permission to view */ @Override public int filterCountByG_C_S(long groupId, long categoryId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C_S(groupId, categoryId, status); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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(categoryId); 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_C_S_GROUPID_2 = "mbMessage.groupId = ? AND "; private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbMessage.categoryId = ? AND "; private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbMessage.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C_C", 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_WITHOUT_PAGINATION_FIND_BY_U_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C_C", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }, MBMessageModelImpl.USERID_COLUMN_BITMASK | MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK | MBMessageModelImpl.CLASSPK_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_C", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); /** * Returns all the message-boards messages where userId = ? and classNameId = ? and classPK = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @return the matching message-boards messages */ @Override public List<MBMessage> findByU_C_C(long userId, long classNameId, long classPK) { return findByU_C_C(userId, classNameId, classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where userId = ? and classNameId = ? and classPK = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByU_C_C(long userId, long classNameId, long classPK, int start, int end) { return findByU_C_C(userId, classNameId, classPK, start, end, null); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ? and classPK = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByU_C_C(long userId, long classNameId, long classPK, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByU_C_C(userId, classNameId, classPK, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ? and classPK = ?. * * <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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByU_C_C(long userId, long classNameId, long classPK, int start, int end, OrderByComparator<MBMessage> 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_U_C_C; finderArgs = new Object[] { userId, classNameId, classPK }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C; finderArgs = new Object[] { userId, classNameId, classPK, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((userId != mbMessage.getUserId()) || (classNameId != mbMessage.getClassNameId()) || (classPK != mbMessage.getClassPK())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_C_USERID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(userId); qPos.add(classNameId); qPos.add(classPK); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where userId = ? and classNameId = ? and classPK = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByU_C_C_First(long userId, long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByU_C_C_First(userId, classNameId, classPK, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where userId = ? and classNameId = ? and classPK = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByU_C_C_First(long userId, long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByU_C_C(userId, classNameId, classPK, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where userId = ? and classNameId = ? and classPK = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByU_C_C_Last(long userId, long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByU_C_C_Last(userId, classNameId, classPK, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where userId = ? and classNameId = ? and classPK = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByU_C_C_Last(long userId, long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) { int count = countByU_C_C(userId, classNameId, classPK); if (count == 0) { return null; } List<MBMessage> list = findByU_C_C(userId, classNameId, classPK, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where userId = ? and classNameId = ? and classPK = ?. * * @param messageId the primary key of the current message-boards message * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByU_C_C_PrevAndNext(long messageId, long userId, long classNameId, long classPK, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByU_C_C_PrevAndNext(session, mbMessage, userId, classNameId, classPK, orderByComparator, true); array[1] = mbMessage; array[2] = getByU_C_C_PrevAndNext(session, mbMessage, userId, classNameId, classPK, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByU_C_C_PrevAndNext(Session session, MBMessage mbMessage, long userId, long classNameId, long classPK, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_C_USERID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSPK_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(MBMessageModelImpl.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(userId); qPos.add(classNameId); qPos.add(classPK); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where userId = ? and classNameId = ? and classPK = ? from the database. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk */ @Override public void removeByU_C_C(long userId, long classNameId, long classPK) { for (MBMessage mbMessage : findByU_C_C(userId, classNameId, classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where userId = ? and classNameId = ? and classPK = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @return the number of matching message-boards messages */ @Override public int countByU_C_C(long userId, long classNameId, long classPK) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U_C_C; Object[] finderArgs = new Object[] { userId, classNameId, classPK }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_C_USERID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(classNameId); qPos.add(classPK); 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_U_C_C_USERID_2 = "mbMessage.userId = ? AND "; private static final String _FINDER_COLUMN_U_C_C_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND "; private static final String _FINDER_COLUMN_U_C_C_CLASSPK_2 = "mbMessage.classPK = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C_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_U_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.USERID_COLUMN_BITMASK | MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByU_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the message-boards messages where userId = ? and classNameId = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByU_C_S(long userId, long classNameId, int status) { return findByU_C_S(userId, classNameId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where userId = ? and classNameId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByU_C_S(long userId, long classNameId, int status, int start, int end) { return findByU_C_S(userId, classNameId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByU_C_S(long userId, long classNameId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByU_C_S(userId, classNameId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByU_C_S(long userId, long classNameId, int status, int start, int end, OrderByComparator<MBMessage> 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_U_C_S; finderArgs = new Object[] { userId, classNameId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_S; finderArgs = new Object[] { userId, classNameId, status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((userId != mbMessage.getUserId()) || (classNameId != mbMessage.getClassNameId()) || (status != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_S_USERID_2); query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(userId); qPos.add(classNameId); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where userId = ? and classNameId = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByU_C_S_First(long userId, long classNameId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByU_C_S_First(userId, classNameId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where userId = ? and classNameId = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByU_C_S_First(long userId, long classNameId, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByU_C_S(userId, classNameId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where userId = ? and classNameId = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByU_C_S_Last(long userId, long classNameId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByU_C_S_Last(userId, classNameId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where userId = ? and classNameId = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByU_C_S_Last(long userId, long classNameId, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByU_C_S(userId, classNameId, status); if (count == 0) { return null; } List<MBMessage> list = findByU_C_S(userId, classNameId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where userId = ? and classNameId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param userId the user ID * @param classNameId the class name 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByU_C_S_PrevAndNext(long messageId, long userId, long classNameId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByU_C_S_PrevAndNext(session, mbMessage, userId, classNameId, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByU_C_S_PrevAndNext(session, mbMessage, userId, classNameId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByU_C_S_PrevAndNext(Session session, MBMessage mbMessage, long userId, long classNameId, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_S_USERID_2); query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_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(MBMessageModelImpl.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(userId); qPos.add(classNameId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages where userId = ? and classNameId = 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameIds the class name IDs * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByU_C_S(long userId, long[] classNameIds, int status) { return findByU_C_S(userId, classNameIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where userId = ? and classNameId = 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameIds the class name IDs * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByU_C_S(long userId, long[] classNameIds, int status, int start, int end) { return findByU_C_S(userId, classNameIds, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameIds the class name IDs * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByU_C_S(long userId, long[] classNameIds, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByU_C_S(userId, classNameIds, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByU_C_S(long userId, long[] classNameIds, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator, boolean retrieveFromCache) { if (classNameIds == null) { classNameIds = new long[0]; } else if (classNameIds.length > 1) { classNameIds = ArrayUtil.unique(classNameIds); Arrays.sort(classNameIds); } if (classNameIds.length == 1) { return findByU_C_S(userId, classNameIds[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[] { userId, StringUtil.merge(classNameIds), status }; } else { finderArgs = new Object[] { userId, StringUtil.merge(classNameIds), status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((userId != mbMessage.getUserId()) || !ArrayUtil.contains(classNameIds, mbMessage.getClassNameId()) || (status != mbMessage.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_S_USERID_2); if (classNameIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_7); query.append(StringUtil.merge(classNameIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_U_C_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(MBMessageModelImpl.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(userId); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_S, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the message-boards messages where userId = ? and classNameId = ? and status = ? from the database. * * @param userId the user ID * @param classNameId the class name ID * @param status the status */ @Override public void removeByU_C_S(long userId, long classNameId, int status) { for (MBMessage mbMessage : findByU_C_S(userId, classNameId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where userId = ? and classNameId = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param status the status * @return the number of matching message-boards messages */ @Override public int countByU_C_S(long userId, long classNameId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U_C_S; Object[] finderArgs = new Object[] { userId, classNameId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_S_USERID_2); query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_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(userId); qPos.add(classNameId); 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 messages where userId = ? and classNameId = any ? and status = ?. * * @param userId the user ID * @param classNameIds the class name IDs * @param status the status * @return the number of matching message-boards messages */ @Override public int countByU_C_S(long userId, long[] classNameIds, int status) { if (classNameIds == null) { classNameIds = new long[0]; } else if (classNameIds.length > 1) { classNameIds = ArrayUtil.unique(classNameIds); Arrays.sort(classNameIds); } Object[] finderArgs = new Object[] { userId, StringUtil.merge(classNameIds), status }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_C_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_S_USERID_2); if (classNameIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_7); query.append(StringUtil.merge(classNameIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_U_C_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(userId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_C_S, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_C_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U_C_S_USERID_2 = "mbMessage.userId = ? AND "; private static final String _FINDER_COLUMN_U_C_S_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND "; private static final String _FINDER_COLUMN_U_C_S_CLASSNAMEID_7 = "mbMessage.classNameId IN ("; private static final String _FINDER_COLUMN_U_C_S_STATUS_2 = "mbMessage.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_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_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK | MBMessageModelImpl.CLASSPK_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the message-boards messages where classNameId = ? and classPK = ? and status = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByC_C_S(long classNameId, long classPK, int status) { return findByC_C_S(classNameId, classPK, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where classNameId = ? and classPK = ? 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 MBMessageModelImpl}. 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 classNameId the class name ID * @param classPK the class pk * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByC_C_S(long classNameId, long classPK, int status, int start, int end) { return findByC_C_S(classNameId, classPK, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where classNameId = ? and classPK = ? 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 MBMessageModelImpl}. 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 classNameId the class name ID * @param classPK the class pk * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByC_C_S(long classNameId, long classPK, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByC_C_S(classNameId, classPK, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where classNameId = ? and classPK = ? 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 MBMessageModelImpl}. 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 classNameId the class name ID * @param classPK the class pk * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByC_C_S(long classNameId, long classPK, int status, int start, int end, OrderByComparator<MBMessage> 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_C_S; finderArgs = new Object[] { classNameId, classPK, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_S; finderArgs = new Object[] { classNameId, classPK, status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((classNameId != mbMessage.getClassNameId()) || (classPK != mbMessage.getClassPK()) || (status != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_C_C_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(classNameId); qPos.add(classPK); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where classNameId = ? and classPK = ? and status = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByC_C_S_First(long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByC_C_S_First(classNameId, classPK, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where classNameId = ? and classPK = ? and status = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByC_C_S_First(long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByC_C_S(classNameId, classPK, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where classNameId = ? and classPK = ? and status = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByC_C_S_Last(long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByC_C_S_Last(classNameId, classPK, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where classNameId = ? and classPK = ? and status = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByC_C_S_Last(long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByC_C_S(classNameId, classPK, status); if (count == 0) { return null; } List<MBMessage> list = findByC_C_S(classNameId, classPK, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where classNameId = ? and classPK = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param classNameId the class name ID * @param classPK the class pk * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByC_C_S_PrevAndNext(long messageId, long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByC_C_S_PrevAndNext(session, mbMessage, classNameId, classPK, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByC_C_S_PrevAndNext(session, mbMessage, classNameId, classPK, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByC_C_S_PrevAndNext(Session session, MBMessage mbMessage, long classNameId, long classPK, int status, OrderByComparator<MBMessage> 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_C_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(MBMessageModelImpl.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(classNameId); qPos.add(classPK); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where classNameId = ? and classPK = ? and status = ? from the database. * * @param classNameId the class name ID * @param classPK the class pk * @param status the status */ @Override public void removeByC_C_S(long classNameId, long classPK, int status) { for (MBMessage mbMessage : findByC_C_S(classNameId, classPK, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where classNameId = ? and classPK = ? and status = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @return the number of matching message-boards messages */ @Override public int countByC_C_S(long classNameId, long classPK, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_S; Object[] finderArgs = new Object[] { classNameId, classPK, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_C_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(classNameId); qPos.add(classPK); 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_C_S_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND "; private static final String _FINDER_COLUMN_C_C_S_CLASSPK_2 = "mbMessage.classPK = ? AND "; private static final String _FINDER_COLUMN_C_C_S_STATUS_2 = "mbMessage.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_T_A", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Boolean.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T_A", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Boolean.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK | MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.ANSWER_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T_A", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Boolean.class.getName() }); /** * Returns all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @return the matching message-boards messages */ @Override public List<MBMessage> findByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer) { return findByG_C_T_A(groupId, categoryId, threadId, answer, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer, int start, int end) { return findByG_C_T_A(groupId, categoryId, threadId, answer, start, end, null); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByG_C_T_A(groupId, categoryId, threadId, answer, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer, int start, int end, OrderByComparator<MBMessage> 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_C_T_A; finderArgs = new Object[] { groupId, categoryId, threadId, answer }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T_A; finderArgs = new Object[] { groupId, categoryId, threadId, answer, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.getGroupId()) || (categoryId != mbMessage.getCategoryId()) || (threadId != mbMessage.getThreadId()) || (answer != mbMessage.getAnswer())) { 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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(categoryId); qPos.add(threadId); qPos.add(answer); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_T_A_First(long groupId, long categoryId, long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_T_A_First(groupId, categoryId, threadId, answer, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(", threadId="); msg.append(threadId); msg.append(", answer="); msg.append(answer); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_T_A_First(long groupId, long categoryId, long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByG_C_T_A(groupId, categoryId, threadId, answer, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_T_A_Last(long groupId, long categoryId, long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_T_A_Last(groupId, categoryId, threadId, answer, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(", threadId="); msg.append(threadId); msg.append(", answer="); msg.append(answer); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_T_A_Last(long groupId, long categoryId, long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) { int count = countByG_C_T_A(groupId, categoryId, threadId, answer); if (count == 0) { return null; } List<MBMessage> list = findByG_C_T_A(groupId, categoryId, threadId, answer, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByG_C_T_A_PrevAndNext(long messageId, long groupId, long categoryId, long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByG_C_T_A_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, answer, orderByComparator, true); array[1] = mbMessage; array[2] = getByG_C_T_A_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, answer, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByG_C_T_A_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, long threadId, boolean answer, OrderByComparator<MBMessage> 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); } query.append(_SQL_SELECT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_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(MBMessageModelImpl.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(categoryId); qPos.add(threadId); qPos.add(answer); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @return the matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer) { return filterFindByG_C_T_A(groupId, categoryId, threadId, answer, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer, int start, int end) { return filterFindByG_C_T_A(groupId, categoryId, threadId, answer, start, end, null); } /** * Returns an ordered range of all the message-boards messages that the user has permissions to view where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * <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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer, int start, int end, OrderByComparator<MBMessage> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_T_A(groupId, categoryId, threadId, answer, 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(threadId); qPos.add(answer); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByG_C_T_A_PrevAndNext(long messageId, long groupId, long categoryId, long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_T_A_PrevAndNext(messageId, groupId, categoryId, threadId, answer, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByG_C_T_A_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, answer, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByG_C_T_A_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, answer, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByG_C_T_A_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, long threadId, boolean answer, OrderByComparator<MBMessage> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(8 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(7); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(threadId); qPos.add(answer); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? and answer = ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer */ @Override public void removeByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer) { for (MBMessage mbMessage : findByG_C_T_A(groupId, categoryId, threadId, answer, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @return the number of matching message-boards messages */ @Override public int countByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T_A; Object[] finderArgs = new Object[] { groupId, categoryId, threadId, answer }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_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(categoryId); qPos.add(threadId); qPos.add(answer); 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 messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ? and answer = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param answer the answer * @return the number of matching message-boards messages that the user has permission to view */ @Override public int filterCountByG_C_T_A(long groupId, long categoryId, long threadId, boolean answer) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C_T_A(groupId, categoryId, threadId, answer); } StringBundler query = new StringBundler(5); query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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(categoryId); qPos.add(threadId); qPos.add(answer); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_C_T_A_GROUPID_2 = "mbMessage.groupId = ? AND "; private static final String _FINDER_COLUMN_G_C_T_A_CATEGORYID_2 = "mbMessage.categoryId = ? AND "; private static final String _FINDER_COLUMN_G_C_T_A_THREADID_2 = "mbMessage.threadId = ? AND "; private static final String _FINDER_COLUMN_G_C_T_A_ANSWER_2 = "mbMessage.answer = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_T_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_WITHOUT_PAGINATION_FIND_BY_G_C_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.GROUPID_COLUMN_BITMASK | MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK | MBMessageModelImpl.THREADID_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByG_C_T_S(long groupId, long categoryId, long threadId, int status) { return findByG_C_T_S(groupId, categoryId, threadId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByG_C_T_S(long groupId, long categoryId, long threadId, int status, int start, int end) { return findByG_C_T_S(groupId, categoryId, threadId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByG_C_T_S(long groupId, long categoryId, long threadId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByG_C_T_S(groupId, categoryId, threadId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByG_C_T_S(long groupId, long categoryId, long threadId, int status, int start, int end, OrderByComparator<MBMessage> 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_C_T_S; finderArgs = new Object[] { groupId, categoryId, threadId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T_S; finderArgs = new Object[] { groupId, categoryId, threadId, status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((groupId != mbMessage.getGroupId()) || (categoryId != mbMessage.getCategoryId()) || (threadId != mbMessage.getThreadId()) || (status != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(categoryId); qPos.add(threadId); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_T_S_First(long groupId, long categoryId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_T_S_First(groupId, categoryId, threadId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(", threadId="); msg.append(threadId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_T_S_First(long groupId, long categoryId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByG_C_T_S(groupId, categoryId, threadId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByG_C_T_S_Last(long groupId, long categoryId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByG_C_T_S_Last(groupId, categoryId, threadId, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", categoryId="); msg.append(categoryId); msg.append(", threadId="); msg.append(threadId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByG_C_T_S_Last(long groupId, long categoryId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByG_C_T_S(groupId, categoryId, threadId, status); if (count == 0) { return null; } List<MBMessage> list = findByG_C_T_S(groupId, categoryId, threadId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByG_C_T_S_PrevAndNext(long messageId, long groupId, long categoryId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByG_C_T_S_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByG_C_T_S_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByG_C_T_S_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, long threadId, int status, OrderByComparator<MBMessage> 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); } query.append(_SQL_SELECT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_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(MBMessageModelImpl.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(categoryId); qPos.add(threadId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status * @return the matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId, long threadId, int status) { return filterFindByG_C_T_S(groupId, categoryId, threadId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId, long threadId, int status, int start, int end) { return filterFindByG_C_T_S(groupId, categoryId, threadId, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages that the user has permissions to view where groupId = ? and categoryId = ? and threadId = ? 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 MBMessageModelImpl}. 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 categoryId the category ID * @param threadId the thread ID * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages that the user has permission to view */ @Override public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId, long threadId, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_T_S(groupId, categoryId, threadId, 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_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(threadId); qPos.add(status); return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set of message-boards messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread 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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] filterFindByG_C_T_S_PrevAndNext(long messageId, long groupId, long categoryId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_T_S_PrevAndNext(messageId, groupId, categoryId, threadId, status, orderByComparator); } MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = filterGetByG_C_T_S_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, status, orderByComparator, true); array[1] = mbMessage; array[2] = filterGetByG_C_T_S_PrevAndNext(session, mbMessage, groupId, categoryId, threadId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage filterGetByG_C_T_S_PrevAndNext(Session session, MBMessage mbMessage, long groupId, long categoryId, long threadId, int status, OrderByComparator<MBMessage> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(8 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(7); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBMESSAGE_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(MBMessageModelImpl.ORDER_BY_JPQL); } else { query.append(MBMessageModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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, MBMessageImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(threadId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where groupId = ? and categoryId = ? and threadId = ? and status = ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status */ @Override public void removeByG_C_T_S(long groupId, long categoryId, long threadId, int status) { for (MBMessage mbMessage : findByG_C_T_S(groupId, categoryId, threadId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status * @return the number of matching message-boards messages */ @Override public int countByG_C_T_S(long groupId, long categoryId, long threadId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T_S; Object[] finderArgs = new Object[] { groupId, categoryId, threadId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_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(categoryId); qPos.add(threadId); 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 messages that the user has permission to view where groupId = ? and categoryId = ? and threadId = ? and status = ?. * * @param groupId the group ID * @param categoryId the category ID * @param threadId the thread ID * @param status the status * @return the number of matching message-boards messages that the user has permission to view */ @Override public int filterCountByG_C_T_S(long groupId, long categoryId, long threadId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C_T_S(groupId, categoryId, threadId, status); } StringBundler query = new StringBundler(5); query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2); query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2); query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBMessage.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(categoryId); qPos.add(threadId); 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_C_T_S_GROUPID_2 = "mbMessage.groupId = ? AND "; private static final String _FINDER_COLUMN_G_C_T_S_CATEGORYID_2 = "mbMessage.categoryId = ? AND "; private static final String _FINDER_COLUMN_G_C_T_S_THREADID_2 = "mbMessage.threadId = ? AND "; private static final String _FINDER_COLUMN_G_C_T_S_STATUS_2 = "mbMessage.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C_C_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_WITHOUT_PAGINATION_FIND_BY_U_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C_C_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBMessageModelImpl.USERID_COLUMN_BITMASK | MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK | MBMessageModelImpl.CLASSPK_COLUMN_BITMASK | MBMessageModelImpl.STATUS_COLUMN_BITMASK | MBMessageModelImpl.CREATEDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_C_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the message-boards messages where userId = ? and classNameId = ? and classPK = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @return the matching message-boards messages */ @Override public List<MBMessage> findByU_C_C_S(long userId, long classNameId, long classPK, int status) { return findByU_C_C_S(userId, classNameId, classPK, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages where userId = ? and classNameId = ? and classPK = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of matching message-boards messages */ @Override public List<MBMessage> findByU_C_C_S(long userId, long classNameId, long classPK, int status, int start, int end) { return findByU_C_C_S(userId, classNameId, classPK, status, start, end, null); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ? and classPK = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message-boards messages */ @Override public List<MBMessage> findByU_C_C_S(long userId, long classNameId, long classPK, int status, int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findByU_C_C_S(userId, classNameId, classPK, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages where userId = ? and classNameId = ? and classPK = ? 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 MBMessageModelImpl}. 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 userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param start the lower bound of the range of message-boards messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findByU_C_C_S(long userId, long classNameId, long classPK, int status, int start, int end, OrderByComparator<MBMessage> 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_U_C_C_S; finderArgs = new Object[] { userId, classNameId, classPK, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C_S; finderArgs = new Object[] { userId, classNameId, classPK, status, start, end, orderByComparator }; } List<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MBMessage mbMessage : list) { if ((userId != mbMessage.getUserId()) || (classNameId != mbMessage.getClassNameId()) || (classPK != mbMessage.getClassPK()) || (status != mbMessage.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_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_C_S_USERID_2); query.append(_FINDER_COLUMN_U_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_U_C_C_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MBMessageModelImpl.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(userId); qPos.add(classNameId); qPos.add(classPK); qPos.add(status); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 message in the ordered set where userId = ? and classNameId = ? and classPK = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByU_C_C_S_First(long userId, long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByU_C_C_S_First(userId, classNameId, classPK, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the first message-boards message in the ordered set where userId = ? and classNameId = ? and classPK = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByU_C_C_S_First(long userId, long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) { List<MBMessage> list = findByU_C_C_S(userId, classNameId, classPK, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last message-boards message in the ordered set where userId = ? and classNameId = ? and classPK = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message * @throws NoSuchMessageException if a matching message-boards message could not be found */ @Override public MBMessage findByU_C_C_S_Last(long userId, long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = fetchByU_C_C_S_Last(userId, classNameId, classPK, status, orderByComparator); if (mbMessage != null) { return mbMessage; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchMessageException(msg.toString()); } /** * Returns the last message-boards message in the ordered set where userId = ? and classNameId = ? and classPK = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message-boards message, or <code>null</code> if a matching message-boards message could not be found */ @Override public MBMessage fetchByU_C_C_S_Last(long userId, long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) { int count = countByU_C_C_S(userId, classNameId, classPK, status); if (count == 0) { return null; } List<MBMessage> list = findByU_C_C_S(userId, classNameId, classPK, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the message-boards messages before and after the current message-boards message in the ordered set where userId = ? and classNameId = ? and classPK = ? and status = ?. * * @param messageId the primary key of the current message-boards message * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @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 message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage[] findByU_C_C_S_PrevAndNext(long messageId, long userId, long classNameId, long classPK, int status, OrderByComparator<MBMessage> orderByComparator) throws NoSuchMessageException { MBMessage mbMessage = findByPrimaryKey(messageId); Session session = null; try { session = openSession(); MBMessage[] array = new MBMessageImpl[3]; array[0] = getByU_C_C_S_PrevAndNext(session, mbMessage, userId, classNameId, classPK, status, orderByComparator, true); array[1] = mbMessage; array[2] = getByU_C_C_S_PrevAndNext(session, mbMessage, userId, classNameId, classPK, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBMessage getByU_C_C_S_PrevAndNext(Session session, MBMessage mbMessage, long userId, long classNameId, long classPK, int status, OrderByComparator<MBMessage> 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); } query.append(_SQL_SELECT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_C_S_USERID_2); query.append(_FINDER_COLUMN_U_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_U_C_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(MBMessageModelImpl.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(userId); qPos.add(classNameId); qPos.add(classPK); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbMessage); for (Object value : values) { qPos.add(value); } } List<MBMessage> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the message-boards messages where userId = ? and classNameId = ? and classPK = ? and status = ? from the database. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status */ @Override public void removeByU_C_C_S(long userId, long classNameId, long classPK, int status) { for (MBMessage mbMessage : findByU_C_C_S(userId, classNameId, classPK, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(mbMessage); } } /** * Returns the number of message-boards messages where userId = ? and classNameId = ? and classPK = ? and status = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param status the status * @return the number of matching message-boards messages */ @Override public int countByU_C_C_S(long userId, long classNameId, long classPK, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U_C_C_S; Object[] finderArgs = new Object[] { userId, classNameId, classPK, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_MBMESSAGE_WHERE); query.append(_FINDER_COLUMN_U_C_C_S_USERID_2); query.append(_FINDER_COLUMN_U_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_U_C_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(userId); qPos.add(classNameId); qPos.add(classPK); 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_U_C_C_S_USERID_2 = "mbMessage.userId = ? AND "; private static final String _FINDER_COLUMN_U_C_C_S_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND "; private static final String _FINDER_COLUMN_U_C_C_S_CLASSPK_2 = "mbMessage.classPK = ? AND "; private static final String _FINDER_COLUMN_U_C_C_S_STATUS_2 = "mbMessage.status = ?"; public MBMessagePersistenceImpl() { setModelClass(MBMessage.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 message in the entity cache if it is enabled. * * @param mbMessage the message-boards message */ @Override public void cacheResult(MBMessage mbMessage) { entityCache.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, mbMessage.getPrimaryKey(), mbMessage); finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, new Object[] { mbMessage.getUuid(), mbMessage.getGroupId() }, mbMessage); mbMessage.resetOriginalValues(); } /** * Caches the message-boards messages in the entity cache if it is enabled. * * @param mbMessages the message-boards messages */ @Override public void cacheResult(List<MBMessage> mbMessages) { for (MBMessage mbMessage : mbMessages) { if (entityCache.getResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, mbMessage.getPrimaryKey()) == null) { cacheResult(mbMessage); } else { mbMessage.resetOriginalValues(); } } } /** * Clears the cache for all message-boards messages. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(MBMessageImpl.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 message. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(MBMessage mbMessage) { entityCache.removeResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, mbMessage.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((MBMessageModelImpl)mbMessage, true); } @Override public void clearCache(List<MBMessage> mbMessages) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (MBMessage mbMessage : mbMessages) { entityCache.removeResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, mbMessage.getPrimaryKey()); clearUniqueFindersCache((MBMessageModelImpl)mbMessage, true); } } protected void cacheUniqueFindersCache( MBMessageModelImpl mbMessageModelImpl) { Object[] args = new Object[] { mbMessageModelImpl.getUuid(), mbMessageModelImpl.getGroupId() }; finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args, mbMessageModelImpl, false); } protected void clearUniqueFindersCache( MBMessageModelImpl mbMessageModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { mbMessageModelImpl.getUuid(), mbMessageModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalUuid(), mbMessageModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); } } /** * Creates a new message-boards message with the primary key. Does not add the message-boards message to the database. * * @param messageId the primary key for the new message-boards message * @return the new message-boards message */ @Override public MBMessage create(long messageId) { MBMessage mbMessage = new MBMessageImpl(); mbMessage.setNew(true); mbMessage.setPrimaryKey(messageId); String uuid = PortalUUIDUtil.generate(); mbMessage.setUuid(uuid); mbMessage.setCompanyId(companyProvider.getCompanyId()); return mbMessage; } /** * Removes the message-boards message with the primary key from the database. Also notifies the appropriate model listeners. * * @param messageId the primary key of the message-boards message * @return the message-boards message that was removed * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage remove(long messageId) throws NoSuchMessageException { return remove((Serializable)messageId); } /** * Removes the message-boards message with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the message-boards message * @return the message-boards message that was removed * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage remove(Serializable primaryKey) throws NoSuchMessageException { Session session = null; try { session = openSession(); MBMessage mbMessage = (MBMessage)session.get(MBMessageImpl.class, primaryKey); if (mbMessage == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchMessageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(mbMessage); } catch (NoSuchMessageException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected MBMessage removeImpl(MBMessage mbMessage) { mbMessage = toUnwrappedModel(mbMessage); Session session = null; try { session = openSession(); if (!session.contains(mbMessage)) { mbMessage = (MBMessage)session.get(MBMessageImpl.class, mbMessage.getPrimaryKeyObj()); } if (mbMessage != null) { session.delete(mbMessage); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (mbMessage != null) { clearCache(mbMessage); } return mbMessage; } @Override public MBMessage updateImpl(MBMessage mbMessage) { mbMessage = toUnwrappedModel(mbMessage); boolean isNew = mbMessage.isNew(); MBMessageModelImpl mbMessageModelImpl = (MBMessageModelImpl)mbMessage; if (Validator.isNull(mbMessage.getUuid())) { String uuid = PortalUUIDUtil.generate(); mbMessage.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (mbMessage.getCreateDate() == null)) { if (serviceContext == null) { mbMessage.setCreateDate(now); } else { mbMessage.setCreateDate(serviceContext.getCreateDate(now)); } } if (!mbMessageModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { mbMessage.setModifiedDate(now); } else { mbMessage.setModifiedDate(serviceContext.getModifiedDate(now)); } } long userId = GetterUtil.getLong(PrincipalThreadLocal.getName()); if (userId > 0) { long companyId = mbMessage.getCompanyId(); long groupId = mbMessage.getGroupId(); long messageId = 0; if (!isNew) { messageId = mbMessage.getPrimaryKey(); } try { mbMessage.setSubject(SanitizerUtil.sanitize(companyId, groupId, userId, MBMessage.class.getName(), messageId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL, mbMessage.getSubject(), null)); } catch (SanitizerException se) { throw new SystemException(se); } } Session session = null; try { session = openSession(); if (mbMessage.isNew()) { session.save(mbMessage); mbMessage.setNew(false); } else { mbMessage = (MBMessage)session.merge(mbMessage); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!MBMessageModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { mbMessageModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { mbMessageModelImpl.getUuid(), mbMessageModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { mbMessageModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { mbMessageModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { mbMessageModelImpl.getUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args); args = new Object[] { mbMessageModelImpl.getThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_THREADID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID, args); args = new Object[] { mbMessageModelImpl.getThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_THREADREPLIES, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); args = new Object[] { mbMessageModelImpl.getCompanyId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S, args); args = new Object[] { mbMessageModelImpl.getUserId(), mbMessageModelImpl.getClassNameId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C, args); args = new Object[] { mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C, args); args = new Object[] { mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getParentMessageId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P, args); args = new Object[] { mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getAnswer() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_A, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A, args); args = new Object[] { mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S, args); args = new Object[] { mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_TR_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getUserId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId(), mbMessageModelImpl.getThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S, args); args = new Object[] { mbMessageModelImpl.getUserId(), mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C, args); args = new Object[] { mbMessageModelImpl.getUserId(), mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S, args); args = new Object[] { mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getClassPK(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId(), mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getAnswer() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T_A, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId(), mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S, args); args = new Object[] { mbMessageModelImpl.getUserId(), mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getClassPK(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S, args); finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL, FINDER_ARGS_EMPTY); } else { if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { mbMessageModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalUuid(), mbMessageModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { mbMessageModelImpl.getUuid(), mbMessageModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { mbMessageModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { mbMessageModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args); args = new Object[] { mbMessageModelImpl.getUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_THREADID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID, args); args = new Object[] { mbMessageModelImpl.getThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_THREADID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_THREADREPLIES, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES, args); args = new Object[] { mbMessageModelImpl.getThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_THREADREPLIES, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId(), mbMessageModelImpl.getOriginalUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId(), mbMessageModelImpl.getOriginalCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalCompanyId(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S, args); args = new Object[] { mbMessageModelImpl.getCompanyId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalUserId(), mbMessageModelImpl.getOriginalClassNameId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C, args); args = new Object[] { mbMessageModelImpl.getUserId(), mbMessageModelImpl.getClassNameId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalClassNameId(), mbMessageModelImpl.getOriginalClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C, args); args = new Object[] { mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalThreadId(), mbMessageModelImpl.getOriginalParentMessageId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P, args); args = new Object[] { mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getParentMessageId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalThreadId(), mbMessageModelImpl.getOriginalAnswer() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_A, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A, args); args = new Object[] { mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getAnswer() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_A, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalThreadId(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S, args); args = new Object[] { mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_T_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalThreadId(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_TR_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S, args); args = new Object[] { mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_TR_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId(), mbMessageModelImpl.getOriginalUserId(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getUserId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId(), mbMessageModelImpl.getOriginalCategoryId(), mbMessageModelImpl.getOriginalThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId(), mbMessageModelImpl.getThreadId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId(), mbMessageModelImpl.getOriginalCategoryId(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalUserId(), mbMessageModelImpl.getOriginalClassNameId(), mbMessageModelImpl.getOriginalClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C, args); args = new Object[] { mbMessageModelImpl.getUserId(), mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalUserId(), mbMessageModelImpl.getOriginalClassNameId(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S, args); args = new Object[] { mbMessageModelImpl.getUserId(), mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalClassNameId(), mbMessageModelImpl.getOriginalClassPK(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S, args); args = new Object[] { mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getClassPK(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId(), mbMessageModelImpl.getOriginalCategoryId(), mbMessageModelImpl.getOriginalThreadId(), mbMessageModelImpl.getOriginalAnswer() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T_A, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId(), mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getAnswer() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T_A, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalGroupId(), mbMessageModelImpl.getOriginalCategoryId(), mbMessageModelImpl.getOriginalThreadId(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S, args); args = new Object[] { mbMessageModelImpl.getGroupId(), mbMessageModelImpl.getCategoryId(), mbMessageModelImpl.getThreadId(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_C_T_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S, args); } if ((mbMessageModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbMessageModelImpl.getOriginalUserId(), mbMessageModelImpl.getOriginalClassNameId(), mbMessageModelImpl.getOriginalClassPK(), mbMessageModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S, args); args = new Object[] { mbMessageModelImpl.getUserId(), mbMessageModelImpl.getClassNameId(), mbMessageModelImpl.getClassPK(), mbMessageModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S, args); } } entityCache.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, mbMessage.getPrimaryKey(), mbMessage, false); clearUniqueFindersCache(mbMessageModelImpl, false); cacheUniqueFindersCache(mbMessageModelImpl); mbMessage.resetOriginalValues(); return mbMessage; } protected MBMessage toUnwrappedModel(MBMessage mbMessage) { if (mbMessage instanceof MBMessageImpl) { return mbMessage; } MBMessageImpl mbMessageImpl = new MBMessageImpl(); mbMessageImpl.setNew(mbMessage.isNew()); mbMessageImpl.setPrimaryKey(mbMessage.getPrimaryKey()); mbMessageImpl.setUuid(mbMessage.getUuid()); mbMessageImpl.setMessageId(mbMessage.getMessageId()); mbMessageImpl.setGroupId(mbMessage.getGroupId()); mbMessageImpl.setCompanyId(mbMessage.getCompanyId()); mbMessageImpl.setUserId(mbMessage.getUserId()); mbMessageImpl.setUserName(mbMessage.getUserName()); mbMessageImpl.setCreateDate(mbMessage.getCreateDate()); mbMessageImpl.setModifiedDate(mbMessage.getModifiedDate()); mbMessageImpl.setClassNameId(mbMessage.getClassNameId()); mbMessageImpl.setClassPK(mbMessage.getClassPK()); mbMessageImpl.setCategoryId(mbMessage.getCategoryId()); mbMessageImpl.setThreadId(mbMessage.getThreadId()); mbMessageImpl.setRootMessageId(mbMessage.getRootMessageId()); mbMessageImpl.setParentMessageId(mbMessage.getParentMessageId()); mbMessageImpl.setSubject(mbMessage.getSubject()); mbMessageImpl.setBody(mbMessage.getBody()); mbMessageImpl.setFormat(mbMessage.getFormat()); mbMessageImpl.setAnonymous(mbMessage.isAnonymous()); mbMessageImpl.setPriority(mbMessage.getPriority()); mbMessageImpl.setAllowPingbacks(mbMessage.isAllowPingbacks()); mbMessageImpl.setAnswer(mbMessage.isAnswer()); mbMessageImpl.setLastPublishDate(mbMessage.getLastPublishDate()); mbMessageImpl.setStatus(mbMessage.getStatus()); mbMessageImpl.setStatusByUserId(mbMessage.getStatusByUserId()); mbMessageImpl.setStatusByUserName(mbMessage.getStatusByUserName()); mbMessageImpl.setStatusDate(mbMessage.getStatusDate()); return mbMessageImpl; } /** * Returns the message-boards message 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 message * @return the message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage findByPrimaryKey(Serializable primaryKey) throws NoSuchMessageException { MBMessage mbMessage = fetchByPrimaryKey(primaryKey); if (mbMessage == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchMessageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return mbMessage; } /** * Returns the message-boards message with the primary key or throws a {@link NoSuchMessageException} if it could not be found. * * @param messageId the primary key of the message-boards message * @return the message-boards message * @throws NoSuchMessageException if a message-boards message with the primary key could not be found */ @Override public MBMessage findByPrimaryKey(long messageId) throws NoSuchMessageException { return findByPrimaryKey((Serializable)messageId); } /** * Returns the message-boards message with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the message-boards message * @return the message-boards message, or <code>null</code> if a message-boards message with the primary key could not be found */ @Override public MBMessage fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, primaryKey); if (serializable == nullModel) { return null; } MBMessage mbMessage = (MBMessage)serializable; if (mbMessage == null) { Session session = null; try { session = openSession(); mbMessage = (MBMessage)session.get(MBMessageImpl.class, primaryKey); if (mbMessage != null) { cacheResult(mbMessage); } else { entityCache.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return mbMessage; } /** * Returns the message-boards message with the primary key or returns <code>null</code> if it could not be found. * * @param messageId the primary key of the message-boards message * @return the message-boards message, or <code>null</code> if a message-boards message with the primary key could not be found */ @Override public MBMessage fetchByPrimaryKey(long messageId) { return fetchByPrimaryKey((Serializable)messageId); } @Override public Map<Serializable, MBMessage> fetchByPrimaryKeys( Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, MBMessage> map = new HashMap<Serializable, MBMessage>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); MBMessage mbMessage = fetchByPrimaryKey(primaryKey); if (mbMessage != null) { map.put(primaryKey, mbMessage); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (MBMessage)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_MBMESSAGE_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 (MBMessage mbMessage : (List<MBMessage>)q.list()) { map.put(mbMessage.getPrimaryKeyObj(), mbMessage); cacheResult(mbMessage); uncachedPrimaryKeys.remove(mbMessage.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED, MBMessageImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the message-boards messages. * * @return the message-boards messages */ @Override public List<MBMessage> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message-boards messages. * * <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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @return the range of message-boards messages */ @Override public List<MBMessage> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the message-boards messages. * * <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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of message-boards messages */ @Override public List<MBMessage> findAll(int start, int end, OrderByComparator<MBMessage> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the message-boards messages. * * <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 MBMessageModelImpl}. 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 messages * @param end the upper bound of the range of message-boards messages (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 messages */ @Override public List<MBMessage> findAll(int start, int end, OrderByComparator<MBMessage> 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<MBMessage> list = null; if (retrieveFromCache) { list = (List<MBMessage>)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_MBMESSAGE); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_MBMESSAGE; if (pagination) { sql = sql.concat(MBMessageModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MBMessage>)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 messages from the database. * */ @Override public void removeAll() { for (MBMessage mbMessage : findAll()) { remove(mbMessage); } } /** * Returns the number of message-boards messages. * * @return the number of message-boards messages */ @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_MBMESSAGE); 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 MBMessageModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the message-boards message persistence. */ public void afterPropertiesSet() { } public void destroy() { entityCache.removeCache(MBMessageImpl.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_MBMESSAGE = "SELECT mbMessage FROM MBMessage mbMessage"; private static final String _SQL_SELECT_MBMESSAGE_WHERE_PKS_IN = "SELECT mbMessage FROM MBMessage mbMessage WHERE messageId IN ("; private static final String _SQL_SELECT_MBMESSAGE_WHERE = "SELECT mbMessage FROM MBMessage mbMessage WHERE "; private static final String _SQL_COUNT_MBMESSAGE = "SELECT COUNT(mbMessage) FROM MBMessage mbMessage"; private static final String _SQL_COUNT_MBMESSAGE_WHERE = "SELECT COUNT(mbMessage) FROM MBMessage mbMessage WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbMessage.rootMessageId"; private static final String _FILTER_SQL_SELECT_MBMESSAGE_WHERE = "SELECT DISTINCT {mbMessage.*} FROM MBMessage mbMessage WHERE "; private static final String _FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {MBMessage.*} FROM (SELECT DISTINCT mbMessage.messageId FROM MBMessage mbMessage WHERE "; private static final String _FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN MBMessage ON TEMP_TABLE.messageId = MBMessage.messageId"; private static final String _FILTER_SQL_COUNT_MBMESSAGE_WHERE = "SELECT COUNT(DISTINCT mbMessage.messageId) AS COUNT_VALUE FROM MBMessage mbMessage WHERE "; private static final String _FILTER_ENTITY_ALIAS = "mbMessage"; private static final String _FILTER_ENTITY_TABLE = "MBMessage"; private static final String _ORDER_BY_ENTITY_ALIAS = "mbMessage."; private static final String _ORDER_BY_ENTITY_TABLE = "MBMessage."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMessage exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMessage exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(MBMessagePersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] { "uuid" }); }