Java tutorial
/** * Copyright (c) 2000-2012 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; import com.liferay.portal.NoSuchModelException; import com.liferay.portal.kernel.bean.BeanReference; import com.liferay.portal.kernel.cache.CacheRegistryUtil; import com.liferay.portal.kernel.dao.orm.EntityCacheUtil; 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.util.CalendarUtil; import com.liferay.portal.kernel.util.GetterUtil; import com.liferay.portal.kernel.util.InstanceFactory; import com.liferay.portal.kernel.util.OrderByComparator; 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.model.CacheModel; import com.liferay.portal.model.ModelListener; import com.liferay.portal.security.permission.InlineSQLHelperUtil; import com.liferay.portal.service.persistence.BatchSessionUtil; import com.liferay.portal.service.persistence.LockPersistence; import com.liferay.portal.service.persistence.ResourcePersistence; import com.liferay.portal.service.persistence.UserPersistence; import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence; import com.liferay.portal.service.persistence.impl.BasePersistenceImpl; import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence; import com.liferay.portlet.messageboards.NoSuchThreadException; import com.liferay.portlet.messageboards.model.MBThread; import com.liferay.portlet.messageboards.model.impl.MBThreadImpl; import com.liferay.portlet.messageboards.model.impl.MBThreadModelImpl; import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence; import com.liferay.portlet.social.service.persistence.SocialActivityPersistence; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; /** * The persistence implementation for the message boards thread service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see MBThreadPersistence * @see MBThreadUtil * @generated */ public class MBThreadPersistenceImpl extends BasePersistenceImpl<MBThread> implements MBThreadPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link MBThreadUtil} to access the message boards thread persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = MBThreadImpl.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_BY_GROUPID = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId", new String[] { Long.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId", new String[] { Long.class.getName() }, MBThreadModelImpl.GROUPID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId", new String[] { Long.class.getName() }); public static final FinderPath FINDER_PATH_FETCH_BY_ROOTMESSAGEID = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByRootMessageId", new String[] { Long.class.getName() }, MBThreadModelImpl.ROOTMESSAGEID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_ROOTMESSAGEID = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRootMessageId", new String[] { Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C", new String[] { Long.class.getName(), Long.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C", new String[] { Long.class.getName(), Long.class.getName() }, MBThreadModelImpl.GROUPID_COLUMN_BITMASK | MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C", new String[] { Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC", new String[] { Long.class.getName(), Long.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_NotC", new String[] { Long.class.getName(), Long.class.getName() }, MBThreadModelImpl.GROUPID_COLUMN_BITMASK | MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_NOTC = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_NotC", new String[] { Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName() }, MBThreadModelImpl.GROUPID_COLUMN_BITMASK | MBThreadModelImpl.STATUS_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S", new String[] { Long.class.getName(), Integer.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P", new String[] { Long.class.getName(), Double.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P", new String[] { Long.class.getName(), Double.class.getName() }, MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK | MBThreadModelImpl.PRIORITY_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P", new String[] { Long.class.getName(), Double.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByL_P", new String[] { Date.class.getName(), Double.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P", new String[] { Date.class.getName(), Double.class.getName() }, MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK | MBThreadModelImpl.PRIORITY_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P", new String[] { Date.class.getName(), Double.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_L", new String[] { Long.class.getName(), Long.class.getName(), Date.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L", new String[] { Long.class.getName(), Long.class.getName(), Date.class.getName() }, MBThreadModelImpl.GROUPID_COLUMN_BITMASK | MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK | MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L", new String[] { Long.class.getName(), Long.class.getName(), Date.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBThreadModelImpl.GROUPID_COLUMN_BITMASK | MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK | MBThreadModelImpl.STATUS_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.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() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC_S = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_NotC_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MBThreadModelImpl.GROUPID_COLUMN_BITMASK | MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK | MBThreadModelImpl.STATUS_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_NOTC_S = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_NotC_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath( MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); /** * Caches the message boards thread in the entity cache if it is enabled. * * @param mbThread the message boards thread */ public void cacheResult(MBThread mbThread) { EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread); FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, new Object[] { Long.valueOf(mbThread.getRootMessageId()) }, mbThread); mbThread.resetOriginalValues(); } /** * Caches the message boards threads in the entity cache if it is enabled. * * @param mbThreads the message boards threads */ public void cacheResult(List<MBThread> mbThreads) { for (MBThread mbThread : mbThreads) { if (EntityCacheUtil.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadImpl.class, mbThread.getPrimaryKey()) == null) { cacheResult(mbThread); } else { mbThread.resetOriginalValues(); } } } /** * Clears the cache for all message boards threads. * * <p> * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) { CacheRegistryUtil.clear(MBThreadImpl.class.getName()); } EntityCacheUtil.clearCache(MBThreadImpl.class.getName()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the message boards thread. * * <p> * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(MBThread mbThread) { EntityCacheUtil.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadImpl.class, mbThread.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache(mbThread); } @Override public void clearCache(List<MBThread> mbThreads) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (MBThread mbThread : mbThreads) { EntityCacheUtil.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadImpl.class, mbThread.getPrimaryKey()); clearUniqueFindersCache(mbThread); } } protected void clearUniqueFindersCache(MBThread mbThread) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, new Object[] { Long.valueOf(mbThread.getRootMessageId()) }); } /** * Creates a new message boards thread with the primary key. Does not add the message boards thread to the database. * * @param threadId the primary key for the new message boards thread * @return the new message boards thread */ public MBThread create(long threadId) { MBThread mbThread = new MBThreadImpl(); mbThread.setNew(true); mbThread.setPrimaryKey(threadId); return mbThread; } /** * Removes the message boards thread with the primary key from the database. Also notifies the appropriate model listeners. * * @param threadId the primary key of the message boards thread * @return the message boards thread that was removed * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread remove(long threadId) throws NoSuchThreadException, SystemException { return remove(Long.valueOf(threadId)); } /** * Removes the message boards thread with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the message boards thread * @return the message boards thread that was removed * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ @Override public MBThread remove(Serializable primaryKey) throws NoSuchThreadException, SystemException { Session session = null; try { session = openSession(); MBThread mbThread = (MBThread) session.get(MBThreadImpl.class, primaryKey); if (mbThread == null) { if (_log.isWarnEnabled()) { _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(mbThread); } catch (NoSuchThreadException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected MBThread removeImpl(MBThread mbThread) throws SystemException { mbThread = toUnwrappedModel(mbThread); Session session = null; try { session = openSession(); BatchSessionUtil.delete(session, mbThread); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } clearCache(mbThread); return mbThread; } @Override public MBThread updateImpl(com.liferay.portlet.messageboards.model.MBThread mbThread, boolean merge) throws SystemException { mbThread = toUnwrappedModel(mbThread); boolean isNew = mbThread.isNew(); MBThreadModelImpl mbThreadModelImpl = (MBThreadModelImpl) mbThread; Session session = null; try { session = openSession(); BatchSessionUtil.update(session, mbThread, merge); mbThread.setNew(false); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !MBThreadModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalGroupId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); } if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalGroupId()), Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C, args); args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()), Long.valueOf(mbThreadModelImpl.getCategoryId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C, args); } if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalGroupId()), Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_NOTC, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC, args); args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()), Long.valueOf(mbThreadModelImpl.getCategoryId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_NOTC, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC, args); } if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalGroupId()), Integer.valueOf(mbThreadModelImpl.getOriginalStatus()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()), Integer.valueOf(mbThreadModelImpl.getStatus()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); } if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()), Double.valueOf(mbThreadModelImpl.getOriginalPriority()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P, args); args = new Object[] { Long.valueOf(mbThreadModelImpl.getCategoryId()), Double.valueOf(mbThreadModelImpl.getPriority()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P, args); } if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) { Object[] args = new Object[] { mbThreadModelImpl.getOriginalLastPostDate(), Double.valueOf(mbThreadModelImpl.getOriginalPriority()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P, args); args = new Object[] { mbThreadModelImpl.getLastPostDate(), Double.valueOf(mbThreadModelImpl.getPriority()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P, args); } if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalGroupId()), Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()), mbThreadModelImpl.getOriginalLastPostDate() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L, args); args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()), Long.valueOf(mbThreadModelImpl.getCategoryId()), mbThreadModelImpl.getLastPostDate() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L, args); } if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalGroupId()), Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()), Integer.valueOf(mbThreadModelImpl.getOriginalStatus()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S, args); args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()), Long.valueOf(mbThreadModelImpl.getCategoryId()), Integer.valueOf(mbThreadModelImpl.getStatus()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S, args); } if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalGroupId()), Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()), Integer.valueOf(mbThreadModelImpl.getOriginalStatus()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_NOTC_S, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC_S, args); args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()), Long.valueOf(mbThreadModelImpl.getCategoryId()), Integer.valueOf(mbThreadModelImpl.getStatus()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_NOTC_S, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC_S, args); } } EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread); if (isNew) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, new Object[] { Long.valueOf(mbThread.getRootMessageId()) }, mbThread); } else { if ((mbThreadModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_ROOTMESSAGEID.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(mbThreadModelImpl.getOriginalRootMessageId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args); FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args); FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, new Object[] { Long.valueOf(mbThread.getRootMessageId()) }, mbThread); } } return mbThread; } protected MBThread toUnwrappedModel(MBThread mbThread) { if (mbThread instanceof MBThreadImpl) { return mbThread; } MBThreadImpl mbThreadImpl = new MBThreadImpl(); mbThreadImpl.setNew(mbThread.isNew()); mbThreadImpl.setPrimaryKey(mbThread.getPrimaryKey()); mbThreadImpl.setThreadId(mbThread.getThreadId()); mbThreadImpl.setGroupId(mbThread.getGroupId()); mbThreadImpl.setCompanyId(mbThread.getCompanyId()); mbThreadImpl.setCategoryId(mbThread.getCategoryId()); mbThreadImpl.setRootMessageId(mbThread.getRootMessageId()); mbThreadImpl.setRootMessageUserId(mbThread.getRootMessageUserId()); mbThreadImpl.setMessageCount(mbThread.getMessageCount()); mbThreadImpl.setViewCount(mbThread.getViewCount()); mbThreadImpl.setLastPostByUserId(mbThread.getLastPostByUserId()); mbThreadImpl.setLastPostDate(mbThread.getLastPostDate()); mbThreadImpl.setPriority(mbThread.getPriority()); mbThreadImpl.setQuestion(mbThread.isQuestion()); mbThreadImpl.setStatus(mbThread.getStatus()); mbThreadImpl.setStatusByUserId(mbThread.getStatusByUserId()); mbThreadImpl.setStatusByUserName(mbThread.getStatusByUserName()); mbThreadImpl.setStatusDate(mbThread.getStatusDate()); return mbThreadImpl; } /** * Returns the message boards thread with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found. * * @param primaryKey the primary key of the message boards thread * @return the message boards thread * @throws com.liferay.portal.NoSuchModelException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ @Override public MBThread findByPrimaryKey(Serializable primaryKey) throws NoSuchModelException, SystemException { return findByPrimaryKey(((Long) primaryKey).longValue()); } /** * Returns the message boards thread with the primary key or throws a {@link com.liferay.portlet.messageboards.NoSuchThreadException} if it could not be found. * * @param threadId the primary key of the message boards thread * @return the message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread findByPrimaryKey(long threadId) throws NoSuchThreadException, SystemException { MBThread mbThread = fetchByPrimaryKey(threadId); if (mbThread == null) { if (_log.isWarnEnabled()) { _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + threadId); } throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + threadId); } return mbThread; } /** * Returns the message boards thread with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the message boards thread * @return the message boards thread, or <code>null</code> if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ @Override public MBThread fetchByPrimaryKey(Serializable primaryKey) throws SystemException { return fetchByPrimaryKey(((Long) primaryKey).longValue()); } /** * Returns the message boards thread with the primary key or returns <code>null</code> if it could not be found. * * @param threadId the primary key of the message boards thread * @return the message boards thread, or <code>null</code> if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread fetchByPrimaryKey(long threadId) throws SystemException { MBThread mbThread = (MBThread) EntityCacheUtil.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadImpl.class, threadId); if (mbThread == _nullMBThread) { return null; } if (mbThread == null) { Session session = null; boolean hasException = false; try { session = openSession(); mbThread = (MBThread) session.get(MBThreadImpl.class, Long.valueOf(threadId)); } catch (Exception e) { hasException = true; throw processException(e); } finally { if (mbThread != null) { cacheResult(mbThread); } else if (!hasException) { EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED, MBThreadImpl.class, threadId, _nullMBThread); } closeSession(session); } } return mbThread; } /** * Returns all the message boards threads where groupId = ?. * * @param groupId the group ID * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByGroupId(long groupId) throws SystemException { return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByGroupId(long groupId, int start, int end) throws SystemException { return findByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByGroupId(long groupId, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { 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<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.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); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByGroupId_First(long groupId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByGroupId(groupId, 0, 1, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByGroupId_Last(long groupId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByGroupId(groupId); List<MBThread> list = findByGroupId(groupId, count - 1, count, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByGroupId_PrevAndNext(long threadId, long groupId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByGroupId_PrevAndNext(session, mbThread, groupId, orderByComparator, true); array[1] = mbThread; array[2] = getByGroupId_PrevAndNext(session, mbThread, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByGroupId_PrevAndNext(Session session, MBThread mbThread, long groupId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_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(MBThreadModelImpl.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(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByGroupId(long groupId) throws SystemException { return filterFindByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByGroupId(long groupId, int start, int end) throws SystemException { return filterFindByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByGroupId(long groupId, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId(groupId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set of message boards threads that the user has permission to view where groupId = ?. * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] filterFindByGroupId_PrevAndNext(long threadId, long groupId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId_PrevAndNext(threadId, groupId, orderByComparator); } MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = filterGetByGroupId_PrevAndNext(session, mbThread, groupId, orderByComparator, true); array[1] = mbThread; array[2] = filterGetByGroupId_PrevAndNext(session, mbThread, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread filterGetByGroupId_PrevAndNext(Session session, MBThread mbThread, long groupId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_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(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns the message boards thread where rootMessageId = ? or throws a {@link com.liferay.portlet.messageboards.NoSuchThreadException} if it could not be found. * * @param rootMessageId the root message ID * @return the matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByRootMessageId(long rootMessageId) throws NoSuchThreadException, SystemException { MBThread mbThread = fetchByRootMessageId(rootMessageId); if (mbThread == null) { StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("rootMessageId="); msg.append(rootMessageId); msg.append(StringPool.CLOSE_CURLY_BRACE); if (_log.isWarnEnabled()) { _log.warn(msg.toString()); } throw new NoSuchThreadException(msg.toString()); } return mbThread; } /** * Returns the message boards thread where rootMessageId = ? or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param rootMessageId the root message ID * @return the matching message boards thread, or <code>null</code> if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread fetchByRootMessageId(long rootMessageId) throws SystemException { return fetchByRootMessageId(rootMessageId, true); } /** * Returns the message boards thread where rootMessageId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param rootMessageId the root message ID * @param retrieveFromCache whether to use the finder cache * @return the matching message boards thread, or <code>null</code> if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread fetchByRootMessageId(long rootMessageId, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { rootMessageId }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, finderArgs, this); } if (result == null) { StringBundler query = new StringBundler(3); query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2); query.append(MBThreadModelImpl.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(rootMessageId); List<MBThread> list = q.list(); result = list; MBThread mbThread = null; if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, finderArgs, list); } else { mbThread = list.get(0); cacheResult(mbThread); if ((mbThread.getRootMessageId() != rootMessageId)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, finderArgs, mbThread); } } return mbThread; } catch (Exception e) { throw processException(e); } finally { if (result == null) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, finderArgs); } closeSession(session); } } else { if (result instanceof List<?>) { return null; } else { return (MBThread) result; } } } /** * Returns all the message boards threads where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C(long groupId, long categoryId) throws SystemException { return findByG_C(groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C(long groupId, long categoryId, int start, int end) throws SystemException { return findByG_C(groupId, categoryId, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C(long groupId, long categoryId, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { 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<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBTHREAD_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 { query.append(MBThreadModelImpl.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); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_C_First(long groupId, long categoryId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByG_C(groupId, categoryId, 0, 1, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_C_Last(long groupId, long categoryId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByG_C(groupId, categoryId); List<MBThread> list = findByG_C(groupId, categoryId, count - 1, count, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByG_C_PrevAndNext(long threadId, long groupId, long categoryId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByG_C_PrevAndNext(session, mbThread, groupId, categoryId, orderByComparator, true); array[1] = mbThread; array[2] = getByG_C_PrevAndNext(session, mbThread, groupId, categoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByG_C_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_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(MBThreadModelImpl.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(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C(long groupId, long[] categoryIds) throws SystemException { return findByG_C(groupId, categoryIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C(long groupId, long[] categoryIds, int start, int end) throws SystemException { return findByG_C(groupId, categoryIds, start, end, null); } /** * Returns an ordered range of all the message boards threads where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C(long groupId, long[] categoryIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C; finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds) }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C; finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds), start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.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 (categoryIds != null) { qPos.add(categoryIds); } list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns all the message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C(long groupId, long categoryId) throws SystemException { return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C(long groupId, long categoryId, int start, int end) throws SystemException { return filterFindByG_C(groupId, categoryId, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C(long groupId, long categoryId, int start, int end, OrderByComparator orderByComparator) throws SystemException { 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 * 3)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_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_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set of message boards threads that the user has permission to view where groupId = ? and categoryId = ?. * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] filterFindByG_C_PrevAndNext(long threadId, long groupId, long categoryId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_PrevAndNext(threadId, groupId, categoryId, orderByComparator); } MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = filterGetByG_C_PrevAndNext(session, mbThread, groupId, categoryId, orderByComparator, true); array[1] = mbThread; array[2] = filterGetByG_C_PrevAndNext(session, mbThread, groupId, categoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread filterGetByG_C_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_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_MBTHREAD_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(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads that the user has permission to view where groupId = ? and categoryId = any ?. * * @param groupId the group ID * @param categoryIds the category IDs * @return the matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds) throws SystemException { return filterFindByG_C(groupId, categoryIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds, int start, int end) throws SystemException { return filterFindByG_C(groupId, categoryIds, start, end, null); } /** * Returns an ordered range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C(groupId, categoryIds, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the message boards threads where groupId = ? and categoryId ≠ ?. * * @param groupId the group ID * @param categoryId the category ID * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_NotC(long groupId, long categoryId) throws SystemException { return findByG_NotC(groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_NotC(long groupId, long categoryId, int start, int end) throws SystemException { return findByG_NotC(groupId, categoryId, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_NotC(long groupId, long categoryId, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC; finderArgs = new Object[] { groupId, categoryId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC; finderArgs = new Object[] { groupId, categoryId, start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.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); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_NotC_First(long groupId, long categoryId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByG_NotC(groupId, categoryId, 0, 1, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_NotC_Last(long groupId, long categoryId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByG_NotC(groupId, categoryId); List<MBThread> list = findByG_NotC(groupId, categoryId, count - 1, count, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByG_NotC_PrevAndNext(long threadId, long groupId, long categoryId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByG_NotC_PrevAndNext(session, mbThread, groupId, categoryId, orderByComparator, true); array[1] = mbThread; array[2] = getByG_NotC_PrevAndNext(session, mbThread, groupId, categoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByG_NotC_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_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(MBThreadModelImpl.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(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_NotC(long groupId, long categoryId) throws SystemException { return filterFindByG_NotC(groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_NotC(long groupId, long categoryId, int start, int end) throws SystemException { return filterFindByG_NotC(groupId, categoryId, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_NotC(long groupId, long categoryId, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_NotC(groupId, categoryId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set of message boards threads that the user has permission to view where groupId = ? and categoryId ≠ ?. * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] filterFindByG_NotC_PrevAndNext(long threadId, long groupId, long categoryId, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_NotC_PrevAndNext(threadId, groupId, categoryId, orderByComparator); } MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = filterGetByG_NotC_PrevAndNext(session, mbThread, groupId, categoryId, orderByComparator, true); array[1] = mbThread; array[2] = filterGetByG_NotC_PrevAndNext(session, mbThread, groupId, categoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread filterGetByG_NotC_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_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(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_S(long groupId, int status) throws SystemException { return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_S(long groupId, int status, int start, int end) throws SystemException { return findByG_S(groupId, status, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_S(long groupId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { 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<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBTHREAD_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 { query.append(MBThreadModelImpl.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); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_S_First(long groupId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByG_S(groupId, status, 0, 1, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_S_Last(long groupId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByG_S(groupId, status); List<MBThread> list = findByG_S(groupId, status, count - 1, count, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByG_S_PrevAndNext(long threadId, long groupId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByG_S_PrevAndNext(session, mbThread, groupId, status, orderByComparator, true); array[1] = mbThread; array[2] = getByG_S_PrevAndNext(session, mbThread, groupId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByG_S_PrevAndNext(Session session, MBThread mbThread, long groupId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_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(MBThreadModelImpl.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(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_S(long groupId, int status) throws SystemException { return filterFindByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_S(long groupId, int status, int start, int end) throws SystemException { return filterFindByG_S(groupId, status, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_S(long groupId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { 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 * 3)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_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_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set of message boards threads that the user has permission to view where groupId = ? and status = ?. * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] filterFindByG_S_PrevAndNext(long threadId, long groupId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S_PrevAndNext(threadId, groupId, status, orderByComparator); } MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = filterGetByG_S_PrevAndNext(session, mbThread, groupId, status, orderByComparator, true); array[1] = mbThread; array[2] = filterGetByG_S_PrevAndNext(session, mbThread, groupId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread filterGetByG_S_PrevAndNext(Session session, MBThread mbThread, long groupId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_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_MBTHREAD_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(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads where categoryId = ? and priority = ?. * * @param categoryId the category ID * @param priority the priority * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByC_P(long categoryId, double priority) throws SystemException { return findByC_P(categoryId, priority, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads where categoryId = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param categoryId the category ID * @param priority the priority * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByC_P(long categoryId, double priority, int start, int end) throws SystemException { return findByC_P(categoryId, priority, start, end, null); } /** * Returns an ordered range of all the message boards threads where categoryId = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param categoryId the category ID * @param priority the priority * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByC_P(long categoryId, double priority, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P; finderArgs = new Object[] { categoryId, priority }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P; finderArgs = new Object[] { categoryId, priority, start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_C_P_CATEGORYID_2); query.append(_FINDER_COLUMN_C_P_PRIORITY_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(priority); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set where categoryId = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param categoryId the category ID * @param priority the priority * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByC_P_First(long categoryId, double priority, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByC_P(categoryId, priority, 0, 1, orderByComparator); if (list.isEmpty()) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(", priority="); msg.append(priority); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set where categoryId = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param categoryId the category ID * @param priority the priority * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByC_P_Last(long categoryId, double priority, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByC_P(categoryId, priority); List<MBThread> list = findByC_P(categoryId, priority, count - 1, count, orderByComparator); if (list.isEmpty()) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(", priority="); msg.append(priority); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set where categoryId = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @param categoryId the category ID * @param priority the priority * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByC_P_PrevAndNext(long threadId, long categoryId, double priority, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByC_P_PrevAndNext(session, mbThread, categoryId, priority, orderByComparator, true); array[1] = mbThread; array[2] = getByC_P_PrevAndNext(session, mbThread, categoryId, priority, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByC_P_PrevAndNext(Session session, MBThread mbThread, long categoryId, double priority, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_C_P_CATEGORYID_2); query.append(_FINDER_COLUMN_C_P_PRIORITY_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(MBThreadModelImpl.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(categoryId); qPos.add(priority); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads where lastPostDate = ? and priority = ?. * * @param lastPostDate the last post date * @param priority the priority * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByL_P(Date lastPostDate, double priority) throws SystemException { return findByL_P(lastPostDate, priority, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads where lastPostDate = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param lastPostDate the last post date * @param priority the priority * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByL_P(Date lastPostDate, double priority, int start, int end) throws SystemException { return findByL_P(lastPostDate, priority, start, end, null); } /** * Returns an ordered range of all the message boards threads where lastPostDate = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param lastPostDate the last post date * @param priority the priority * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByL_P(Date lastPostDate, double priority, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P; finderArgs = new Object[] { lastPostDate, priority }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P; finderArgs = new Object[] { lastPostDate, priority, start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MBTHREAD_WHERE); if (lastPostDate == null) { query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2); } query.append(_FINDER_COLUMN_L_P_PRIORITY_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } qPos.add(priority); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set where lastPostDate = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param lastPostDate the last post date * @param priority the priority * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByL_P_First(Date lastPostDate, double priority, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByL_P(lastPostDate, priority, 0, 1, orderByComparator); if (list.isEmpty()) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("lastPostDate="); msg.append(lastPostDate); msg.append(", priority="); msg.append(priority); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set where lastPostDate = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param lastPostDate the last post date * @param priority the priority * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByL_P_Last(Date lastPostDate, double priority, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByL_P(lastPostDate, priority); List<MBThread> list = findByL_P(lastPostDate, priority, count - 1, count, orderByComparator); if (list.isEmpty()) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("lastPostDate="); msg.append(lastPostDate); msg.append(", priority="); msg.append(priority); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set where lastPostDate = ? and priority = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @param lastPostDate the last post date * @param priority the priority * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByL_P_PrevAndNext(long threadId, Date lastPostDate, double priority, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByL_P_PrevAndNext(session, mbThread, lastPostDate, priority, orderByComparator, true); array[1] = mbThread; array[2] = getByL_P_PrevAndNext(session, mbThread, lastPostDate, priority, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByL_P_PrevAndNext(Session session, MBThread mbThread, Date lastPostDate, double priority, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_WHERE); if (lastPostDate == null) { query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2); } query.append(_FINDER_COLUMN_L_P_PRIORITY_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(MBThreadModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } qPos.add(priority); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads where groupId = ? and categoryId = ? and lastPostDate = ?. * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_L(long groupId, long categoryId, Date lastPostDate) throws SystemException { return findByG_C_L(groupId, categoryId, lastPostDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads where groupId = ? and categoryId = ? and lastPostDate = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_L(long groupId, long categoryId, Date lastPostDate, int start, int end) throws SystemException { return findByG_C_L(groupId, categoryId, lastPostDate, start, end, null); } /** * Returns an ordered range of all the message boards threads where groupId = ? and categoryId = ? and lastPostDate = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_L(long groupId, long categoryId, Date lastPostDate, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L; finderArgs = new Object[] { groupId, categoryId, lastPostDate }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L; finderArgs = new Object[] { groupId, categoryId, lastPostDate, start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_C_L_GROUPID_2); query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2); if (lastPostDate == null) { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.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 (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set where groupId = ? and categoryId = ? and lastPostDate = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_C_L_First(long groupId, long categoryId, Date lastPostDate, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate, 0, 1, orderByComparator); if (list.isEmpty()) { 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(", lastPostDate="); msg.append(lastPostDate); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set where groupId = ? and categoryId = ? and lastPostDate = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_C_L_Last(long groupId, long categoryId, Date lastPostDate, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByG_C_L(groupId, categoryId, lastPostDate); List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate, count - 1, count, orderByComparator); if (list.isEmpty()) { 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(", lastPostDate="); msg.append(lastPostDate); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set where groupId = ? and categoryId = ? and lastPostDate = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByG_C_L_PrevAndNext(long threadId, long groupId, long categoryId, Date lastPostDate, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByG_C_L_PrevAndNext(session, mbThread, groupId, categoryId, lastPostDate, orderByComparator, true); array[1] = mbThread; array[2] = getByG_C_L_PrevAndNext(session, mbThread, groupId, categoryId, lastPostDate, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByG_C_L_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, Date lastPostDate, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_C_L_GROUPID_2); query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2); if (lastPostDate == null) { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_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(MBThreadModelImpl.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 (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads that the user has permission to view where groupId = ? and categoryId = ? and lastPostDate = ?. * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @return the matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_L(long groupId, long categoryId, Date lastPostDate) throws SystemException { return filterFindByG_C_L(groupId, categoryId, lastPostDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = ? and lastPostDate = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_L(long groupId, long categoryId, Date lastPostDate, int start, int end) throws SystemException { return filterFindByG_C_L(groupId, categoryId, lastPostDate, start, end, null); } /** * Returns an ordered range of all the message boards threads that the user has permissions to view where groupId = ? and categoryId = ? and lastPostDate = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_L(long groupId, long categoryId, Date lastPostDate, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_L(groupId, categoryId, lastPostDate, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_L_GROUPID_2); query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2); if (lastPostDate == null) { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2); } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); if (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set of message boards threads that the user has permission to view where groupId = ? and categoryId = ? and lastPostDate = ?. * * @param threadId the primary key of the current message boards thread * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next message boards thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] filterFindByG_C_L_PrevAndNext(long threadId, long groupId, long categoryId, Date lastPostDate, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_L_PrevAndNext(threadId, groupId, categoryId, lastPostDate, orderByComparator); } MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId, categoryId, lastPostDate, orderByComparator, true); array[1] = mbThread; array[2] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId, categoryId, lastPostDate, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread filterGetByG_C_L_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, Date lastPostDate, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_C_L_GROUPID_2); query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2); if (lastPostDate == null) { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2); } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_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(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); if (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads 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 threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_S(long groupId, long categoryId, int status) throws SystemException { return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_S(long groupId, long categoryId, int status, int start, int end) throws SystemException { return findByG_C_S(groupId, categoryId, status, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_S(long groupId, long categoryId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { 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<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_MBTHREAD_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 { query.append(MBThreadModelImpl.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); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_C_S_First(long groupId, long categoryId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByG_C_S(groupId, categoryId, status, 0, 1, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_C_S_Last(long groupId, long categoryId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByG_C_S(groupId, categoryId, status); List<MBThread> list = findByG_C_S(groupId, categoryId, status, count - 1, count, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByG_C_S_PrevAndNext(long threadId, long groupId, long categoryId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByG_C_S_PrevAndNext(session, mbThread, groupId, categoryId, status, orderByComparator, true); array[1] = mbThread; array[2] = getByG_C_S_PrevAndNext(session, mbThread, groupId, categoryId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByG_C_S_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_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(MBThreadModelImpl.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(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @return the matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_S(long groupId, long[] categoryIds, int status) throws SystemException { return findByG_C_S(groupId, categoryIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_S(long groupId, long[] categoryIds, int status, int start, int end) throws SystemException { return findByG_C_S(groupId, categoryIds, status, start, end, null); } /** * Returns an ordered range of all the message boards threads where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_S(long groupId, long[] categoryIds, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S; finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds), status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S; finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds), status, start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_STATUS_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.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 (categoryIds != null) { qPos.add(categoryIds); } qPos.add(status); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns all the message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_S(long groupId, long categoryId, int status) throws SystemException { return filterFindByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_S(long groupId, long categoryId, int status, int start, int end) throws SystemException { return filterFindByG_C_S(groupId, categoryId, status, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_S(long groupId, long categoryId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { 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 * 3)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_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_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(status); return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set of message boards threads that the user has permission to view where groupId = ? and categoryId = ? and status = ?. * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] filterFindByG_C_S_PrevAndNext(long threadId, long groupId, long categoryId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_S_PrevAndNext(threadId, groupId, categoryId, status, orderByComparator); } MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId, categoryId, status, orderByComparator, true); array[1] = mbThread; array[2] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId, categoryId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread filterGetByG_C_S_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_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_MBTHREAD_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(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads that the user has permission to view where groupId = ? and categoryId = any ? and status = ?. * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @return the matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds, int status) throws SystemException { return filterFindByG_C_S(groupId, categoryIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds, int status, int start, int end) throws SystemException { return filterFindByG_C_S(groupId, categoryIds, status, start, end, null); } /** * Returns an ordered range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_S(groupId, categoryIds, status, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_STATUS_5); conjunctionable = true; if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } qPos.add(status); return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the message boards threads 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 threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_NotC_S(long groupId, long categoryId, int status) throws SystemException { return findByG_NotC_S(groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_NotC_S(long groupId, long categoryId, int status, int start, int end) throws SystemException { return findByG_NotC_S(groupId, categoryId, status, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_NotC_S(long groupId, long categoryId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_NOTC_S; finderArgs = new Object[] { groupId, categoryId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S; finderArgs = new Object[] { groupId, categoryId, status, start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.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); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_NotC_S_First(long groupId, long categoryId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { List<MBThread> list = findByG_NotC_S(groupId, categoryId, status, 0, 1, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the last message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a matching message boards thread could not be found * @throws SystemException if a system exception occurred */ public MBThread findByG_NotC_S_Last(long groupId, long categoryId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { int count = countByG_NotC_S(groupId, categoryId, status); List<MBThread> list = findByG_NotC_S(groupId, categoryId, status, count - 1, count, orderByComparator); if (list.isEmpty()) { 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 NoSuchThreadException(msg.toString()); } else { return list.get(0); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] findByG_NotC_S_PrevAndNext(long threadId, long groupId, long categoryId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId, categoryId, status, orderByComparator, true); array[1] = mbThread; array[2] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId, categoryId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread getByG_NotC_S_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_NOTC_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(MBThreadModelImpl.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(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId, int status) throws SystemException { return filterFindByG_NotC_S(groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId, int status, int start, int end) throws SystemException { return filterFindByG_NotC_S(groupId, categoryId, status, start, end, null); } /** * Returns an ordered range of all the message boards threads 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_NotC_S(groupId, categoryId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(status); return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the message boards threads before and after the current message boards thread in the ordered set of message boards threads that the user has permission to view where groupId = ? and categoryId ≠ ? and status = ?. * * @param threadId the primary key of the current message boards thread * @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 thread * @throws com.liferay.portlet.messageboards.NoSuchThreadException if a message boards thread with the primary key could not be found * @throws SystemException if a system exception occurred */ public MBThread[] filterFindByG_NotC_S_PrevAndNext(long threadId, long groupId, long categoryId, int status, OrderByComparator orderByComparator) throws NoSuchThreadException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_NotC_S_PrevAndNext(threadId, groupId, categoryId, status, orderByComparator); } MBThread mbThread = findByPrimaryKey(threadId); Session session = null; try { session = openSession(); MBThread[] array = new MBThreadImpl[3]; array[0] = filterGetByG_NotC_S_PrevAndNext(session, mbThread, groupId, categoryId, status, orderByComparator, true); array[1] = mbThread; array[2] = filterGetByG_NotC_S_PrevAndNext(session, mbThread, groupId, categoryId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected MBThread filterGetByG_NotC_S_PrevAndNext(Session session, MBThread mbThread, long groupId, long categoryId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_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(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(categoryId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(mbThread); for (Object value : values) { qPos.add(value); } } List<MBThread> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the message boards threads. * * @return the message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findAll() throws SystemException { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the message boards threads. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @return the range of message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findAll(int start, int end) throws SystemException { return findAll(start, end, null); } /** * Returns an ordered range of all the message boards threads. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findAll(int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = new Object[] { start, end, orderByComparator }; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL; finderArgs = new Object[] { start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 3)); query.append(_SQL_SELECT_MBTHREAD); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_MBTHREAD.concat(MBThreadModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (orderByComparator == null) { list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); } else { list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Removes all the message boards threads where groupId = ? from the database. * * @param groupId the group ID * @throws SystemException if a system exception occurred */ public void removeByGroupId(long groupId) throws SystemException { for (MBThread mbThread : findByGroupId(groupId)) { remove(mbThread); } } /** * Removes the message boards thread where rootMessageId = ? from the database. * * @param rootMessageId the root message ID * @throws SystemException if a system exception occurred */ public void removeByRootMessageId(long rootMessageId) throws NoSuchThreadException, SystemException { MBThread mbThread = findByRootMessageId(rootMessageId); remove(mbThread); } /** * Removes all the message boards threads where groupId = ? and categoryId = ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @throws SystemException if a system exception occurred */ public void removeByG_C(long groupId, long categoryId) throws SystemException { for (MBThread mbThread : findByG_C(groupId, categoryId)) { remove(mbThread); } } /** * Removes all the message boards threads where groupId = ? and categoryId ≠ ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @throws SystemException if a system exception occurred */ public void removeByG_NotC(long groupId, long categoryId) throws SystemException { for (MBThread mbThread : findByG_NotC(groupId, categoryId)) { remove(mbThread); } } /** * Removes all the message boards threads where groupId = ? and status = ? from the database. * * @param groupId the group ID * @param status the status * @throws SystemException if a system exception occurred */ public void removeByG_S(long groupId, int status) throws SystemException { for (MBThread mbThread : findByG_S(groupId, status)) { remove(mbThread); } } /** * Removes all the message boards threads where categoryId = ? and priority = ? from the database. * * @param categoryId the category ID * @param priority the priority * @throws SystemException if a system exception occurred */ public void removeByC_P(long categoryId, double priority) throws SystemException { for (MBThread mbThread : findByC_P(categoryId, priority)) { remove(mbThread); } } /** * Removes all the message boards threads where lastPostDate = ? and priority = ? from the database. * * @param lastPostDate the last post date * @param priority the priority * @throws SystemException if a system exception occurred */ public void removeByL_P(Date lastPostDate, double priority) throws SystemException { for (MBThread mbThread : findByL_P(lastPostDate, priority)) { remove(mbThread); } } /** * Removes all the message boards threads where groupId = ? and categoryId = ? and lastPostDate = ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @throws SystemException if a system exception occurred */ public void removeByG_C_L(long groupId, long categoryId, Date lastPostDate) throws SystemException { for (MBThread mbThread : findByG_C_L(groupId, categoryId, lastPostDate)) { remove(mbThread); } } /** * Removes all the message boards threads where groupId = ? and categoryId = ? and status = ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @param status the status * @throws SystemException if a system exception occurred */ public void removeByG_C_S(long groupId, long categoryId, int status) throws SystemException { for (MBThread mbThread : findByG_C_S(groupId, categoryId, status)) { remove(mbThread); } } /** * Removes all the message boards threads where groupId = ? and categoryId ≠ ? and status = ? from the database. * * @param groupId the group ID * @param categoryId the category ID * @param status the status * @throws SystemException if a system exception occurred */ public void removeByG_NotC_S(long groupId, long categoryId, int status) throws SystemException { for (MBThread mbThread : findByG_NotC_S(groupId, categoryId, status)) { remove(mbThread); } } /** * Removes all the message boards threads from the database. * * @throws SystemException if a system exception occurred */ public void removeAll() throws SystemException { for (MBThread mbThread : findAll()) { remove(mbThread); } } /** * Returns the number of message boards threads where groupId = ?. * * @param groupId the group ID * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByGroupId(long groupId) throws SystemException { Object[] finderArgs = new Object[] { groupId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_MBTHREAD_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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the number of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByGroupId(long groupId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByGroupId(groupId); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(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); } } /** * Returns the number of message boards threads where rootMessageId = ?. * * @param rootMessageId the root message ID * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByRootMessageId(long rootMessageId) throws SystemException { Object[] finderArgs = new Object[] { rootMessageId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(rootMessageId); count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads where groupId = ? and categoryId = ?. * * @param groupId the group ID * @param categoryId the category ID * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByG_C(long groupId, long categoryId) throws SystemException { Object[] finderArgs = new Object[] { groupId, categoryId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBTHREAD_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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads where groupId = ? and categoryId = any ?. * * @param groupId the group ID * @param categoryIds the category IDs * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByG_C(long groupId, long[] categoryIds) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_C(long groupId, long categoryId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C(groupId, categoryId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_C_GROUPID_2); query.append(_FINDER_COLUMN_G_C_CATEGORYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(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); } } /** * Returns the number of message boards threads that the user has permission to view where groupId = ? and categoryId = any ?. * * @param groupId the group ID * @param categoryIds the category IDs * @return the number of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_C(long groupId, long[] categoryIds) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C(groupId, categoryIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of message boards threads where groupId = ? and categoryId ≠ ?. * * @param groupId the group ID * @param categoryId the category ID * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByG_NotC(long groupId, long categoryId) throws SystemException { Object[] finderArgs = new Object[] { groupId, categoryId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_NOTC, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_NOTC, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_NotC(long groupId, long categoryId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_NotC(groupId, categoryId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(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); } } /** * Returns the number of message boards threads where groupId = ? and status = ?. * * @param groupId the group ID * @param status the status * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByG_S(long groupId, int status) throws SystemException { Object[] finderArgs = new Object[] { groupId, status }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBTHREAD_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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_S(long groupId, int status) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_S(groupId, status); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(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); } } /** * Returns the number of message boards threads where categoryId = ? and priority = ?. * * @param categoryId the category ID * @param priority the priority * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByC_P(long categoryId, double priority) throws SystemException { Object[] finderArgs = new Object[] { categoryId, priority }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_C_P_CATEGORYID_2); query.append(_FINDER_COLUMN_C_P_PRIORITY_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); qPos.add(priority); count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads where lastPostDate = ? and priority = ?. * * @param lastPostDate the last post date * @param priority the priority * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByL_P(Date lastPostDate, double priority) throws SystemException { Object[] finderArgs = new Object[] { lastPostDate, priority }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MBTHREAD_WHERE); if (lastPostDate == null) { query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2); } query.append(_FINDER_COLUMN_L_P_PRIORITY_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } qPos.add(priority); count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads where groupId = ? and categoryId = ? and lastPostDate = ?. * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByG_C_L(long groupId, long categoryId, Date lastPostDate) throws SystemException { Object[] finderArgs = new Object[] { groupId, categoryId, lastPostDate }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_C_L_GROUPID_2); query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2); if (lastPostDate == null) { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_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); if (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads that the user has permission to view where groupId = ? and categoryId = ? and lastPostDate = ?. * * @param groupId the group ID * @param categoryId the category ID * @param lastPostDate the last post date * @return the number of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_C_L(long groupId, long categoryId, Date lastPostDate) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C_L(groupId, categoryId, lastPostDate); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_C_L_GROUPID_2); query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2); if (lastPostDate == null) { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1); } else { query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(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); if (lastPostDate != null) { qPos.add(CalendarUtil.getTimestamp(lastPostDate)); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of message boards threads 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 threads * @throws SystemException if a system exception occurred */ public int countByG_C_S(long groupId, long categoryId, int status) throws SystemException { Object[] finderArgs = new Object[] { groupId, categoryId, status }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBTHREAD_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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads where groupId = ? and categoryId = any ? and status = ?. * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByG_C_S(long groupId, long[] categoryIds, int status) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds), status }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_STATUS_5); conjunctionable = true; String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } qPos.add(status); count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_C_S(long groupId, long categoryId, int status) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C_S(groupId, categoryId, status); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_MBTHREAD_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(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(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); } } /** * Returns the number of message boards threads that the user has permission to view where groupId = ? and categoryId = any ? and status = ?. * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @return the number of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_C_S(long groupId, long[] categoryIds, int status) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C_S(groupId, categoryIds, status); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_STATUS_5); conjunctionable = true; String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } qPos.add(status); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of message boards threads 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 threads * @throws SystemException if a system exception occurred */ public int countByG_NotC_S(long groupId, long categoryId, int status) throws SystemException { Object[] finderArgs = new Object[] { groupId, categoryId, status }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_NOTC_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_NOTC_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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_NOTC_S, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of message boards threads 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 threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_NotC_S(long groupId, long categoryId, int status) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_NotC_S(groupId, categoryId, status); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2); query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(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); } } /** * Returns the number of message boards threads. * * @return the number of message boards threads * @throws SystemException if a system exception occurred */ public int countAll() throws SystemException { Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_MBTHREAD); count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count); closeSession(session); } } return count.intValue(); } /** * Initializes the message boards thread persistence. */ public void afterPropertiesSet() { String[] listenerClassNames = StringUtil.split(GetterUtil.getString(com.liferay.portal.util.PropsUtil .get("value.object.listener.com.liferay.portlet.messageboards.model.MBThread"))); if (listenerClassNames.length > 0) { try { List<ModelListener<MBThread>> listenersList = new ArrayList<ModelListener<MBThread>>(); for (String listenerClassName : listenerClassNames) { listenersList.add((ModelListener<MBThread>) InstanceFactory.newInstance(listenerClassName)); } listeners = listenersList.toArray(new ModelListener[listenersList.size()]); } catch (Exception e) { _log.error(e); } } } public void destroy() { EntityCacheUtil.removeCache(MBThreadImpl.class.getName()); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = MBBanPersistence.class) protected MBBanPersistence mbBanPersistence; @BeanReference(type = MBCategoryPersistence.class) protected MBCategoryPersistence mbCategoryPersistence; @BeanReference(type = MBDiscussionPersistence.class) protected MBDiscussionPersistence mbDiscussionPersistence; @BeanReference(type = MBMailingListPersistence.class) protected MBMailingListPersistence mbMailingListPersistence; @BeanReference(type = MBMessagePersistence.class) protected MBMessagePersistence mbMessagePersistence; @BeanReference(type = MBStatsUserPersistence.class) protected MBStatsUserPersistence mbStatsUserPersistence; @BeanReference(type = MBThreadPersistence.class) protected MBThreadPersistence mbThreadPersistence; @BeanReference(type = MBThreadFlagPersistence.class) protected MBThreadFlagPersistence mbThreadFlagPersistence; @BeanReference(type = LockPersistence.class) protected LockPersistence lockPersistence; @BeanReference(type = ResourcePersistence.class) protected ResourcePersistence resourcePersistence; @BeanReference(type = UserPersistence.class) protected UserPersistence userPersistence; @BeanReference(type = WorkflowInstanceLinkPersistence.class) protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence; @BeanReference(type = AssetEntryPersistence.class) protected AssetEntryPersistence assetEntryPersistence; @BeanReference(type = RatingsStatsPersistence.class) protected RatingsStatsPersistence ratingsStatsPersistence; @BeanReference(type = SocialActivityPersistence.class) protected SocialActivityPersistence socialActivityPersistence; private static final String _SQL_SELECT_MBTHREAD = "SELECT mbThread FROM MBThread mbThread"; private static final String _SQL_SELECT_MBTHREAD_WHERE = "SELECT mbThread FROM MBThread mbThread WHERE "; private static final String _SQL_COUNT_MBTHREAD = "SELECT COUNT(mbThread) FROM MBThread mbThread"; private static final String _SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(mbThread) FROM MBThread mbThread WHERE "; private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbThread.groupId = ?"; private static final String _FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2 = "mbThread.rootMessageId = ?"; private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbThread.groupId = ? AND "; private static final String _FINDER_COLUMN_G_C_GROUPID_5 = "(" + _removeConjunction(_FINDER_COLUMN_G_C_GROUPID_2) + ")"; private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbThread.categoryId = ?"; private static final String _FINDER_COLUMN_G_C_CATEGORYID_5 = "(" + _removeConjunction(_FINDER_COLUMN_G_C_CATEGORYID_2) + ")"; private static final String _FINDER_COLUMN_G_NOTC_GROUPID_2 = "mbThread.groupId = ? AND "; private static final String _FINDER_COLUMN_G_NOTC_CATEGORYID_2 = "mbThread.categoryId != ?"; private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbThread.groupId = ? AND "; private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbThread.status = ? AND mbThread.categoryId != -1"; private static final String _FINDER_COLUMN_C_P_CATEGORYID_2 = "mbThread.categoryId = ? AND "; private static final String _FINDER_COLUMN_C_P_PRIORITY_2 = "mbThread.priority = ?"; private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL AND "; private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_2 = "mbThread.lastPostDate = ? AND "; private static final String _FINDER_COLUMN_L_P_PRIORITY_2 = "mbThread.priority = ?"; private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "mbThread.groupId = ? AND "; private static final String _FINDER_COLUMN_G_C_L_CATEGORYID_2 = "mbThread.categoryId = ? AND "; private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL"; private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_2 = "mbThread.lastPostDate = ?"; private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "mbThread.groupId = ? AND "; private static final String _FINDER_COLUMN_G_C_S_GROUPID_5 = "(" + _removeConjunction(_FINDER_COLUMN_G_C_S_GROUPID_2) + ")"; private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbThread.categoryId = ? AND "; private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_5 = "(" + _removeConjunction(_FINDER_COLUMN_G_C_S_CATEGORYID_2) + ")"; private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbThread.status = ?"; private static final String _FINDER_COLUMN_G_C_S_STATUS_5 = "(" + _removeConjunction(_FINDER_COLUMN_G_C_S_STATUS_2) + ")"; private static final String _FINDER_COLUMN_G_NOTC_S_GROUPID_2 = "mbThread.groupId = ? AND "; private static final String _FINDER_COLUMN_G_NOTC_S_CATEGORYID_2 = "mbThread.categoryId != ? AND "; private static final String _FINDER_COLUMN_G_NOTC_S_STATUS_2 = "mbThread.status = ?"; private static String _removeConjunction(String sql) { int pos = sql.indexOf(" AND "); if (pos != -1) { sql = sql.substring(0, pos); } return sql; } private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbThread.threadId"; private static final String _FILTER_SQL_SELECT_MBTHREAD_WHERE = "SELECT DISTINCT {mbThread.*} FROM MBThread mbThread WHERE "; private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {MBThread.*} FROM (SELECT DISTINCT mbThread.threadId FROM MBThread mbThread WHERE "; private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN MBThread ON TEMP_TABLE.threadId = MBThread.threadId"; private static final String _FILTER_SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(DISTINCT mbThread.threadId) AS COUNT_VALUE FROM MBThread mbThread WHERE "; private static final String _FILTER_ENTITY_ALIAS = "mbThread"; private static final String _FILTER_ENTITY_TABLE = "MBThread"; private static final String _ORDER_BY_ENTITY_ALIAS = "mbThread."; private static final String _ORDER_BY_ENTITY_TABLE = "MBThread."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBThread exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBThread exists with the key {"; private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE; private static Log _log = LogFactoryUtil.getLog(MBThreadPersistenceImpl.class); private static MBThread _nullMBThread = new MBThreadImpl() { @Override public Object clone() { return this; } @Override public CacheModel<MBThread> toCacheModel() { return _nullMBThreadCacheModel; } }; private static CacheModel<MBThread> _nullMBThreadCacheModel = new CacheModel<MBThread>() { public MBThread toEntityModel() { return _nullMBThread; } }; }