com.liferay.message.boards.service.persistence.impl.MBThreadPersistenceImpl Maven / Gradle / Ivy
Show all versions of com.liferay.message.boards.service
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.message.boards.service.persistence.impl;
import aQute.bnd.annotation.ProviderType;
import com.liferay.message.boards.exception.NoSuchThreadException;
import com.liferay.message.boards.model.MBThread;
import com.liferay.message.boards.model.impl.MBThreadImpl;
import com.liferay.message.boards.model.impl.MBThreadModelImpl;
import com.liferay.message.boards.service.persistence.MBThreadPersistence;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.sanitizer.Sanitizer;
import com.liferay.portal.kernel.sanitizer.SanitizerException;
import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import com.liferay.portal.spring.extender.service.ServiceReference;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* The persistence implementation for the message boards thread service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
@ProviderType
public class MBThreadPersistenceImpl
extends BasePersistenceImpl implements MBThreadPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use MBThreadUtil
to access the message boards thread persistence. Modify service.xml
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";
private FinderPath _finderPathWithPaginationFindAll;
private FinderPath _finderPathWithoutPaginationFindAll;
private FinderPath _finderPathCountAll;
private FinderPath _finderPathWithPaginationFindByUuid;
private FinderPath _finderPathWithoutPaginationFindByUuid;
private FinderPath _finderPathCountByUuid;
/**
* Returns all the message boards threads where uuid = ?.
*
* @param uuid the uuid
* @return the matching message boards threads
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards threads where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @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
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid(uuid, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] {uuid};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] {uuid, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if (!uuid.equals(mbThread.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_MBTHREAD_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(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 (bindUuid) {
qPos.add(uuid);
}
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByUuid_First(uuid, orderByComparator);
if (mbThread != null) {
return mbThread;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByUuid_First(
String uuid, OrderByComparator orderByComparator) {
List list = findByUuid(uuid, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByUuid_Last(uuid, orderByComparator);
if (mbThread != null) {
return mbThread;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByUuid_Last(
String uuid, OrderByComparator orderByComparator) {
int count = countByUuid(uuid);
if (count == 0) {
return null;
}
List list = findByUuid(
uuid, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set where uuid = ?.
*
* @param threadId the primary key of the current message boards thread
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByUuid_PrevAndNext(
long threadId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
uuid = Objects.toString(uuid, "");
MBThread mbThread = findByPrimaryKey(threadId);
Session session = null;
try {
session = openSession();
MBThread[] array = new MBThreadImpl[3];
array[0] = getByUuid_PrevAndNext(
session, mbThread, uuid, orderByComparator, true);
array[1] = mbThread;
array[2] = getByUuid_PrevAndNext(
session, mbThread, uuid, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MBThread getByUuid_PrevAndNext(
Session session, MBThread mbThread, String uuid,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_MBTHREAD_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(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 (bindUuid) {
qPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards threads where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (MBThread mbThread :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(mbThread);
}
}
/**
* Returns the number of message boards threads where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching message boards threads
*/
@Override
public int countByUuid(String uuid) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid;
Object[] finderArgs = new Object[] {uuid};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_MBTHREAD_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"mbThread.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(mbThread.uuid IS NULL OR mbThread.uuid = '')";
private FinderPath _finderPathFetchByUUID_G;
private FinderPath _finderPathCountByUUID_G;
/**
* Returns the message boards thread where uuid = ? and groupId = ? or throws a NoSuchThreadException
if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByUUID_G(String uuid, long groupId)
throws NoSuchThreadException {
MBThread mbThread = fetchByUUID_G(uuid, groupId);
if (mbThread == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchThreadException(msg.toString());
}
return mbThread;
}
/**
* Returns the message boards thread where uuid = ? and groupId = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
}
/**
* Returns the message boards thread where uuid = ? and groupId = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param useFinderCache whether to use the finder cache
* @return the matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByUUID_G(
String uuid, long groupId, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {uuid, groupId};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof MBThread) {
MBThread mbThread = (MBThread)result;
if (!Objects.equals(uuid, mbThread.getUuid()) ||
(groupId != mbThread.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_MBTHREAD_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
List list = q.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByUUID_G, finderArgs, list);
}
}
else {
MBThread mbThread = list.get(0);
result = mbThread;
cacheResult(mbThread);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(
_finderPathFetchByUUID_G, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (MBThread)result;
}
}
/**
* Removes the message boards thread where uuid = ? and groupId = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the message boards thread that was removed
*/
@Override
public MBThread removeByUUID_G(String uuid, long groupId)
throws NoSuchThreadException {
MBThread mbThread = findByUUID_G(uuid, groupId);
return remove(mbThread);
}
/**
* Returns the number of message boards threads where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching message boards threads
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUUID_G;
Object[] finderArgs = new Object[] {uuid, groupId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_MBTHREAD_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_G_UUID_2 =
"mbThread.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_3 =
"(mbThread.uuid IS NULL OR mbThread.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 =
"mbThread.groupId = ?";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the message boards threads where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching message boards threads
*/
@Override
public List findByUuid_C(String uuid, long companyId) {
return findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards threads where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param companyId the company 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
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end) {
return findByUuid_C(uuid, companyId, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param companyId the company 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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid_C(
uuid, companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param companyId the company 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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] {uuid, companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] {
uuid, companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if (!uuid.equals(mbThread.getUuid()) ||
(companyId != mbThread.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_MBTHREAD_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(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 (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (mbThread != null) {
return mbThread;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", companyId=");
msg.append(companyId);
msg.append("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator) {
List list = findByUuid_C(
uuid, companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (mbThread != null) {
return mbThread;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", companyId=");
msg.append(companyId);
msg.append("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator) {
int count = countByUuid_C(uuid, companyId);
if (count == 0) {
return null;
}
List list = findByUuid_C(
uuid, companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set where uuid = ? and companyId = ?.
*
* @param threadId the primary key of the current message boards thread
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByUuid_C_PrevAndNext(
long threadId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
uuid = Objects.toString(uuid, "");
MBThread mbThread = findByPrimaryKey(threadId);
Session session = null;
try {
session = openSession();
MBThread[] array = new MBThreadImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, mbThread, uuid, companyId, orderByComparator, true);
array[1] = mbThread;
array[2] = getByUuid_C_PrevAndNext(
session, mbThread, uuid, companyId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MBThread getByUuid_C_PrevAndNext(
Session session, MBThread mbThread, String uuid, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_MBTHREAD_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(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 (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards threads where uuid = ? and companyId = ? from the database.
*
* @param uuid the uuid
* @param companyId the company ID
*/
@Override
public void removeByUuid_C(String uuid, long companyId) {
for (MBThread mbThread :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(mbThread);
}
}
/**
* Returns the number of message boards threads where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching message boards threads
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid_C;
Object[] finderArgs = new Object[] {uuid, companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_MBTHREAD_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"mbThread.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(mbThread.uuid IS NULL OR mbThread.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"mbThread.companyId = ?";
private FinderPath _finderPathWithPaginationFindByGroupId;
private FinderPath _finderPathWithoutPaginationFindByGroupId;
private FinderPath _finderPathCountByGroupId;
/**
* Returns all the message boards threads where groupId = ?.
*
* @param groupId the group ID
* @return the matching message boards threads
*/
@Override
public List findByGroupId(long groupId) {
return findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards threads where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByGroupId(long groupId, int start, int end) {
return findByGroupId(groupId, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator) {
return findByGroupId(groupId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByGroupId;
finderArgs = new Object[] {groupId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByGroupId;
finderArgs = new Object[] {groupId, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if ((groupId != mbThread.getGroupId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_MBTHREAD_WHERE);
query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
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 (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByGroupId_First(
long groupId, OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByGroupId_First(groupId, orderByComparator);
if (mbThread != null) {
return mbThread;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByGroupId_First(
long groupId, OrderByComparator orderByComparator) {
List list = findByGroupId(groupId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByGroupId_Last(
long groupId, OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByGroupId_Last(groupId, orderByComparator);
if (mbThread != null) {
return mbThread;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByGroupId_Last(
long groupId, OrderByComparator orderByComparator) {
int count = countByGroupId(groupId);
if (count == 0) {
return null;
}
List list = findByGroupId(
groupId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set 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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByGroupId_PrevAndNext(
long threadId, long groupId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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(
4 + (orderByComparator.getOrderByConditionFields().length * 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) {
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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List 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
*/
@Override
public List filterFindByGroupId(long groupId) {
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 = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List filterFindByGroupId(
long groupId, int start, int end) {
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 = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads that the user has permission to view
*/
@Override
public List filterFindByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByGroupId(groupId, start, end, orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_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, true);
}
else {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
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.createSynchronizedSQLQuery(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)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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] filterFindByGroupId_PrevAndNext(
long threadId, long groupId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(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_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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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.createSynchronizedSQLQuery(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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards threads where groupId = ? from the database.
*
* @param groupId the group ID
*/
@Override
public void removeByGroupId(long groupId) {
for (MBThread mbThread :
findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(mbThread);
}
}
/**
* Returns the number of message boards threads where groupId = ?.
*
* @param groupId the group ID
* @return the number of matching message boards threads
*/
@Override
public int countByGroupId(long groupId) {
FinderPath finderPath = _finderPathCountByGroupId;
Object[] finderArgs = new Object[] {groupId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_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();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of message boards 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
*/
@Override
public int filterCountByGroupId(long groupId) {
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.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 =
"mbThread.groupId = ? AND mbThread.categoryId != -1";
private FinderPath _finderPathFetchByRootMessageId;
private FinderPath _finderPathCountByRootMessageId;
/**
* Returns the message boards thread where rootMessageId = ? or throws a NoSuchThreadException
if it could not be found.
*
* @param rootMessageId the root message ID
* @return the matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByRootMessageId(long rootMessageId)
throws NoSuchThreadException {
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("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchThreadException(msg.toString());
}
return mbThread;
}
/**
* Returns the message boards thread where rootMessageId = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param rootMessageId the root message ID
* @return the matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByRootMessageId(long rootMessageId) {
return fetchByRootMessageId(rootMessageId, true);
}
/**
* Returns the message boards thread where rootMessageId = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param rootMessageId the root message ID
* @param useFinderCache whether to use the finder cache
* @return the matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByRootMessageId(
long rootMessageId, boolean useFinderCache) {
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {rootMessageId};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByRootMessageId, finderArgs, this);
}
if (result instanceof MBThread) {
MBThread mbThread = (MBThread)result;
if ((rootMessageId != mbThread.getRootMessageId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_SELECT_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);
List list = q.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByRootMessageId, finderArgs, list);
}
}
else {
if (list.size() > 1) {
Collections.sort(list, Collections.reverseOrder());
if (_log.isWarnEnabled()) {
if (!useFinderCache) {
finderArgs = new Object[] {rootMessageId};
}
_log.warn(
"MBThreadPersistenceImpl.fetchByRootMessageId(long, boolean) with parameters (" +
StringUtil.merge(finderArgs) +
") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
}
}
MBThread mbThread = list.get(0);
result = mbThread;
cacheResult(mbThread);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(
_finderPathFetchByRootMessageId, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (MBThread)result;
}
}
/**
* Removes the message boards thread where rootMessageId = ? from the database.
*
* @param rootMessageId the root message ID
* @return the message boards thread that was removed
*/
@Override
public MBThread removeByRootMessageId(long rootMessageId)
throws NoSuchThreadException {
MBThread mbThread = findByRootMessageId(rootMessageId);
return remove(mbThread);
}
/**
* Returns the number of message boards threads where rootMessageId = ?.
*
* @param rootMessageId the root message ID
* @return the number of matching message boards threads
*/
@Override
public int countByRootMessageId(long rootMessageId) {
FinderPath finderPath = _finderPathCountByRootMessageId;
Object[] finderArgs = new Object[] {rootMessageId};
Long count = (Long)finderCache.getResult(finderPath, 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();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2 =
"mbThread.rootMessageId = ?";
private FinderPath _finderPathWithPaginationFindByG_C;
private FinderPath _finderPathWithoutPaginationFindByG_C;
private FinderPath _finderPathCountByG_C;
private FinderPath _finderPathWithPaginationCountByG_C;
/**
* 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
*/
@Override
public List findByG_C(long groupId, long categoryId) {
return findByG_C(
groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards threads where groupId = ? and categoryId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByG_C(
long groupId, long categoryId, int start, int end) {
return findByG_C(groupId, categoryId, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_C(
long groupId, long categoryId, int start, int end,
OrderByComparator orderByComparator) {
return findByG_C(
groupId, categoryId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_C(
long groupId, long categoryId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_C;
finderArgs = new Object[] {groupId, categoryId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_C;
finderArgs = new Object[] {
groupId, categoryId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if ((groupId != mbThread.getGroupId()) ||
(categoryId != mbThread.getCategoryId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_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 if (pagination) {
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 (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and categoryId = ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_C_First(
long groupId, long categoryId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_C_First(
groupId, categoryId, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and categoryId = ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_C_First(
long groupId, long categoryId,
OrderByComparator orderByComparator) {
List list = findByG_C(
groupId, categoryId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and categoryId = ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_C_Last(
long groupId, long categoryId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_C_Last(
groupId, categoryId, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and categoryId = ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_C_Last(
long groupId, long categoryId,
OrderByComparator orderByComparator) {
int count = countByG_C(groupId, categoryId);
if (count == 0) {
return null;
}
List list = findByG_C(
groupId, categoryId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set 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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByG_C_PrevAndNext(
long threadId, long groupId, long categoryId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(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) {
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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List 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
*/
@Override
public List filterFindByG_C(long groupId, long categoryId) {
return filterFindByG_C(
groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List filterFindByG_C(
long groupId, long categoryId, int start, int end) {
return filterFindByG_C(groupId, categoryId, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads that the user has permissions to view where groupId = ? and categoryId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads that the user has permission to view
*/
@Override
public List filterFindByG_C(
long groupId, long categoryId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_C(
groupId, categoryId, start, end, orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_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, true);
}
else {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
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.createSynchronizedSQLQuery(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)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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] filterFindByG_C_PrevAndNext(
long threadId, long groupId, long categoryId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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.getOrderByConditionFields().length * 3) +
(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_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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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.createSynchronizedSQLQuery(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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List 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
*/
@Override
public List filterFindByG_C(long groupId, long[] categoryIds) {
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 ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List filterFindByG_C(
long groupId, long[] categoryIds, int start, int end) {
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 ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads that the user has permission to view
*/
@Override
public List filterFindByG_C(
long groupId, long[] categoryIds, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_C(
groupId, categoryIds, start, end, orderByComparator);
}
if (categoryIds == null) {
categoryIds = new long[0];
}
else if (categoryIds.length > 1) {
categoryIds = ArrayUtil.unique(categoryIds);
Arrays.sort(categoryIds);
}
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);
}
query.append(_FINDER_COLUMN_G_C_GROUPID_2);
if (categoryIds.length > 0) {
query.append("(");
query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
query.append(StringUtil.merge(categoryIds));
query.append(")");
query.append(")");
}
query.setStringAt(
removeConjunction(query.stringAt(query.index() - 1)),
query.index() - 1);
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, true);
}
else {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
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.createSynchronizedSQLQuery(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)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 = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param categoryIds the category IDs
* @return the matching message boards threads
*/
@Override
public List findByG_C(long groupId, long[] categoryIds) {
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 ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByG_C(
long groupId, long[] categoryIds, int start, int end) {
return findByG_C(groupId, categoryIds, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_C(
long groupId, long[] categoryIds, int start, int end,
OrderByComparator orderByComparator) {
return findByG_C(
groupId, categoryIds, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_C(
long groupId, long[] categoryIds, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
if (categoryIds == null) {
categoryIds = new long[0];
}
else if (categoryIds.length > 1) {
categoryIds = ArrayUtil.unique(categoryIds);
Arrays.sort(categoryIds);
}
if (categoryIds.length == 1) {
return findByG_C(
groupId, categoryIds[0], start, end, orderByComparator);
}
boolean pagination = true;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderArgs = new Object[] {
groupId, StringUtil.merge(categoryIds)
};
}
}
else if (useFinderCache) {
finderArgs = new Object[] {
groupId, StringUtil.merge(categoryIds), start, end,
orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
_finderPathWithPaginationFindByG_C, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if ((groupId != mbThread.getGroupId()) ||
!ArrayUtil.contains(
categoryIds, mbThread.getCategoryId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = new StringBundler();
query.append(_SQL_SELECT_MBTHREAD_WHERE);
query.append(_FINDER_COLUMN_G_C_GROUPID_2);
if (categoryIds.length > 0) {
query.append("(");
query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
query.append(StringUtil.merge(categoryIds));
query.append(")");
query.append(")");
}
query.setStringAt(
removeConjunction(query.stringAt(query.index() - 1)),
query.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(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 (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(
_finderPathWithPaginationFindByG_C, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(
_finderPathWithPaginationFindByG_C, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the message boards threads where groupId = ? and categoryId = ? from the database.
*
* @param groupId the group ID
* @param categoryId the category ID
*/
@Override
public void removeByG_C(long groupId, long categoryId) {
for (MBThread mbThread :
findByG_C(
groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(mbThread);
}
}
/**
* 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
*/
@Override
public int countByG_C(long groupId, long categoryId) {
FinderPath finderPath = _finderPathCountByG_C;
Object[] finderArgs = new Object[] {groupId, categoryId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_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();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of message boards threads where groupId = ? and categoryId = any ?.
*
* @param groupId the group ID
* @param categoryIds the category IDs
* @return the number of matching message boards threads
*/
@Override
public int countByG_C(long groupId, long[] categoryIds) {
if (categoryIds == null) {
categoryIds = new long[0];
}
else if (categoryIds.length > 1) {
categoryIds = ArrayUtil.unique(categoryIds);
Arrays.sort(categoryIds);
}
Object[] finderArgs = new Object[] {
groupId, StringUtil.merge(categoryIds)
};
Long count = (Long)finderCache.getResult(
_finderPathWithPaginationCountByG_C, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler();
query.append(_SQL_COUNT_MBTHREAD_WHERE);
query.append(_FINDER_COLUMN_G_C_GROUPID_2);
if (categoryIds.length > 0) {
query.append("(");
query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
query.append(StringUtil.merge(categoryIds));
query.append(")");
query.append(")");
}
query.setStringAt(
removeConjunction(query.stringAt(query.index() - 1)),
query.index() - 1);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
count = (Long)q.uniqueResult();
finderCache.putResult(
_finderPathWithPaginationCountByG_C, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(
_finderPathWithPaginationCountByG_C, finderArgs);
throw processException(e);
}
finally {
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
*/
@Override
public int filterCountByG_C(long groupId, long categoryId) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_C(groupId, categoryId);
}
StringBundler query = new StringBundler(3);
query.append(_FILTER_SQL_COUNT_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.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(categoryId);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
/**
* 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
*/
@Override
public int filterCountByG_C(long groupId, long[] categoryIds) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_C(groupId, categoryIds);
}
if (categoryIds == null) {
categoryIds = new long[0];
}
else if (categoryIds.length > 1) {
categoryIds = ArrayUtil.unique(categoryIds);
Arrays.sort(categoryIds);
}
StringBundler query = new StringBundler();
query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
query.append(_FINDER_COLUMN_G_C_GROUPID_2);
if (categoryIds.length > 0) {
query.append("(");
query.append(_FINDER_COLUMN_G_C_CATEGORYID_7);
query.append(StringUtil.merge(categoryIds));
query.append(")");
query.append(")");
}
query.setStringAt(
removeConjunction(query.stringAt(query.index() - 1)),
query.index() - 1);
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.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_C_GROUPID_2 =
"mbThread.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 =
"mbThread.categoryId = ?";
private static final String _FINDER_COLUMN_G_C_CATEGORYID_7 =
"mbThread.categoryId IN (";
private FinderPath _finderPathWithPaginationFindByG_NotC;
private FinderPath _finderPathWithPaginationCountByG_NotC;
/**
* 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
*/
@Override
public List findByG_NotC(long groupId, long categoryId) {
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 ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByG_NotC(
long groupId, long categoryId, int start, int end) {
return findByG_NotC(groupId, categoryId, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_NotC(
long groupId, long categoryId, int start, int end,
OrderByComparator orderByComparator) {
return findByG_NotC(
groupId, categoryId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_NotC(
long groupId, long categoryId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByG_NotC;
finderArgs = new Object[] {
groupId, categoryId, start, end, orderByComparator
};
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if ((groupId != mbThread.getGroupId()) ||
(categoryId == mbThread.getCategoryId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_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 if (pagination) {
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 (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and categoryId ≠ ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_NotC_First(
long groupId, long categoryId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_NotC_First(
groupId, categoryId, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and categoryId ≠ ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_NotC_First(
long groupId, long categoryId,
OrderByComparator orderByComparator) {
List list = findByG_NotC(
groupId, categoryId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and categoryId ≠ ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_NotC_Last(
long groupId, long categoryId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_NotC_Last(
groupId, categoryId, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and categoryId ≠ ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_NotC_Last(
long groupId, long categoryId,
OrderByComparator orderByComparator) {
int count = countByG_NotC(groupId, categoryId);
if (count == 0) {
return null;
}
List list = findByG_NotC(
groupId, categoryId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set 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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByG_NotC_PrevAndNext(
long threadId, long groupId, long categoryId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(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) {
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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List 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
*/
@Override
public List filterFindByG_NotC(long groupId, long categoryId) {
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 ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List filterFindByG_NotC(
long groupId, long categoryId, int start, int end) {
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 ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads that the user has permission to view
*/
@Override
public List filterFindByG_NotC(
long groupId, long categoryId, int start, int end,
OrderByComparator orderByComparator) {
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 * 2));
}
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_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, true);
}
else {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
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.createSynchronizedSQLQuery(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)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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] filterFindByG_NotC_PrevAndNext(
long threadId, long groupId, long categoryId,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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.getOrderByConditionFields().length * 3) +
(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_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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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.createSynchronizedSQLQuery(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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards threads where groupId = ? and categoryId ≠ ? from the database.
*
* @param groupId the group ID
* @param categoryId the category ID
*/
@Override
public void removeByG_NotC(long groupId, long categoryId) {
for (MBThread mbThread :
findByG_NotC(
groupId, categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(mbThread);
}
}
/**
* 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
*/
@Override
public int countByG_NotC(long groupId, long categoryId) {
FinderPath finderPath = _finderPathWithPaginationCountByG_NotC;
Object[] finderArgs = new Object[] {groupId, categoryId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_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();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of message boards 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
*/
@Override
public int filterCountByG_NotC(long groupId, long categoryId) {
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.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(categoryId);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_NOTC_GROUPID_2 =
"mbThread.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_NOTC_CATEGORYID_2 =
"mbThread.categoryId != ?";
private FinderPath _finderPathWithPaginationFindByG_S;
private FinderPath _finderPathWithoutPaginationFindByG_S;
private FinderPath _finderPathCountByG_S;
/**
* 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
*/
@Override
public List findByG_S(long groupId, int status) {
return findByG_S(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards threads where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByG_S(
long groupId, int status, int start, int end) {
return findByG_S(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_S(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByG_S(groupId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_S(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_S;
finderArgs = new Object[] {groupId, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_S;
finderArgs = new Object[] {
groupId, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if ((groupId != mbThread.getGroupId()) ||
(status != mbThread.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_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 if (pagination) {
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);
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_S_First(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_S_First(
groupId, status, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_S_First(
long groupId, int status,
OrderByComparator orderByComparator) {
List list = findByG_S(
groupId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_S_Last(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_S_Last(groupId, status, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_S_Last(
long groupId, int status,
OrderByComparator orderByComparator) {
int count = countByG_S(groupId, status);
if (count == 0) {
return null;
}
List list = findByG_S(
groupId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set 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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByG_S_PrevAndNext(
long threadId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(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) {
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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List 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
*/
@Override
public List filterFindByG_S(long groupId, int status) {
return filterFindByG_S(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards threads that the user has permission to view where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List filterFindByG_S(
long groupId, int status, int start, int end) {
return filterFindByG_S(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads that the user has permissions to view where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads that the user has permission to view
*/
@Override
public List filterFindByG_S(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_S(groupId, status, start, end, orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_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, true);
}
else {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
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.createSynchronizedSQLQuery(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)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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] filterFindByG_S_PrevAndNext(
long threadId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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.getOrderByConditionFields().length * 3) +
(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_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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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.createSynchronizedSQLQuery(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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards threads where groupId = ? and status = ? from the database.
*
* @param groupId the group ID
* @param status the status
*/
@Override
public void removeByG_S(long groupId, int status) {
for (MBThread mbThread :
findByG_S(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(mbThread);
}
}
/**
* 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
*/
@Override
public int countByG_S(long groupId, int status) {
FinderPath finderPath = _finderPathCountByG_S;
Object[] finderArgs = new Object[] {groupId, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_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();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of message boards 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
*/
@Override
public int filterCountByG_S(long groupId, int status) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_S(groupId, status);
}
StringBundler query = new StringBundler(3);
query.append(_FILTER_SQL_COUNT_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.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_S_GROUPID_2 =
"mbThread.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_S_STATUS_2 =
"mbThread.status = ? AND mbThread.categoryId != -1";
private FinderPath _finderPathWithPaginationFindByC_P;
private FinderPath _finderPathWithoutPaginationFindByC_P;
private FinderPath _finderPathCountByC_P;
/**
* 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
*/
@Override
public List findByC_P(long categoryId, double priority) {
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 = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByC_P(
long categoryId, double priority, int start, int end) {
return findByC_P(categoryId, priority, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where categoryId = ? and priority = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByC_P(
long categoryId, double priority, int start, int end,
OrderByComparator orderByComparator) {
return findByC_P(
categoryId, priority, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where categoryId = ? and priority = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByC_P(
long categoryId, double priority, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByC_P;
finderArgs = new Object[] {categoryId, priority};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByC_P;
finderArgs = new Object[] {
categoryId, priority, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if ((categoryId != mbThread.getCategoryId()) ||
(priority != mbThread.getPriority())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_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 if (pagination) {
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);
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where categoryId = ? and priority = ?.
*
* @param categoryId the category ID
* @param priority the priority
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByC_P_First(
long categoryId, double priority,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByC_P_First(
categoryId, priority, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where categoryId = ? and priority = ?.
*
* @param categoryId the category ID
* @param priority the priority
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByC_P_First(
long categoryId, double priority,
OrderByComparator orderByComparator) {
List list = findByC_P(
categoryId, priority, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where categoryId = ? and priority = ?.
*
* @param categoryId the category ID
* @param priority the priority
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByC_P_Last(
long categoryId, double priority,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByC_P_Last(
categoryId, priority, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where categoryId = ? and priority = ?.
*
* @param categoryId the category ID
* @param priority the priority
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByC_P_Last(
long categoryId, double priority,
OrderByComparator orderByComparator) {
int count = countByC_P(categoryId, priority);
if (count == 0) {
return null;
}
List list = findByC_P(
categoryId, priority, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set where categoryId = ? and priority = ?.
*
* @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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByC_P_PrevAndNext(
long threadId, long categoryId, double priority,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(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) {
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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards threads where categoryId = ? and priority = ? from the database.
*
* @param categoryId the category ID
* @param priority the priority
*/
@Override
public void removeByC_P(long categoryId, double priority) {
for (MBThread mbThread :
findByC_P(
categoryId, priority, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(mbThread);
}
}
/**
* 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
*/
@Override
public int countByC_P(long categoryId, double priority) {
FinderPath finderPath = _finderPathCountByC_P;
Object[] finderArgs = new Object[] {categoryId, priority};
Long count = (Long)finderCache.getResult(finderPath, 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();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_P_CATEGORYID_2 =
"mbThread.categoryId = ? AND ";
private static final String _FINDER_COLUMN_C_P_PRIORITY_2 =
"mbThread.priority = ?";
private FinderPath _finderPathWithPaginationFindByL_P;
private FinderPath _finderPathWithoutPaginationFindByL_P;
private FinderPath _finderPathCountByL_P;
/**
* 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
*/
@Override
public List findByL_P(Date lastPostDate, double priority) {
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 = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByL_P(
Date lastPostDate, double priority, int start, int end) {
return findByL_P(lastPostDate, priority, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where lastPostDate = ? and priority = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByL_P(
Date lastPostDate, double priority, int start, int end,
OrderByComparator orderByComparator) {
return findByL_P(
lastPostDate, priority, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where lastPostDate = ? and priority = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByL_P(
Date lastPostDate, double priority, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByL_P;
finderArgs = new Object[] {_getTime(lastPostDate), priority};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByL_P;
finderArgs = new Object[] {
_getTime(lastPostDate), priority, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if (!Objects.equals(
lastPostDate, mbThread.getLastPostDate()) ||
(priority != mbThread.getPriority())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_MBTHREAD_WHERE);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
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 if (pagination) {
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 (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
qPos.add(priority);
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where lastPostDate = ? and priority = ?.
*
* @param lastPostDate the last post date
* @param priority the priority
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByL_P_First(
Date lastPostDate, double priority,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByL_P_First(
lastPostDate, priority, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where lastPostDate = ? and priority = ?.
*
* @param lastPostDate the last post date
* @param priority the priority
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByL_P_First(
Date lastPostDate, double priority,
OrderByComparator orderByComparator) {
List list = findByL_P(
lastPostDate, priority, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where lastPostDate = ? and priority = ?.
*
* @param lastPostDate the last post date
* @param priority the priority
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByL_P_Last(
Date lastPostDate, double priority,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByL_P_Last(
lastPostDate, priority, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where lastPostDate = ? and priority = ?.
*
* @param lastPostDate the last post date
* @param priority the priority
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByL_P_Last(
Date lastPostDate, double priority,
OrderByComparator orderByComparator) {
int count = countByL_P(lastPostDate, priority);
if (count == 0) {
return null;
}
List list = findByL_P(
lastPostDate, priority, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set where lastPostDate = ? and priority = ?.
*
* @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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByL_P_PrevAndNext(
long threadId, Date lastPostDate, double priority,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_MBTHREAD_WHERE);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
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 (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
qPos.add(priority);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards threads where lastPostDate = ? and priority = ? from the database.
*
* @param lastPostDate the last post date
* @param priority the priority
*/
@Override
public void removeByL_P(Date lastPostDate, double priority) {
for (MBThread mbThread :
findByL_P(
lastPostDate, priority, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(mbThread);
}
}
/**
* 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
*/
@Override
public int countByL_P(Date lastPostDate, double priority) {
FinderPath finderPath = _finderPathCountByL_P;
Object[] finderArgs = new Object[] {_getTime(lastPostDate), priority};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_MBTHREAD_WHERE);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
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 (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
qPos.add(priority);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_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 = ? AND mbThread.categoryId != -1";
private FinderPath _finderPathWithPaginationFindByG_C_L;
private FinderPath _finderPathWithoutPaginationFindByG_C_L;
private FinderPath _finderPathCountByG_C_L;
/**
* 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
*/
@Override
public List findByG_C_L(
long groupId, long categoryId, Date lastPostDate) {
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 = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByG_C_L(
long groupId, long categoryId, Date lastPostDate, int start, int end) {
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 = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_C_L(
long groupId, long categoryId, Date lastPostDate, int start, int end,
OrderByComparator orderByComparator) {
return findByG_C_L(
groupId, categoryId, lastPostDate, start, end, orderByComparator,
true);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId = ? and lastPostDate = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_C_L(
long groupId, long categoryId, Date lastPostDate, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_C_L;
finderArgs = new Object[] {
groupId, categoryId, _getTime(lastPostDate)
};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_C_L;
finderArgs = new Object[] {
groupId, categoryId, _getTime(lastPostDate), start, end,
orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if ((groupId != mbThread.getGroupId()) ||
(categoryId != mbThread.getCategoryId()) ||
!Objects.equals(
lastPostDate, mbThread.getLastPostDate())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
query.append(_SQL_SELECT_MBTHREAD_WHERE);
query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
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 (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and categoryId = ? and lastPostDate = ?.
*
* @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 null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_C_L_First(
long groupId, long categoryId, Date lastPostDate,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_C_L_First(
groupId, categoryId, lastPostDate, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and categoryId = ? and lastPostDate = ?.
*
* @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 null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_C_L_First(
long groupId, long categoryId, Date lastPostDate,
OrderByComparator orderByComparator) {
List list = findByG_C_L(
groupId, categoryId, lastPostDate, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and categoryId = ? and lastPostDate = ?.
*
* @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 null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_C_L_Last(
long groupId, long categoryId, Date lastPostDate,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_C_L_Last(
groupId, categoryId, lastPostDate, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and categoryId = ? and lastPostDate = ?.
*
* @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 null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_C_L_Last(
long groupId, long categoryId, Date lastPostDate,
OrderByComparator orderByComparator) {
int count = countByG_C_L(groupId, categoryId, lastPostDate);
if (count == 0) {
return null;
}
List list = findByG_C_L(
groupId, categoryId, lastPostDate, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set 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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByG_C_L_PrevAndNext(
long threadId, long groupId, long categoryId, Date lastPostDate,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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.getOrderByConditionFields().length * 3) +
(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);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
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 (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List 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
*/
@Override
public List filterFindByG_C_L(
long groupId, long categoryId, Date lastPostDate) {
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 = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List filterFindByG_C_L(
long groupId, long categoryId, Date lastPostDate, int start, int end) {
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 = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads that the user has permission to view
*/
@Override
public List filterFindByG_C_L(
long groupId, long categoryId, Date lastPostDate, int start, int end,
OrderByComparator orderByComparator) {
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 * 2));
}
else {
query = new StringBundler(6);
}
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);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
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, true);
}
else {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
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.createSynchronizedSQLQuery(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 (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
return (List)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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] filterFindByG_C_L_PrevAndNext(
long threadId, long groupId, long categoryId, Date lastPostDate,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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(
7 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(6);
}
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);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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.createSynchronizedSQLQuery(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 (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* 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
*/
@Override
public void removeByG_C_L(
long groupId, long categoryId, Date lastPostDate) {
for (MBThread mbThread :
findByG_C_L(
groupId, categoryId, lastPostDate, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(mbThread);
}
}
/**
* 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
*/
@Override
public int countByG_C_L(long groupId, long categoryId, Date lastPostDate) {
FinderPath finderPath = _finderPathCountByG_C_L;
Object[] finderArgs = new Object[] {
groupId, categoryId, _getTime(lastPostDate)
};
Long count = (Long)finderCache.getResult(finderPath, 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);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
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 (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of message boards 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
*/
@Override
public int filterCountByG_C_L(
long groupId, long categoryId, Date lastPostDate) {
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);
boolean bindLastPostDate = false;
if (lastPostDate == null) {
query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
}
else {
bindLastPostDate = true;
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.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(categoryId);
if (bindLastPostDate) {
qPos.add(new Timestamp(lastPostDate.getTime()));
}
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_C_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 FinderPath _finderPathWithPaginationFindByG_C_S;
private FinderPath _finderPathWithoutPaginationFindByG_C_S;
private FinderPath _finderPathCountByG_C_S;
private FinderPath _finderPathWithPaginationCountByG_C_S;
/**
* 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
*/
@Override
public List findByG_C_S(
long groupId, long categoryId, int status) {
return findByG_C_S(
groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the message boards threads where groupId = ? and categoryId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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
*/
@Override
public List findByG_C_S(
long groupId, long categoryId, int status, int start, int end) {
return findByG_C_S(groupId, categoryId, status, start, end, null);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_C_S(
long groupId, long categoryId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByG_C_S(
groupId, categoryId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards threads where groupId = ? and categoryId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from MBThreadModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @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 null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching message boards threads
*/
@Override
public List findByG_C_S(
long groupId, long categoryId, int status, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_C_S;
finderArgs = new Object[] {groupId, categoryId, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_C_S;
finderArgs = new Object[] {
groupId, categoryId, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBThread mbThread : list) {
if ((groupId != mbThread.getGroupId()) ||
(categoryId != mbThread.getCategoryId()) ||
(status != mbThread.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
query.append(_SQL_SELECT_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 if (pagination) {
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);
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and categoryId = ? and status = ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_C_S_First(
long groupId, long categoryId, int status,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_C_S_First(
groupId, categoryId, status, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the first message boards thread in the ordered set where groupId = ? and categoryId = ? and status = ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_C_S_First(
long groupId, long categoryId, int status,
OrderByComparator orderByComparator) {
List list = findByG_C_S(
groupId, categoryId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and categoryId = ? and status = ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread
* @throws NoSuchThreadException if a matching message boards thread could not be found
*/
@Override
public MBThread findByG_C_S_Last(
long groupId, long categoryId, int status,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
MBThread mbThread = fetchByG_C_S_Last(
groupId, categoryId, status, orderByComparator);
if (mbThread != null) {
return mbThread;
}
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("}");
throw new NoSuchThreadException(msg.toString());
}
/**
* Returns the last message boards thread in the ordered set where groupId = ? and categoryId = ? and status = ?.
*
* @param groupId the group ID
* @param categoryId the category ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards thread, or null
if a matching message boards thread could not be found
*/
@Override
public MBThread fetchByG_C_S_Last(
long groupId, long categoryId, int status,
OrderByComparator orderByComparator) {
int count = countByG_C_S(groupId, categoryId, status);
if (count == 0) {
return null;
}
List list = findByG_C_S(
groupId, categoryId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards threads before and after the current message boards thread in the ordered set 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 null
)
* @return the previous, current, and next message boards thread
* @throws NoSuchThreadException if a message boards thread with the primary key could not be found
*/
@Override
public MBThread[] findByG_C_S_PrevAndNext(
long threadId, long groupId, long categoryId, int status,
OrderByComparator orderByComparator)
throws NoSuchThreadException {
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.getOrderByConditionFields().length * 3) +
(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) {
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) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbThread)) {
qPos.add(orderByConditionValue);
}
}
List 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
*/
@Override
public List filterFindByG_C_S(
long groupId, long categoryId, int status) {
return filterFindByG_C_S(
groupId, categoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of