com.liferay.message.boards.service.persistence.impl.MBBanPersistenceImpl 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 com.liferay.message.boards.exception.NoSuchBanException;
import com.liferay.message.boards.model.MBBan;
import com.liferay.message.boards.model.MBBanTable;
import com.liferay.message.boards.model.impl.MBBanImpl;
import com.liferay.message.boards.model.impl.MBBanModelImpl;
import com.liferay.message.boards.service.persistence.MBBanPersistence;
import com.liferay.message.boards.service.persistence.MBBanUtil;
import com.liferay.message.boards.service.persistence.impl.constants.MBPersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.change.tracking.CTColumnResolutionType;
import com.liferay.portal.kernel.configuration.Configuration;
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.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.change.tracking.helper.CTPersistenceHelper;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUID;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.EnumMap;
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;
import javax.sql.DataSource;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* The persistence implementation for the message boards ban service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
@Component(service = MBBanPersistence.class)
public class MBBanPersistenceImpl
extends BasePersistenceImpl implements MBBanPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use MBBanUtil
to access the message boards ban persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
MBBanImpl.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 bans where uuid = ?.
*
* @param uuid the uuid
* @return the matching message boards bans
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @return the range of matching message boards bans
*/
@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 bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching message boards bans
*/
@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 bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (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 bans
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] {uuid};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] {uuid, start, end, orderByComparator};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBBan mbBan : list) {
if (!uuid.equals(mbBan.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards ban 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 ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByUuid_First(uuid, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the first message boards ban 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 ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan 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 ban 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 ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByUuid_Last(uuid, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the last message boards ban 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 ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan 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 bans before and after the current message boards ban in the ordered set where uuid = ?.
*
* @param banId the primary key of the current message boards ban
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next message boards ban
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan[] findByUuid_PrevAndNext(
long banId, String uuid, OrderByComparator orderByComparator)
throws NoSuchBanException {
uuid = Objects.toString(uuid, "");
MBBan mbBan = findByPrimaryKey(banId);
Session session = null;
try {
session = openSession();
MBBan[] array = new MBBanImpl[3];
array[0] = getByUuid_PrevAndNext(
session, mbBan, uuid, orderByComparator, true);
array[1] = mbBan;
array[2] = getByUuid_PrevAndNext(
session, mbBan, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected MBBan getByUuid_PrevAndNext(
Session session, MBBan mbBan, String uuid,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbBan)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards bans where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (MBBan mbBan :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(mbBan);
}
}
/**
* Returns the number of message boards bans where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching message boards bans
*/
@Override
public int countByUuid(String uuid) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUuid;
finderArgs = new Object[] {uuid};
count = (Long)finderCache.getResult(finderPath, finderArgs, this);
}
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_MBBAN_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbBan.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(mbBan.uuid IS NULL OR mbBan.uuid = '')";
private FinderPath _finderPathFetchByUUID_G;
private FinderPath _finderPathCountByUUID_G;
/**
* Returns the message boards ban where uuid = ? and groupId = ? or throws a NoSuchBanException
if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching message boards ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByUUID_G(String uuid, long groupId)
throws NoSuchBanException {
MBBan mbBan = fetchByUUID_G(uuid, groupId);
if (mbBan == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", groupId=");
sb.append(groupId);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchBanException(sb.toString());
}
return mbBan;
}
/**
* Returns the message boards ban 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 ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
}
/**
* Returns the message boards ban 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 ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan fetchByUUID_G(
String uuid, long groupId, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
Object[] finderArgs = null;
if (useFinderCache && productionMode) {
finderArgs = new Object[] {uuid, groupId};
}
Object result = null;
if (useFinderCache && productionMode) {
result = finderCache.getResult(
_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof MBBan) {
MBBan mbBan = (MBBan)result;
if (!Objects.equals(uuid, mbBan.getUuid()) ||
(groupId != mbBan.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_MBBAN_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache && productionMode) {
finderCache.putResult(
_finderPathFetchByUUID_G, finderArgs, list);
}
}
else {
MBBan mbBan = list.get(0);
result = mbBan;
cacheResult(mbBan);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (MBBan)result;
}
}
/**
* Removes the message boards ban where uuid = ? and groupId = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the message boards ban that was removed
*/
@Override
public MBBan removeByUUID_G(String uuid, long groupId)
throws NoSuchBanException {
MBBan mbBan = findByUUID_G(uuid, groupId);
return remove(mbBan);
}
/**
* Returns the number of message boards bans where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching message boards bans
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUUID_G;
finderArgs = new Object[] {uuid, groupId};
count = (Long)finderCache.getResult(finderPath, finderArgs, this);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_MBBAN_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_G_UUID_2 =
"mbBan.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_3 =
"(mbBan.uuid IS NULL OR mbBan.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 =
"mbBan.groupId = ?";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the message boards bans where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching message boards bans
*/
@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 bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @return the range of matching message boards bans
*/
@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 bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching message boards bans
*/
@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 bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (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 bans
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] {uuid, companyId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] {
uuid, companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBBan mbBan : list) {
if (!uuid.equals(mbBan.getUuid()) ||
(companyId != mbBan.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards ban 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 ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByUuid_C_First(uuid, companyId, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the first message boards ban 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 ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan 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 ban 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 ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the last message boards ban 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 ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan 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 bans before and after the current message boards ban in the ordered set where uuid = ? and companyId = ?.
*
* @param banId the primary key of the current message boards ban
* @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 ban
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan[] findByUuid_C_PrevAndNext(
long banId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchBanException {
uuid = Objects.toString(uuid, "");
MBBan mbBan = findByPrimaryKey(banId);
Session session = null;
try {
session = openSession();
MBBan[] array = new MBBanImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, mbBan, uuid, companyId, orderByComparator, true);
array[1] = mbBan;
array[2] = getByUuid_C_PrevAndNext(
session, mbBan, uuid, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected MBBan getByUuid_C_PrevAndNext(
Session session, MBBan mbBan, String uuid, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbBan)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards bans 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 (MBBan mbBan :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(mbBan);
}
}
/**
* Returns the number of message boards bans where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching message boards bans
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUuid_C;
finderArgs = new Object[] {uuid, companyId};
count = (Long)finderCache.getResult(finderPath, finderArgs, this);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_MBBAN_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"mbBan.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(mbBan.uuid IS NULL OR mbBan.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"mbBan.companyId = ?";
private FinderPath _finderPathWithPaginationFindByGroupId;
private FinderPath _finderPathWithoutPaginationFindByGroupId;
private FinderPath _finderPathCountByGroupId;
/**
* Returns all the message boards bans where groupId = ?.
*
* @param groupId the group ID
* @return the matching message boards bans
*/
@Override
public List findByGroupId(long groupId) {
return findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @return the range of matching message boards bans
*/
@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 bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching message boards bans
*/
@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 bans 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (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 bans
*/
@Override
public List findByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByGroupId;
finderArgs = new Object[] {groupId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByGroupId;
finderArgs = new Object[] {groupId, start, end, orderByComparator};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBBan mbBan : list) {
if (groupId != mbBan.getGroupId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards ban 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 ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByGroupId_First(
long groupId, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByGroupId_First(groupId, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the first message boards ban 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 ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan 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 ban 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 ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByGroupId_Last(
long groupId, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByGroupId_Last(groupId, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the last message boards ban 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 ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan 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 bans before and after the current message boards ban in the ordered set where groupId = ?.
*
* @param banId the primary key of the current message boards ban
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next message boards ban
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan[] findByGroupId_PrevAndNext(
long banId, long groupId,
OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = findByPrimaryKey(banId);
Session session = null;
try {
session = openSession();
MBBan[] array = new MBBanImpl[3];
array[0] = getByGroupId_PrevAndNext(
session, mbBan, groupId, orderByComparator, true);
array[1] = mbBan;
array[2] = getByGroupId_PrevAndNext(
session, mbBan, groupId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected MBBan getByGroupId_PrevAndNext(
Session session, MBBan mbBan, long groupId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbBan)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards bans where groupId = ? from the database.
*
* @param groupId the group ID
*/
@Override
public void removeByGroupId(long groupId) {
for (MBBan mbBan :
findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(mbBan);
}
}
/**
* Returns the number of message boards bans where groupId = ?.
*
* @param groupId the group ID
* @return the number of matching message boards bans
*/
@Override
public int countByGroupId(long groupId) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByGroupId;
finderArgs = new Object[] {groupId};
count = (Long)finderCache.getResult(finderPath, finderArgs, this);
}
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 =
"mbBan.groupId = ?";
private FinderPath _finderPathWithPaginationFindByUserId;
private FinderPath _finderPathWithoutPaginationFindByUserId;
private FinderPath _finderPathCountByUserId;
/**
* Returns all the message boards bans where userId = ?.
*
* @param userId the user ID
* @return the matching message boards bans
*/
@Override
public List findByUserId(long userId) {
return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards bans where userId = ?.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param userId the user ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @return the range of matching message boards bans
*/
@Override
public List findByUserId(long userId, int start, int end) {
return findByUserId(userId, start, end, null);
}
/**
* Returns an ordered range of all the message boards bans where userId = ?.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param userId the user ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching message boards bans
*/
@Override
public List findByUserId(
long userId, int start, int end,
OrderByComparator orderByComparator) {
return findByUserId(userId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards bans where userId = ?.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param userId the user ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (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 bans
*/
@Override
public List findByUserId(
long userId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByUserId;
finderArgs = new Object[] {userId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByUserId;
finderArgs = new Object[] {userId, start, end, orderByComparator};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBBan mbBan : list) {
if (userId != mbBan.getUserId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_USERID_USERID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(userId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards ban in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByUserId_First(
long userId, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByUserId_First(userId, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("userId=");
sb.append(userId);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the first message boards ban in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan fetchByUserId_First(
long userId, OrderByComparator orderByComparator) {
List list = findByUserId(userId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards ban in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByUserId_Last(
long userId, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByUserId_Last(userId, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("userId=");
sb.append(userId);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the last message boards ban in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan fetchByUserId_Last(
long userId, OrderByComparator orderByComparator) {
int count = countByUserId(userId);
if (count == 0) {
return null;
}
List list = findByUserId(
userId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards bans before and after the current message boards ban in the ordered set where userId = ?.
*
* @param banId the primary key of the current message boards ban
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next message boards ban
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan[] findByUserId_PrevAndNext(
long banId, long userId, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = findByPrimaryKey(banId);
Session session = null;
try {
session = openSession();
MBBan[] array = new MBBanImpl[3];
array[0] = getByUserId_PrevAndNext(
session, mbBan, userId, orderByComparator, true);
array[1] = mbBan;
array[2] = getByUserId_PrevAndNext(
session, mbBan, userId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected MBBan getByUserId_PrevAndNext(
Session session, MBBan mbBan, long userId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_USERID_USERID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(userId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbBan)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards bans where userId = ? from the database.
*
* @param userId the user ID
*/
@Override
public void removeByUserId(long userId) {
for (MBBan mbBan :
findByUserId(
userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(mbBan);
}
}
/**
* Returns the number of message boards bans where userId = ?.
*
* @param userId the user ID
* @return the number of matching message boards bans
*/
@Override
public int countByUserId(long userId) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUserId;
finderArgs = new Object[] {userId};
count = (Long)finderCache.getResult(finderPath, finderArgs, this);
}
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_USERID_USERID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(userId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_USERID_USERID_2 =
"mbBan.userId = ?";
private FinderPath _finderPathWithPaginationFindByBanUserId;
private FinderPath _finderPathWithoutPaginationFindByBanUserId;
private FinderPath _finderPathCountByBanUserId;
/**
* Returns all the message boards bans where banUserId = ?.
*
* @param banUserId the ban user ID
* @return the matching message boards bans
*/
@Override
public List findByBanUserId(long banUserId) {
return findByBanUserId(
banUserId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards bans where banUserId = ?.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param banUserId the ban user ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @return the range of matching message boards bans
*/
@Override
public List findByBanUserId(long banUserId, int start, int end) {
return findByBanUserId(banUserId, start, end, null);
}
/**
* Returns an ordered range of all the message boards bans where banUserId = ?.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param banUserId the ban user ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching message boards bans
*/
@Override
public List findByBanUserId(
long banUserId, int start, int end,
OrderByComparator orderByComparator) {
return findByBanUserId(banUserId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards bans where banUserId = ?.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param banUserId the ban user ID
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (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 bans
*/
@Override
public List findByBanUserId(
long banUserId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByBanUserId;
finderArgs = new Object[] {banUserId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByBanUserId;
finderArgs = new Object[] {
banUserId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MBBan mbBan : list) {
if (banUserId != mbBan.getBanUserId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(banUserId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first message boards ban in the ordered set where banUserId = ?.
*
* @param banUserId the ban user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByBanUserId_First(
long banUserId, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByBanUserId_First(banUserId, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("banUserId=");
sb.append(banUserId);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the first message boards ban in the ordered set where banUserId = ?.
*
* @param banUserId the ban user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching message boards ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan fetchByBanUserId_First(
long banUserId, OrderByComparator orderByComparator) {
List list = findByBanUserId(banUserId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last message boards ban in the ordered set where banUserId = ?.
*
* @param banUserId the ban user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByBanUserId_Last(
long banUserId, OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = fetchByBanUserId_Last(banUserId, orderByComparator);
if (mbBan != null) {
return mbBan;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("banUserId=");
sb.append(banUserId);
sb.append("}");
throw new NoSuchBanException(sb.toString());
}
/**
* Returns the last message boards ban in the ordered set where banUserId = ?.
*
* @param banUserId the ban user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching message boards ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan fetchByBanUserId_Last(
long banUserId, OrderByComparator orderByComparator) {
int count = countByBanUserId(banUserId);
if (count == 0) {
return null;
}
List list = findByBanUserId(
banUserId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the message boards bans before and after the current message boards ban in the ordered set where banUserId = ?.
*
* @param banId the primary key of the current message boards ban
* @param banUserId the ban user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next message boards ban
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan[] findByBanUserId_PrevAndNext(
long banId, long banUserId,
OrderByComparator orderByComparator)
throws NoSuchBanException {
MBBan mbBan = findByPrimaryKey(banId);
Session session = null;
try {
session = openSession();
MBBan[] array = new MBBanImpl[3];
array[0] = getByBanUserId_PrevAndNext(
session, mbBan, banUserId, orderByComparator, true);
array[1] = mbBan;
array[2] = getByBanUserId_PrevAndNext(
session, mbBan, banUserId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected MBBan getByBanUserId_PrevAndNext(
Session session, MBBan mbBan, long banUserId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(MBBanModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(banUserId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(mbBan)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the message boards bans where banUserId = ? from the database.
*
* @param banUserId the ban user ID
*/
@Override
public void removeByBanUserId(long banUserId) {
for (MBBan mbBan :
findByBanUserId(
banUserId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(mbBan);
}
}
/**
* Returns the number of message boards bans where banUserId = ?.
*
* @param banUserId the ban user ID
* @return the number of matching message boards bans
*/
@Override
public int countByBanUserId(long banUserId) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByBanUserId;
finderArgs = new Object[] {banUserId};
count = (Long)finderCache.getResult(finderPath, finderArgs, this);
}
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(banUserId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_BANUSERID_BANUSERID_2 =
"mbBan.banUserId = ?";
private FinderPath _finderPathFetchByG_B;
private FinderPath _finderPathCountByG_B;
/**
* Returns the message boards ban where groupId = ? and banUserId = ? or throws a NoSuchBanException
if it could not be found.
*
* @param groupId the group ID
* @param banUserId the ban user ID
* @return the matching message boards ban
* @throws NoSuchBanException if a matching message boards ban could not be found
*/
@Override
public MBBan findByG_B(long groupId, long banUserId)
throws NoSuchBanException {
MBBan mbBan = fetchByG_B(groupId, banUserId);
if (mbBan == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", banUserId=");
sb.append(banUserId);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchBanException(sb.toString());
}
return mbBan;
}
/**
* Returns the message boards ban where groupId = ? and banUserId = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param groupId the group ID
* @param banUserId the ban user ID
* @return the matching message boards ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan fetchByG_B(long groupId, long banUserId) {
return fetchByG_B(groupId, banUserId, true);
}
/**
* Returns the message boards ban where groupId = ? and banUserId = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param groupId the group ID
* @param banUserId the ban user ID
* @param useFinderCache whether to use the finder cache
* @return the matching message boards ban, or null
if a matching message boards ban could not be found
*/
@Override
public MBBan fetchByG_B(
long groupId, long banUserId, boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
Object[] finderArgs = null;
if (useFinderCache && productionMode) {
finderArgs = new Object[] {groupId, banUserId};
}
Object result = null;
if (useFinderCache && productionMode) {
result = finderCache.getResult(
_finderPathFetchByG_B, finderArgs, this);
}
if (result instanceof MBBan) {
MBBan mbBan = (MBBan)result;
if ((groupId != mbBan.getGroupId()) ||
(banUserId != mbBan.getBanUserId())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_G_B_GROUPID_2);
sb.append(_FINDER_COLUMN_G_B_BANUSERID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(banUserId);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache && productionMode) {
finderCache.putResult(
_finderPathFetchByG_B, finderArgs, list);
}
}
else {
MBBan mbBan = list.get(0);
result = mbBan;
cacheResult(mbBan);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (MBBan)result;
}
}
/**
* Removes the message boards ban where groupId = ? and banUserId = ? from the database.
*
* @param groupId the group ID
* @param banUserId the ban user ID
* @return the message boards ban that was removed
*/
@Override
public MBBan removeByG_B(long groupId, long banUserId)
throws NoSuchBanException {
MBBan mbBan = findByG_B(groupId, banUserId);
return remove(mbBan);
}
/**
* Returns the number of message boards bans where groupId = ? and banUserId = ?.
*
* @param groupId the group ID
* @param banUserId the ban user ID
* @return the number of matching message boards bans
*/
@Override
public int countByG_B(long groupId, long banUserId) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByG_B;
finderArgs = new Object[] {groupId, banUserId};
count = (Long)finderCache.getResult(finderPath, finderArgs, this);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_MBBAN_WHERE);
sb.append(_FINDER_COLUMN_G_B_GROUPID_2);
sb.append(_FINDER_COLUMN_G_B_BANUSERID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(banUserId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_G_B_GROUPID_2 =
"mbBan.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_B_BANUSERID_2 =
"mbBan.banUserId = ?";
public MBBanPersistenceImpl() {
Map dbColumnNames = new HashMap();
dbColumnNames.put("uuid", "uuid_");
setDBColumnNames(dbColumnNames);
setModelClass(MBBan.class);
setModelImplClass(MBBanImpl.class);
setModelPKClass(long.class);
setTable(MBBanTable.INSTANCE);
}
/**
* Caches the message boards ban in the entity cache if it is enabled.
*
* @param mbBan the message boards ban
*/
@Override
public void cacheResult(MBBan mbBan) {
if (mbBan.getCtCollectionId() != 0) {
return;
}
entityCache.putResult(MBBanImpl.class, mbBan.getPrimaryKey(), mbBan);
finderCache.putResult(
_finderPathFetchByUUID_G,
new Object[] {mbBan.getUuid(), mbBan.getGroupId()}, mbBan);
finderCache.putResult(
_finderPathFetchByG_B,
new Object[] {mbBan.getGroupId(), mbBan.getBanUserId()}, mbBan);
}
private int _valueObjectFinderCacheListThreshold;
/**
* Caches the message boards bans in the entity cache if it is enabled.
*
* @param mbBans the message boards bans
*/
@Override
public void cacheResult(List mbBans) {
if ((_valueObjectFinderCacheListThreshold == 0) ||
((_valueObjectFinderCacheListThreshold > 0) &&
(mbBans.size() > _valueObjectFinderCacheListThreshold))) {
return;
}
for (MBBan mbBan : mbBans) {
if (mbBan.getCtCollectionId() != 0) {
continue;
}
if (entityCache.getResult(MBBanImpl.class, mbBan.getPrimaryKey()) ==
null) {
cacheResult(mbBan);
}
}
}
/**
* Clears the cache for all message boards bans.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache() {
entityCache.clearCache(MBBanImpl.class);
finderCache.clearCache(MBBanImpl.class);
}
/**
* Clears the cache for the message boards ban.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache(MBBan mbBan) {
entityCache.removeResult(MBBanImpl.class, mbBan);
}
@Override
public void clearCache(List mbBans) {
for (MBBan mbBan : mbBans) {
entityCache.removeResult(MBBanImpl.class, mbBan);
}
}
@Override
public void clearCache(Set primaryKeys) {
finderCache.clearCache(MBBanImpl.class);
for (Serializable primaryKey : primaryKeys) {
entityCache.removeResult(MBBanImpl.class, primaryKey);
}
}
protected void cacheUniqueFindersCache(MBBanModelImpl mbBanModelImpl) {
Object[] args = new Object[] {
mbBanModelImpl.getUuid(), mbBanModelImpl.getGroupId()
};
finderCache.putResult(_finderPathCountByUUID_G, args, Long.valueOf(1));
finderCache.putResult(_finderPathFetchByUUID_G, args, mbBanModelImpl);
args = new Object[] {
mbBanModelImpl.getGroupId(), mbBanModelImpl.getBanUserId()
};
finderCache.putResult(_finderPathCountByG_B, args, Long.valueOf(1));
finderCache.putResult(_finderPathFetchByG_B, args, mbBanModelImpl);
}
/**
* Creates a new message boards ban with the primary key. Does not add the message boards ban to the database.
*
* @param banId the primary key for the new message boards ban
* @return the new message boards ban
*/
@Override
public MBBan create(long banId) {
MBBan mbBan = new MBBanImpl();
mbBan.setNew(true);
mbBan.setPrimaryKey(banId);
String uuid = _portalUUID.generate();
mbBan.setUuid(uuid);
mbBan.setCompanyId(CompanyThreadLocal.getCompanyId());
return mbBan;
}
/**
* Removes the message boards ban with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param banId the primary key of the message boards ban
* @return the message boards ban that was removed
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan remove(long banId) throws NoSuchBanException {
return remove((Serializable)banId);
}
/**
* Removes the message boards ban with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the message boards ban
* @return the message boards ban that was removed
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan remove(Serializable primaryKey) throws NoSuchBanException {
Session session = null;
try {
session = openSession();
MBBan mbBan = (MBBan)session.get(MBBanImpl.class, primaryKey);
if (mbBan == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchBanException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(mbBan);
}
catch (NoSuchBanException noSuchEntityException) {
throw noSuchEntityException;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
@Override
protected MBBan removeImpl(MBBan mbBan) {
Session session = null;
try {
session = openSession();
if (!session.contains(mbBan)) {
mbBan = (MBBan)session.get(
MBBanImpl.class, mbBan.getPrimaryKeyObj());
}
if ((mbBan != null) && ctPersistenceHelper.isRemove(mbBan)) {
session.delete(mbBan);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
if (mbBan != null) {
clearCache(mbBan);
}
return mbBan;
}
@Override
public MBBan updateImpl(MBBan mbBan) {
boolean isNew = mbBan.isNew();
if (!(mbBan instanceof MBBanModelImpl)) {
InvocationHandler invocationHandler = null;
if (ProxyUtil.isProxyClass(mbBan.getClass())) {
invocationHandler = ProxyUtil.getInvocationHandler(mbBan);
throw new IllegalArgumentException(
"Implement ModelWrapper in mbBan proxy " +
invocationHandler.getClass());
}
throw new IllegalArgumentException(
"Implement ModelWrapper in custom MBBan implementation " +
mbBan.getClass());
}
MBBanModelImpl mbBanModelImpl = (MBBanModelImpl)mbBan;
if (Validator.isNull(mbBan.getUuid())) {
String uuid = _portalUUID.generate();
mbBan.setUuid(uuid);
}
ServiceContext serviceContext =
ServiceContextThreadLocal.getServiceContext();
Date date = new Date();
if (isNew && (mbBan.getCreateDate() == null)) {
if (serviceContext == null) {
mbBan.setCreateDate(date);
}
else {
mbBan.setCreateDate(serviceContext.getCreateDate(date));
}
}
if (!mbBanModelImpl.hasSetModifiedDate()) {
if (serviceContext == null) {
mbBan.setModifiedDate(date);
}
else {
mbBan.setModifiedDate(serviceContext.getModifiedDate(date));
}
}
Session session = null;
try {
session = openSession();
if (ctPersistenceHelper.isInsert(mbBan)) {
if (!isNew) {
session.evict(MBBanImpl.class, mbBan.getPrimaryKeyObj());
}
session.save(mbBan);
}
else {
mbBan = (MBBan)session.merge(mbBan);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
if (mbBan.getCtCollectionId() != 0) {
if (isNew) {
mbBan.setNew(false);
}
mbBan.resetOriginalValues();
return mbBan;
}
entityCache.putResult(MBBanImpl.class, mbBanModelImpl, false, true);
cacheUniqueFindersCache(mbBanModelImpl);
if (isNew) {
mbBan.setNew(false);
}
mbBan.resetOriginalValues();
return mbBan;
}
/**
* Returns the message boards ban with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException
if it could not be found.
*
* @param primaryKey the primary key of the message boards ban
* @return the message boards ban
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan findByPrimaryKey(Serializable primaryKey)
throws NoSuchBanException {
MBBan mbBan = fetchByPrimaryKey(primaryKey);
if (mbBan == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchBanException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return mbBan;
}
/**
* Returns the message boards ban with the primary key or throws a NoSuchBanException
if it could not be found.
*
* @param banId the primary key of the message boards ban
* @return the message boards ban
* @throws NoSuchBanException if a message boards ban with the primary key could not be found
*/
@Override
public MBBan findByPrimaryKey(long banId) throws NoSuchBanException {
return findByPrimaryKey((Serializable)banId);
}
/**
* Returns the message boards ban with the primary key or returns null
if it could not be found.
*
* @param primaryKey the primary key of the message boards ban
* @return the message boards ban, or null
if a message boards ban with the primary key could not be found
*/
@Override
public MBBan fetchByPrimaryKey(Serializable primaryKey) {
if (ctPersistenceHelper.isProductionMode(MBBan.class, primaryKey)) {
return super.fetchByPrimaryKey(primaryKey);
}
MBBan mbBan = null;
Session session = null;
try {
session = openSession();
mbBan = (MBBan)session.get(MBBanImpl.class, primaryKey);
if (mbBan != null) {
cacheResult(mbBan);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
return mbBan;
}
/**
* Returns the message boards ban with the primary key or returns null
if it could not be found.
*
* @param banId the primary key of the message boards ban
* @return the message boards ban, or null
if a message boards ban with the primary key could not be found
*/
@Override
public MBBan fetchByPrimaryKey(long banId) {
return fetchByPrimaryKey((Serializable)banId);
}
@Override
public Map fetchByPrimaryKeys(
Set primaryKeys) {
if (ctPersistenceHelper.isProductionMode(MBBan.class)) {
return super.fetchByPrimaryKeys(primaryKeys);
}
if (primaryKeys.isEmpty()) {
return Collections.emptyMap();
}
Map map = new HashMap();
if (primaryKeys.size() == 1) {
Iterator iterator = primaryKeys.iterator();
Serializable primaryKey = iterator.next();
MBBan mbBan = fetchByPrimaryKey(primaryKey);
if (mbBan != null) {
map.put(primaryKey, mbBan);
}
return map;
}
if ((databaseInMaxParameters > 0) &&
(primaryKeys.size() > databaseInMaxParameters)) {
Iterator iterator = primaryKeys.iterator();
while (iterator.hasNext()) {
Set page = new HashSet<>();
for (int i = 0;
(i < databaseInMaxParameters) && iterator.hasNext(); i++) {
page.add(iterator.next());
}
map.putAll(fetchByPrimaryKeys(page));
}
return map;
}
StringBundler sb = new StringBundler((primaryKeys.size() * 2) + 1);
sb.append(getSelectSQL());
sb.append(" WHERE ");
sb.append(getPKDBName());
sb.append(" IN (");
for (Serializable primaryKey : primaryKeys) {
sb.append((long)primaryKey);
sb.append(",");
}
sb.setIndex(sb.index() - 1);
sb.append(")");
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
for (MBBan mbBan : (List)query.list()) {
map.put(mbBan.getPrimaryKeyObj(), mbBan);
cacheResult(mbBan);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
return map;
}
/**
* Returns all the message boards bans.
*
* @return the message boards bans
*/
@Override
public List findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the message boards bans.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @return the range of message boards bans
*/
@Override
public List findAll(int start, int end) {
return findAll(start, end, null);
}
/**
* Returns an ordered range of all the message boards bans.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of message boards bans
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator) {
return findAll(start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the message boards bans.
*
*
* 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, then the query will include the default ORDER BY logic from MBBanModelImpl
.
*
*
* @param start the lower bound of the range of message boards bans
* @param end the upper bound of the range of message boards bans (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 message boards bans
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindAll;
finderArgs = FINDER_ARGS_EMPTY;
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindAll;
finderArgs = new Object[] {start, end, orderByComparator};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
}
if (list == null) {
StringBundler sb = null;
String sql = null;
if (orderByComparator != null) {
sb = new StringBundler(
2 + (orderByComparator.getOrderByFields().length * 2));
sb.append(_SQL_SELECT_MBBAN);
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = sb.toString();
}
else {
sql = _SQL_SELECT_MBBAN;
sql = sql.concat(MBBanModelImpl.ORDER_BY_JPQL);
}
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the message boards bans from the database.
*
*/
@Override
public void removeAll() {
for (MBBan mbBan : findAll()) {
remove(mbBan);
}
}
/**
* Returns the number of message boards bans.
*
* @return the number of message boards bans
*/
@Override
public int countAll() {
boolean productionMode = ctPersistenceHelper.isProductionMode(
MBBan.class);
Long count = null;
if (productionMode) {
count = (Long)finderCache.getResult(
_finderPathCountAll, FINDER_ARGS_EMPTY, this);
}
if (count == null) {
Session session = null;
try {
session = openSession();
Query query = session.createQuery(_SQL_COUNT_MBBAN);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(
_finderPathCountAll, FINDER_ARGS_EMPTY, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
@Override
public Set getBadColumnNames() {
return _badColumnNames;
}
@Override
protected EntityCache getEntityCache() {
return entityCache;
}
@Override
protected String getPKDBName() {
return "banId";
}
@Override
protected String getSelectSQL() {
return _SQL_SELECT_MBBAN;
}
@Override
public Set getCTColumnNames(
CTColumnResolutionType ctColumnResolutionType) {
return _ctColumnNamesMap.getOrDefault(
ctColumnResolutionType, Collections.emptySet());
}
@Override
public List getMappingTableNames() {
return _mappingTableNames;
}
@Override
public Map getTableColumnsMap() {
return MBBanModelImpl.TABLE_COLUMNS_MAP;
}
@Override
public String getTableName() {
return "MBBan";
}
@Override
public List getUniqueIndexColumnNames() {
return _uniqueIndexColumnNames;
}
private static final Map>
_ctColumnNamesMap = new EnumMap>(
CTColumnResolutionType.class);
private static final List _mappingTableNames =
new ArrayList();
private static final List _uniqueIndexColumnNames =
new ArrayList();
static {
Set ctControlColumnNames = new HashSet();
Set ctIgnoreColumnNames = new HashSet();
Set ctStrictColumnNames = new HashSet();
ctControlColumnNames.add("mvccVersion");
ctControlColumnNames.add("ctCollectionId");
ctStrictColumnNames.add("uuid_");
ctStrictColumnNames.add("groupId");
ctStrictColumnNames.add("companyId");
ctStrictColumnNames.add("userId");
ctStrictColumnNames.add("userName");
ctStrictColumnNames.add("createDate");
ctIgnoreColumnNames.add("modifiedDate");
ctStrictColumnNames.add("banUserId");
ctStrictColumnNames.add("lastPublishDate");
_ctColumnNamesMap.put(
CTColumnResolutionType.CONTROL, ctControlColumnNames);
_ctColumnNamesMap.put(
CTColumnResolutionType.IGNORE, ctIgnoreColumnNames);
_ctColumnNamesMap.put(
CTColumnResolutionType.PK, Collections.singleton("banId"));
_ctColumnNamesMap.put(
CTColumnResolutionType.STRICT, ctStrictColumnNames);
_uniqueIndexColumnNames.add(new String[] {"uuid_", "groupId"});
_uniqueIndexColumnNames.add(new String[] {"groupId", "banUserId"});
}
/**
* Initializes the message boards ban persistence.
*/
@Activate
public void activate() {
_valueObjectFinderCacheListThreshold = GetterUtil.getInteger(
PropsUtil.get(PropsKeys.VALUE_OBJECT_FINDER_CACHE_LIST_THRESHOLD));
_finderPathWithPaginationFindAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0],
new String[0], true);
_finderPathWithoutPaginationFindAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0],
new String[0], true);
_finderPathCountAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll",
new String[0], new String[0], false);
_finderPathWithPaginationFindByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
new String[] {
String.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"uuid_"}, true);
_finderPathWithoutPaginationFindByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
new String[] {String.class.getName()}, new String[] {"uuid_"},
true);
_finderPathCountByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
new String[] {String.class.getName()}, new String[] {"uuid_"},
false);
_finderPathFetchByUUID_G = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"uuid_", "groupId"}, true);
_finderPathCountByUUID_G = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"uuid_", "groupId"}, false);
_finderPathWithPaginationFindByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
new String[] {
String.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
},
new String[] {"uuid_", "companyId"}, true);
_finderPathWithoutPaginationFindByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"uuid_", "companyId"}, true);
_finderPathCountByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"uuid_", "companyId"}, false);
_finderPathWithPaginationFindByGroupId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"groupId"}, true);
_finderPathWithoutPaginationFindByGroupId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
new String[] {Long.class.getName()}, new String[] {"groupId"},
true);
_finderPathCountByGroupId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
new String[] {Long.class.getName()}, new String[] {"groupId"},
false);
_finderPathWithPaginationFindByUserId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"userId"}, true);
_finderPathWithoutPaginationFindByUserId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
new String[] {Long.class.getName()}, new String[] {"userId"}, true);
_finderPathCountByUserId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
new String[] {Long.class.getName()}, new String[] {"userId"},
false);
_finderPathWithPaginationFindByBanUserId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByBanUserId",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"banUserId"}, true);
_finderPathWithoutPaginationFindByBanUserId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByBanUserId",
new String[] {Long.class.getName()}, new String[] {"banUserId"},
true);
_finderPathCountByBanUserId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByBanUserId",
new String[] {Long.class.getName()}, new String[] {"banUserId"},
false);
_finderPathFetchByG_B = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByG_B",
new String[] {Long.class.getName(), Long.class.getName()},
new String[] {"groupId", "banUserId"}, true);
_finderPathCountByG_B = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_B",
new String[] {Long.class.getName(), Long.class.getName()},
new String[] {"groupId", "banUserId"}, false);
MBBanUtil.setPersistence(this);
}
@Deactivate
public void deactivate() {
MBBanUtil.setPersistence(null);
entityCache.removeCache(MBBanImpl.class.getName());
}
@Override
@Reference(
target = MBPersistenceConstants.SERVICE_CONFIGURATION_FILTER,
unbind = "-"
)
public void setConfiguration(Configuration configuration) {
}
@Override
@Reference(
target = MBPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
unbind = "-"
)
public void setDataSource(DataSource dataSource) {
super.setDataSource(dataSource);
}
@Override
@Reference(
target = MBPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
unbind = "-"
)
public void setSessionFactory(SessionFactory sessionFactory) {
super.setSessionFactory(sessionFactory);
}
@Reference
protected CTPersistenceHelper ctPersistenceHelper;
@Reference
protected EntityCache entityCache;
@Reference
protected FinderCache finderCache;
private static final String _SQL_SELECT_MBBAN =
"SELECT mbBan FROM MBBan mbBan";
private static final String _SQL_SELECT_MBBAN_WHERE =
"SELECT mbBan FROM MBBan mbBan WHERE ";
private static final String _SQL_COUNT_MBBAN =
"SELECT COUNT(mbBan) FROM MBBan mbBan";
private static final String _SQL_COUNT_MBBAN_WHERE =
"SELECT COUNT(mbBan) FROM MBBan mbBan WHERE ";
private static final String _ORDER_BY_ENTITY_ALIAS = "mbBan.";
private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
"No MBBan exists with the primary key ";
private static final String _NO_SUCH_ENTITY_WITH_KEY =
"No MBBan exists with the key {";
private static final Log _log = LogFactoryUtil.getLog(
MBBanPersistenceImpl.class);
private static final Set _badColumnNames = SetUtil.fromArray(
new String[] {"uuid"});
@Override
protected FinderCache getFinderCache() {
return finderCache;
}
@Reference
private PortalUUID _portalUUID;
}