
com.liferay.knowledge.base.service.persistence.impl.KBArticlePersistenceImpl Maven / Gradle / Ivy
/**
* 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.knowledge.base.service.persistence.impl;
import aQute.bnd.annotation.ProviderType;
import com.liferay.knowledge.base.exception.NoSuchArticleException;
import com.liferay.knowledge.base.model.KBArticle;
import com.liferay.knowledge.base.model.impl.KBArticleImpl;
import com.liferay.knowledge.base.model.impl.KBArticleModelImpl;
import com.liferay.knowledge.base.service.persistence.KBArticlePersistence;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.CompanyProvider;
import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.CharPool;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import com.liferay.portal.spring.extender.service.ServiceReference;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* The persistence implementation for the k b article service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @see KBArticlePersistence
* @see com.liferay.knowledge.base.service.persistence.KBArticleUtil
* @generated
*/
@ProviderType
public class KBArticlePersistenceImpl extends BasePersistenceImpl
implements KBArticlePersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use {@link KBArticleUtil} to access the k b article persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY = KBArticleImpl.class.getName();
public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
".List1";
public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
".List2";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
new String[] {
String.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
new String[] { String.class.getName() },
KBArticleModelImpl.UUID_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
new String[] { String.class.getName() });
/**
* Returns all the k b articles where uuid = ?.
*
* @param uuid the uuid
* @return the matching k b articles
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the k b articles 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@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 k b articles 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByUuid(String uuid, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
finderArgs = new Object[] { uuid };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
finderArgs = new Object[] { uuid, start, end, orderByComparator };
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if (!Objects.equals(uuid, kbArticle.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(3 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article 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 k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByUuid_First(String uuid,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByUuid_First(uuid, orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article 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 k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle 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 k b article 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 k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByUuid_Last(String uuid,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByUuid_Last(uuid, orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article 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 k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle 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 k b articles before and after the current k b article in the ordered set where uuid = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByUuid_PrevAndNext(long kbArticleId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByUuid_PrevAndNext(session, kbArticle, uuid,
orderByComparator, true);
array[1] = kbArticle;
array[2] = getByUuid_PrevAndNext(session, kbArticle, uuid,
orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByUuid_PrevAndNext(Session session,
KBArticle kbArticle, String uuid,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the k b articles where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (KBArticle kbArticle : findByUuid(uuid, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching k b articles
*/
@Override
public int countByUuid(String uuid) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
Object[] finderArgs = new Object[] { uuid };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_UUID_1 = "kbArticle.uuid IS NULL";
private static final String _FINDER_COLUMN_UUID_UUID_2 = "kbArticle.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 = "(kbArticle.uuid IS NULL OR kbArticle.uuid = '')";
public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
new String[] { String.class.getName(), Long.class.getName() },
KBArticleModelImpl.UUID_COLUMN_BITMASK |
KBArticleModelImpl.GROUPID_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
new String[] { String.class.getName(), Long.class.getName() });
/**
* Returns the k b article where uuid = ? and groupId = ? or throws a {@link NoSuchArticleException} if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByUUID_G(String uuid, long groupId)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByUUID_G(uuid, groupId);
if (kbArticle == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchArticleException(msg.toString());
}
return kbArticle;
}
/**
* Returns the k b article 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 k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
}
/**
* Returns the k b article 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 retrieveFromCache whether to retrieve from the finder cache
* @return the matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByUUID_G(String uuid, long groupId,
boolean retrieveFromCache) {
Object[] finderArgs = new Object[] { uuid, groupId };
Object result = null;
if (retrieveFromCache) {
result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
finderArgs, this);
}
if (result instanceof KBArticle) {
KBArticle kbArticle = (KBArticle)result;
if (!Objects.equals(uuid, kbArticle.getUuid()) ||
(groupId != kbArticle.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_KBARTICLE_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_G_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
List list = q.list();
if (list.isEmpty()) {
finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
finderArgs, list);
}
else {
KBArticle kbArticle = list.get(0);
result = kbArticle;
cacheResult(kbArticle);
if ((kbArticle.getUuid() == null) ||
!kbArticle.getUuid().equals(uuid) ||
(kbArticle.getGroupId() != groupId)) {
finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
finderArgs, kbArticle);
}
}
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (KBArticle)result;
}
}
/**
* Removes the k b article where uuid = ? and groupId = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the k b article that was removed
*/
@Override
public KBArticle removeByUUID_G(String uuid, long groupId)
throws NoSuchArticleException {
KBArticle kbArticle = findByUUID_G(uuid, groupId);
return remove(kbArticle);
}
/**
* Returns the number of k b articles where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching k b articles
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
Object[] finderArgs = new Object[] { uuid, groupId };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_G_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "kbArticle.uuid IS NULL AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "kbArticle.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(kbArticle.uuid IS NULL OR kbArticle.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "kbArticle.groupId = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
new String[] {
String.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
new String[] { String.class.getName(), Long.class.getName() },
KBArticleModelImpl.UUID_COLUMN_BITMASK |
KBArticleModelImpl.COMPANYID_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
new String[] { String.class.getName(), Long.class.getName() });
/**
* Returns all the k b articles where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching k b articles
*/
@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 k b articles 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@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 k b articles 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@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 k b articles 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByUuid_C(String uuid, long companyId, int start,
int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
finderArgs = new Object[] { uuid, companyId };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
finderArgs = new Object[] {
uuid, companyId,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if (!Objects.equals(uuid, kbArticle.getUuid()) ||
(companyId != kbArticle.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_C_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article 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 k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByUuid_C_First(String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByUuid_C_First(uuid, companyId,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", companyId=");
msg.append(companyId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article 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 k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle 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 k b article 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 k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByUuid_C_Last(String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByUuid_C_Last(uuid, companyId,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", companyId=");
msg.append(companyId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article 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 k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle 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 k b articles before and after the current k b article in the ordered set where uuid = ? and companyId = ?.
*
* @param kbArticleId the primary key of the current k b article
* @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 k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByUuid_C_PrevAndNext(long kbArticleId, String uuid,
long companyId, OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByUuid_C_PrevAndNext(session, kbArticle, uuid,
companyId, orderByComparator, true);
array[1] = kbArticle;
array[2] = getByUuid_C_PrevAndNext(session, kbArticle, uuid,
companyId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByUuid_C_PrevAndNext(Session session,
KBArticle kbArticle, String uuid, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_C_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the k b articles 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 (KBArticle kbArticle : findByUuid_C(uuid, companyId,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching k b articles
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
Object[] finderArgs = new Object[] { uuid, companyId };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_C_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "kbArticle.uuid IS NULL AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "kbArticle.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(kbArticle.uuid IS NULL OR kbArticle.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "kbArticle.companyId = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByResourcePrimKey",
new String[] {
Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
new String[] { Long.class.getName() },
KBArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
"countByResourcePrimKey", new String[] { Long.class.getName() });
/**
* Returns all the k b articles where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @return the matching k b articles
*/
@Override
public List findByResourcePrimKey(long resourcePrimKey) {
return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles where resourcePrimKey = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByResourcePrimKey(long resourcePrimKey,
int start, int end) {
return findByResourcePrimKey(resourcePrimKey, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByResourcePrimKey(long resourcePrimKey,
int start, int end, OrderByComparator orderByComparator) {
return findByResourcePrimKey(resourcePrimKey, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByResourcePrimKey(long resourcePrimKey,
int start, int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
finderArgs = new Object[] { resourcePrimKey };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
finderArgs = new Object[] {
resourcePrimKey,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if ((resourcePrimKey != kbArticle.getResourcePrimKey())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(3 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByResourcePrimKey_First(long resourcePrimKey,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByResourcePrimKey_First(resourcePrimKey,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByResourcePrimKey_First(long resourcePrimKey,
OrderByComparator orderByComparator) {
List list = findByResourcePrimKey(resourcePrimKey, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByResourcePrimKey_Last(long resourcePrimKey,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
OrderByComparator orderByComparator) {
int count = countByResourcePrimKey(resourcePrimKey);
if (count == 0) {
return null;
}
List list = findByResourcePrimKey(resourcePrimKey,
count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the k b articles before and after the current k b article in the ordered set where resourcePrimKey = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByResourcePrimKey_PrevAndNext(long kbArticleId,
long resourcePrimKey, OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByResourcePrimKey_PrevAndNext(session, kbArticle,
resourcePrimKey, orderByComparator, true);
array[1] = kbArticle;
array[2] = getByResourcePrimKey_PrevAndNext(session, kbArticle,
resourcePrimKey, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByResourcePrimKey_PrevAndNext(Session session,
KBArticle kbArticle, long resourcePrimKey,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the k b articles where resourcePrimKey = ? from the database.
*
* @param resourcePrimKey the resource prim key
*/
@Override
public void removeByResourcePrimKey(long resourcePrimKey) {
for (KBArticle kbArticle : findByResourcePrimKey(resourcePrimKey,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @return the number of matching k b articles
*/
@Override
public int countByResourcePrimKey(long resourcePrimKey) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
Object[] finderArgs = new Object[] { resourcePrimKey };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
"kbArticle.resourcePrimKey = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_G = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_G",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_G = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_G",
new String[] { Long.class.getName(), Long.class.getName() },
KBArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
KBArticleModelImpl.GROUPID_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_R_G = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_G",
new String[] { Long.class.getName(), Long.class.getName() });
/**
* Returns all the k b articles where resourcePrimKey = ? and groupId = ?.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @return the matching k b articles
*/
@Override
public List findByR_G(long resourcePrimKey, long groupId) {
return findByR_G(resourcePrimKey, groupId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles where resourcePrimKey = ? and 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByR_G(long resourcePrimKey, long groupId,
int start, int end) {
return findByR_G(resourcePrimKey, groupId, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_G(long resourcePrimKey, long groupId,
int start, int end, OrderByComparator orderByComparator) {
return findByR_G(resourcePrimKey, groupId, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_G(long resourcePrimKey, long groupId,
int start, int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_G;
finderArgs = new Object[] { resourcePrimKey, groupId };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_G;
finderArgs = new Object[] {
resourcePrimKey, groupId,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if ((resourcePrimKey != kbArticle.getResourcePrimKey()) ||
(groupId != kbArticle.getGroupId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_G_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_G_GROUPID_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(groupId);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ? and groupId = ?.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_G_First(long resourcePrimKey, long groupId,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_G_First(resourcePrimKey, groupId,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", groupId=");
msg.append(groupId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ? and groupId = ?.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_G_First(long resourcePrimKey, long groupId,
OrderByComparator orderByComparator) {
List list = findByR_G(resourcePrimKey, groupId, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ? and groupId = ?.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_G_Last(long resourcePrimKey, long groupId,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_G_Last(resourcePrimKey, groupId,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", groupId=");
msg.append(groupId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ? and groupId = ?.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_G_Last(long resourcePrimKey, long groupId,
OrderByComparator orderByComparator) {
int count = countByR_G(resourcePrimKey, groupId);
if (count == 0) {
return null;
}
List list = findByR_G(resourcePrimKey, groupId, count - 1,
count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the k b articles before and after the current k b article in the ordered set where resourcePrimKey = ? and groupId = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByR_G_PrevAndNext(long kbArticleId,
long resourcePrimKey, long groupId,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByR_G_PrevAndNext(session, kbArticle,
resourcePrimKey, groupId, orderByComparator, true);
array[1] = kbArticle;
array[2] = getByR_G_PrevAndNext(session, kbArticle,
resourcePrimKey, groupId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByR_G_PrevAndNext(Session session,
KBArticle kbArticle, long resourcePrimKey, long groupId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_G_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_G_GROUPID_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(groupId);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the k b articles that the user has permission to view where resourcePrimKey = ? and groupId = ?.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @return the matching k b articles that the user has permission to view
*/
@Override
public List filterFindByR_G(long resourcePrimKey, long groupId) {
return filterFindByR_G(resourcePrimKey, groupId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles that the user has permission to view where resourcePrimKey = ? and 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles that the user has permission to view
*/
@Override
public List filterFindByR_G(long resourcePrimKey, long groupId,
int start, int end) {
return filterFindByR_G(resourcePrimKey, groupId, start, end, null);
}
/**
* Returns an ordered range of all the k b articles that the user has permissions to view where resourcePrimKey = ? and 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles that the user has permission to view
*/
@Override
public List filterFindByR_G(long resourcePrimKey, long groupId,
int start, int end, OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByR_G(resourcePrimKey, groupId, start, end,
orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE);
}
else {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_R_G_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_G_GROUPID_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator, true);
}
else {
appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
else {
query.append(KBArticleModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
q.addEntity(_FILTER_ENTITY_ALIAS, KBArticleImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(groupId);
return (List)QueryUtil.list(q, getDialect(), start, end);
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
/**
* Returns the k b articles before and after the current k b article in the ordered set of k b articles that the user has permission to view where resourcePrimKey = ? and groupId = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] filterFindByR_G_PrevAndNext(long kbArticleId,
long resourcePrimKey, long groupId,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByR_G_PrevAndNext(kbArticleId, resourcePrimKey, groupId,
orderByComparator);
}
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = filterGetByR_G_PrevAndNext(session, kbArticle,
resourcePrimKey, groupId, orderByComparator, true);
array[1] = kbArticle;
array[2] = filterGetByR_G_PrevAndNext(session, kbArticle,
resourcePrimKey, groupId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle filterGetByR_G_PrevAndNext(Session session,
KBArticle kbArticle, long resourcePrimKey, long groupId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE);
}
else {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_R_G_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_G_GROUPID_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(_ORDER_BY_ENTITY_ALIAS);
}
else {
query.append(_ORDER_BY_ENTITY_TABLE);
}
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(_ORDER_BY_ENTITY_ALIAS);
}
else {
query.append(_ORDER_BY_ENTITY_TABLE);
}
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
else {
query.append(KBArticleModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
q.addEntity(_FILTER_ENTITY_ALIAS, KBArticleImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(groupId);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the k b articles where resourcePrimKey = ? and groupId = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
*/
@Override
public void removeByR_G(long resourcePrimKey, long groupId) {
for (KBArticle kbArticle : findByR_G(resourcePrimKey, groupId,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where resourcePrimKey = ? and groupId = ?.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @return the number of matching k b articles
*/
@Override
public int countByR_G(long resourcePrimKey, long groupId) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_R_G;
Object[] finderArgs = new Object[] { resourcePrimKey, groupId };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_G_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(groupId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of k b articles that the user has permission to view where resourcePrimKey = ? and groupId = ?.
*
* @param resourcePrimKey the resource prim key
* @param groupId the group ID
* @return the number of matching k b articles that the user has permission to view
*/
@Override
public int filterCountByR_G(long resourcePrimKey, long groupId) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByR_G(resourcePrimKey, groupId);
}
StringBundler query = new StringBundler(3);
query.append(_FILTER_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_G_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_G_GROUPID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.addScalar(COUNT_COLUMN_NAME,
com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(groupId);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_R_G_RESOURCEPRIMKEY_2 = "kbArticle.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_G_GROUPID_2 = "kbArticle.groupId = ?";
public static final FinderPath FINDER_PATH_FETCH_BY_R_V = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_ENTITY, "fetchByR_V",
new String[] { Long.class.getName(), Integer.class.getName() },
KBArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
KBArticleModelImpl.VERSION_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_R_V = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_V",
new String[] { Long.class.getName(), Integer.class.getName() });
/**
* Returns the k b article where resourcePrimKey = ? and version = ? or throws a {@link NoSuchArticleException} if it could not be found.
*
* @param resourcePrimKey the resource prim key
* @param version the version
* @return the matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_V(long resourcePrimKey, int version)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_V(resourcePrimKey, version);
if (kbArticle == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", version=");
msg.append(version);
msg.append(StringPool.CLOSE_CURLY_BRACE);
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchArticleException(msg.toString());
}
return kbArticle;
}
/**
* Returns the k b article where resourcePrimKey = ? and version = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param resourcePrimKey the resource prim key
* @param version the version
* @return the matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_V(long resourcePrimKey, int version) {
return fetchByR_V(resourcePrimKey, version, true);
}
/**
* Returns the k b article where resourcePrimKey = ? and version = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param resourcePrimKey the resource prim key
* @param version the version
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_V(long resourcePrimKey, int version,
boolean retrieveFromCache) {
Object[] finderArgs = new Object[] { resourcePrimKey, version };
Object result = null;
if (retrieveFromCache) {
result = finderCache.getResult(FINDER_PATH_FETCH_BY_R_V,
finderArgs, this);
}
if (result instanceof KBArticle) {
KBArticle kbArticle = (KBArticle)result;
if ((resourcePrimKey != kbArticle.getResourcePrimKey()) ||
(version != kbArticle.getVersion())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_V_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_V_VERSION_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(version);
List list = q.list();
if (list.isEmpty()) {
finderCache.putResult(FINDER_PATH_FETCH_BY_R_V, finderArgs,
list);
}
else {
KBArticle kbArticle = list.get(0);
result = kbArticle;
cacheResult(kbArticle);
if ((kbArticle.getResourcePrimKey() != resourcePrimKey) ||
(kbArticle.getVersion() != version)) {
finderCache.putResult(FINDER_PATH_FETCH_BY_R_V,
finderArgs, kbArticle);
}
}
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_FETCH_BY_R_V, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (KBArticle)result;
}
}
/**
* Removes the k b article where resourcePrimKey = ? and version = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param version the version
* @return the k b article that was removed
*/
@Override
public KBArticle removeByR_V(long resourcePrimKey, int version)
throws NoSuchArticleException {
KBArticle kbArticle = findByR_V(resourcePrimKey, version);
return remove(kbArticle);
}
/**
* Returns the number of k b articles where resourcePrimKey = ? and version = ?.
*
* @param resourcePrimKey the resource prim key
* @param version the version
* @return the number of matching k b articles
*/
@Override
public int countByR_V(long resourcePrimKey, int version) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_R_V;
Object[] finderArgs = new Object[] { resourcePrimKey, version };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_V_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_V_VERSION_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(version);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_R_V_RESOURCEPRIMKEY_2 = "kbArticle.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_V_VERSION_2 = "kbArticle.version = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_L = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_L",
new String[] {
Long.class.getName(), Boolean.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_L = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_L",
new String[] { Long.class.getName(), Boolean.class.getName() },
KBArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
KBArticleModelImpl.LATEST_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_R_L = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_L",
new String[] { Long.class.getName(), Boolean.class.getName() });
public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_L = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_L",
new String[] { Long.class.getName(), Boolean.class.getName() });
/**
* Returns all the k b articles where resourcePrimKey = ? and latest = ?.
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @return the matching k b articles
*/
@Override
public List findByR_L(long resourcePrimKey, boolean latest) {
return findByR_L(resourcePrimKey, latest, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles where resourcePrimKey = ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByR_L(long resourcePrimKey, boolean latest,
int start, int end) {
return findByR_L(resourcePrimKey, latest, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_L(long resourcePrimKey, boolean latest,
int start, int end, OrderByComparator orderByComparator) {
return findByR_L(resourcePrimKey, latest, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_L(long resourcePrimKey, boolean latest,
int start, int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_L;
finderArgs = new Object[] { resourcePrimKey, latest };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_L;
finderArgs = new Object[] {
resourcePrimKey, latest,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if ((resourcePrimKey != kbArticle.getResourcePrimKey()) ||
(latest != kbArticle.getLatest())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_L_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_L_LATEST_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(latest);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ? and latest = ?.
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_L_First(long resourcePrimKey, boolean latest,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_L_First(resourcePrimKey, latest,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", latest=");
msg.append(latest);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ? and latest = ?.
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_L_First(long resourcePrimKey, boolean latest,
OrderByComparator orderByComparator) {
List list = findByR_L(resourcePrimKey, latest, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ? and latest = ?.
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_L_Last(long resourcePrimKey, boolean latest,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_L_Last(resourcePrimKey, latest,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", latest=");
msg.append(latest);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ? and latest = ?.
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_L_Last(long resourcePrimKey, boolean latest,
OrderByComparator orderByComparator) {
int count = countByR_L(resourcePrimKey, latest);
if (count == 0) {
return null;
}
List list = findByR_L(resourcePrimKey, latest, count - 1,
count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the k b articles before and after the current k b article in the ordered set where resourcePrimKey = ? and latest = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByR_L_PrevAndNext(long kbArticleId,
long resourcePrimKey, boolean latest,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByR_L_PrevAndNext(session, kbArticle,
resourcePrimKey, latest, orderByComparator, true);
array[1] = kbArticle;
array[2] = getByR_L_PrevAndNext(session, kbArticle,
resourcePrimKey, latest, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByR_L_PrevAndNext(Session session,
KBArticle kbArticle, long resourcePrimKey, boolean latest,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_L_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_L_LATEST_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(latest);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the k b articles where resourcePrimKey = any ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param latest the latest
* @return the matching k b articles
*/
@Override
public List findByR_L(long[] resourcePrimKeies, boolean latest) {
return findByR_L(resourcePrimKeies, latest, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles where resourcePrimKey = any ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByR_L(long[] resourcePrimKeies, boolean latest,
int start, int end) {
return findByR_L(resourcePrimKeies, latest, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = any ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_L(long[] resourcePrimKeies, boolean latest,
int start, int end, OrderByComparator orderByComparator) {
return findByR_L(resourcePrimKeies, latest, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and latest = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_L(long[] resourcePrimKeies, boolean latest,
int start, int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
if (resourcePrimKeies == null) {
resourcePrimKeies = new long[0];
}
else if (resourcePrimKeies.length > 1) {
resourcePrimKeies = ArrayUtil.unique(resourcePrimKeies);
Arrays.sort(resourcePrimKeies);
}
if (resourcePrimKeies.length == 1) {
return findByR_L(resourcePrimKeies[0], latest, start, end,
orderByComparator);
}
boolean pagination = true;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderArgs = new Object[] {
StringUtil.merge(resourcePrimKeies), latest
};
}
else {
finderArgs = new Object[] {
StringUtil.merge(resourcePrimKeies), latest,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_L,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if (!ArrayUtil.contains(resourcePrimKeies,
kbArticle.getResourcePrimKey()) ||
(latest != kbArticle.getLatest())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = new StringBundler();
query.append(_SQL_SELECT_KBARTICLE_WHERE);
if (resourcePrimKeies.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_R_L_RESOURCEPRIMKEY_7);
query.append(StringUtil.merge(resourcePrimKeies));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_R_L_LATEST_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(latest);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_L,
finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_L,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the k b articles where resourcePrimKey = ? and latest = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
*/
@Override
public void removeByR_L(long resourcePrimKey, boolean latest) {
for (KBArticle kbArticle : findByR_L(resourcePrimKey, latest,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where resourcePrimKey = ? and latest = ?.
*
* @param resourcePrimKey the resource prim key
* @param latest the latest
* @return the number of matching k b articles
*/
@Override
public int countByR_L(long resourcePrimKey, boolean latest) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_R_L;
Object[] finderArgs = new Object[] { resourcePrimKey, latest };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_L_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_L_LATEST_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(latest);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of k b articles where resourcePrimKey = any ? and latest = ?.
*
* @param resourcePrimKeies the resource prim keies
* @param latest the latest
* @return the number of matching k b articles
*/
@Override
public int countByR_L(long[] resourcePrimKeies, boolean latest) {
if (resourcePrimKeies == null) {
resourcePrimKeies = new long[0];
}
else if (resourcePrimKeies.length > 1) {
resourcePrimKeies = ArrayUtil.unique(resourcePrimKeies);
Arrays.sort(resourcePrimKeies);
}
Object[] finderArgs = new Object[] {
StringUtil.merge(resourcePrimKeies), latest
};
Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_L,
finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler();
query.append(_SQL_COUNT_KBARTICLE_WHERE);
if (resourcePrimKeies.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_R_L_RESOURCEPRIMKEY_7);
query.append(StringUtil.merge(resourcePrimKeies));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_R_L_LATEST_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(latest);
count = (Long)q.uniqueResult();
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_L,
finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_L,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_R_L_RESOURCEPRIMKEY_2 = "kbArticle.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_L_RESOURCEPRIMKEY_7 = "kbArticle.resourcePrimKey IN (";
private static final String _FINDER_COLUMN_R_L_LATEST_2 = "kbArticle.latest = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_M = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_M",
new String[] {
Long.class.getName(), Boolean.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_M = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_M",
new String[] { Long.class.getName(), Boolean.class.getName() },
KBArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
KBArticleModelImpl.MAIN_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_R_M = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_M",
new String[] { Long.class.getName(), Boolean.class.getName() });
public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_M = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_M",
new String[] { Long.class.getName(), Boolean.class.getName() });
/**
* Returns all the k b articles where resourcePrimKey = ? and main = ?.
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @return the matching k b articles
*/
@Override
public List findByR_M(long resourcePrimKey, boolean main) {
return findByR_M(resourcePrimKey, main, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles where resourcePrimKey = ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByR_M(long resourcePrimKey, boolean main,
int start, int end) {
return findByR_M(resourcePrimKey, main, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_M(long resourcePrimKey, boolean main,
int start, int end, OrderByComparator orderByComparator) {
return findByR_M(resourcePrimKey, main, start, end, orderByComparator,
true);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_M(long resourcePrimKey, boolean main,
int start, int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_M;
finderArgs = new Object[] { resourcePrimKey, main };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_M;
finderArgs = new Object[] {
resourcePrimKey, main,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if ((resourcePrimKey != kbArticle.getResourcePrimKey()) ||
(main != kbArticle.getMain())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_M_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_M_MAIN_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(main);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ? and main = ?.
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_M_First(long resourcePrimKey, boolean main,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_M_First(resourcePrimKey, main,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", main=");
msg.append(main);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ? and main = ?.
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_M_First(long resourcePrimKey, boolean main,
OrderByComparator orderByComparator) {
List list = findByR_M(resourcePrimKey, main, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ? and main = ?.
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_M_Last(long resourcePrimKey, boolean main,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_M_Last(resourcePrimKey, main,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", main=");
msg.append(main);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ? and main = ?.
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_M_Last(long resourcePrimKey, boolean main,
OrderByComparator orderByComparator) {
int count = countByR_M(resourcePrimKey, main);
if (count == 0) {
return null;
}
List list = findByR_M(resourcePrimKey, main, count - 1,
count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the k b articles before and after the current k b article in the ordered set where resourcePrimKey = ? and main = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param resourcePrimKey the resource prim key
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByR_M_PrevAndNext(long kbArticleId,
long resourcePrimKey, boolean main,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByR_M_PrevAndNext(session, kbArticle,
resourcePrimKey, main, orderByComparator, true);
array[1] = kbArticle;
array[2] = getByR_M_PrevAndNext(session, kbArticle,
resourcePrimKey, main, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByR_M_PrevAndNext(Session session,
KBArticle kbArticle, long resourcePrimKey, boolean main,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_M_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_M_MAIN_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(main);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the k b articles where resourcePrimKey = any ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param main the main
* @return the matching k b articles
*/
@Override
public List findByR_M(long[] resourcePrimKeies, boolean main) {
return findByR_M(resourcePrimKeies, main, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles where resourcePrimKey = any ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByR_M(long[] resourcePrimKeies, boolean main,
int start, int end) {
return findByR_M(resourcePrimKeies, main, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = any ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_M(long[] resourcePrimKeies, boolean main,
int start, int end, OrderByComparator orderByComparator) {
return findByR_M(resourcePrimKeies, main, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and main = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_M(long[] resourcePrimKeies, boolean main,
int start, int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
if (resourcePrimKeies == null) {
resourcePrimKeies = new long[0];
}
else if (resourcePrimKeies.length > 1) {
resourcePrimKeies = ArrayUtil.unique(resourcePrimKeies);
Arrays.sort(resourcePrimKeies);
}
if (resourcePrimKeies.length == 1) {
return findByR_M(resourcePrimKeies[0], main, start, end,
orderByComparator);
}
boolean pagination = true;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderArgs = new Object[] { StringUtil.merge(resourcePrimKeies), main };
}
else {
finderArgs = new Object[] {
StringUtil.merge(resourcePrimKeies), main,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_M,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if (!ArrayUtil.contains(resourcePrimKeies,
kbArticle.getResourcePrimKey()) ||
(main != kbArticle.getMain())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = new StringBundler();
query.append(_SQL_SELECT_KBARTICLE_WHERE);
if (resourcePrimKeies.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_R_M_RESOURCEPRIMKEY_7);
query.append(StringUtil.merge(resourcePrimKeies));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_R_M_MAIN_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(main);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_M,
finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_M,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the k b articles where resourcePrimKey = ? and main = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param main the main
*/
@Override
public void removeByR_M(long resourcePrimKey, boolean main) {
for (KBArticle kbArticle : findByR_M(resourcePrimKey, main,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where resourcePrimKey = ? and main = ?.
*
* @param resourcePrimKey the resource prim key
* @param main the main
* @return the number of matching k b articles
*/
@Override
public int countByR_M(long resourcePrimKey, boolean main) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_R_M;
Object[] finderArgs = new Object[] { resourcePrimKey, main };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_M_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_M_MAIN_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(main);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of k b articles where resourcePrimKey = any ? and main = ?.
*
* @param resourcePrimKeies the resource prim keies
* @param main the main
* @return the number of matching k b articles
*/
@Override
public int countByR_M(long[] resourcePrimKeies, boolean main) {
if (resourcePrimKeies == null) {
resourcePrimKeies = new long[0];
}
else if (resourcePrimKeies.length > 1) {
resourcePrimKeies = ArrayUtil.unique(resourcePrimKeies);
Arrays.sort(resourcePrimKeies);
}
Object[] finderArgs = new Object[] {
StringUtil.merge(resourcePrimKeies), main
};
Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_M,
finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler();
query.append(_SQL_COUNT_KBARTICLE_WHERE);
if (resourcePrimKeies.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_R_M_RESOURCEPRIMKEY_7);
query.append(StringUtil.merge(resourcePrimKeies));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_R_M_MAIN_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(main);
count = (Long)q.uniqueResult();
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_M,
finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_M,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_R_M_RESOURCEPRIMKEY_2 = "kbArticle.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_M_RESOURCEPRIMKEY_7 = "kbArticle.resourcePrimKey IN (";
private static final String _FINDER_COLUMN_R_M_MAIN_2 = "kbArticle.main = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_S",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_S",
new String[] { Long.class.getName(), Integer.class.getName() },
KBArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
KBArticleModelImpl.STATUS_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_R_S = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_S",
new String[] { Long.class.getName(), Integer.class.getName() });
public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_S = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_S",
new String[] { Long.class.getName(), Integer.class.getName() });
/**
* Returns all the k b articles where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @return the matching k b articles
*/
@Override
public List findByR_S(long resourcePrimKey, int status) {
return findByR_S(resourcePrimKey, status, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles where resourcePrimKey = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByR_S(long resourcePrimKey, int status,
int start, int end) {
return findByR_S(resourcePrimKey, status, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_S(long resourcePrimKey, int status,
int start, int end, OrderByComparator orderByComparator) {
return findByR_S(resourcePrimKey, status, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_S(long resourcePrimKey, int status,
int start, int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S;
finderArgs = new Object[] { resourcePrimKey, status };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S;
finderArgs = new Object[] {
resourcePrimKey, status,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if ((resourcePrimKey != kbArticle.getResourcePrimKey()) ||
(status != kbArticle.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(status);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_S_First(long resourcePrimKey, int status,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_S_First(resourcePrimKey, status,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", status=");
msg.append(status);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_S_First(long resourcePrimKey, int status,
OrderByComparator orderByComparator) {
List list = findByR_S(resourcePrimKey, status, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByR_S_Last(long resourcePrimKey, int status,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByR_S_Last(resourcePrimKey, status,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("resourcePrimKey=");
msg.append(resourcePrimKey);
msg.append(", status=");
msg.append(status);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByR_S_Last(long resourcePrimKey, int status,
OrderByComparator orderByComparator) {
int count = countByR_S(resourcePrimKey, status);
if (count == 0) {
return null;
}
List list = findByR_S(resourcePrimKey, status, count - 1,
count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the k b articles before and after the current k b article in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByR_S_PrevAndNext(long kbArticleId,
long resourcePrimKey, int status,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByR_S_PrevAndNext(session, kbArticle,
resourcePrimKey, status, orderByComparator, true);
array[1] = kbArticle;
array[2] = getByR_S_PrevAndNext(session, kbArticle,
resourcePrimKey, status, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByR_S_PrevAndNext(Session session,
KBArticle kbArticle, long resourcePrimKey, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(status);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the k b articles where resourcePrimKey = any ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param status the status
* @return the matching k b articles
*/
@Override
public List findByR_S(long[] resourcePrimKeies, int status) {
return findByR_S(resourcePrimKeies, status, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles where resourcePrimKey = any ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByR_S(long[] resourcePrimKeies, int status,
int start, int end) {
return findByR_S(resourcePrimKeies, status, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = any ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKeies the resource prim keies
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_S(long[] resourcePrimKeies, int status,
int start, int end, OrderByComparator orderByComparator) {
return findByR_S(resourcePrimKeies, status, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where resourcePrimKey = ? and status = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByR_S(long[] resourcePrimKeies, int status,
int start, int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
if (resourcePrimKeies == null) {
resourcePrimKeies = new long[0];
}
else if (resourcePrimKeies.length > 1) {
resourcePrimKeies = ArrayUtil.unique(resourcePrimKeies);
Arrays.sort(resourcePrimKeies);
}
if (resourcePrimKeies.length == 1) {
return findByR_S(resourcePrimKeies[0], status, start, end,
orderByComparator);
}
boolean pagination = true;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderArgs = new Object[] {
StringUtil.merge(resourcePrimKeies), status
};
}
else {
finderArgs = new Object[] {
StringUtil.merge(resourcePrimKeies), status,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if (!ArrayUtil.contains(resourcePrimKeies,
kbArticle.getResourcePrimKey()) ||
(status != kbArticle.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = new StringBundler();
query.append(_SQL_SELECT_KBARTICLE_WHERE);
if (resourcePrimKeies.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_7);
query.append(StringUtil.merge(resourcePrimKeies));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_R_S_STATUS_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(status);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S,
finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the k b articles where resourcePrimKey = ? and status = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param status the status
*/
@Override
public void removeByR_S(long resourcePrimKey, int status) {
for (KBArticle kbArticle : findByR_S(resourcePrimKey, status,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @return the number of matching k b articles
*/
@Override
public int countByR_S(long resourcePrimKey, int status) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_R_S;
Object[] finderArgs = new Object[] { resourcePrimKey, status };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
query.append(_FINDER_COLUMN_R_S_STATUS_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(resourcePrimKey);
qPos.add(status);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of k b articles where resourcePrimKey = any ? and status = ?.
*
* @param resourcePrimKeies the resource prim keies
* @param status the status
* @return the number of matching k b articles
*/
@Override
public int countByR_S(long[] resourcePrimKeies, int status) {
if (resourcePrimKeies == null) {
resourcePrimKeies = new long[0];
}
else if (resourcePrimKeies.length > 1) {
resourcePrimKeies = ArrayUtil.unique(resourcePrimKeies);
Arrays.sort(resourcePrimKeies);
}
Object[] finderArgs = new Object[] {
StringUtil.merge(resourcePrimKeies), status
};
Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_S,
finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler();
query.append(_SQL_COUNT_KBARTICLE_WHERE);
if (resourcePrimKeies.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_7);
query.append(StringUtil.merge(resourcePrimKeies));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_R_S_STATUS_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(status);
count = (Long)q.uniqueResult();
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_S,
finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_S,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2 = "kbArticle.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_S_RESOURCEPRIMKEY_7 = "kbArticle.resourcePrimKey IN (";
private static final String _FINDER_COLUMN_R_S_STATUS_2 = "kbArticle.status = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_L",
new String[] {
Long.class.getName(), Boolean.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
new String[] { Long.class.getName(), Boolean.class.getName() },
KBArticleModelImpl.GROUPID_COLUMN_BITMASK |
KBArticleModelImpl.LATEST_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
new String[] { Long.class.getName(), Boolean.class.getName() });
/**
* Returns all the k b articles where groupId = ? and latest = ?.
*
* @param groupId the group ID
* @param latest the latest
* @return the matching k b articles
*/
@Override
public List findByG_L(long groupId, boolean latest) {
return findByG_L(groupId, latest, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the k b articles where groupId = ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByG_L(long groupId, boolean latest, int start,
int end) {
return findByG_L(groupId, latest, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where groupId = ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByG_L(long groupId, boolean latest, int start,
int end, OrderByComparator orderByComparator) {
return findByG_L(groupId, latest, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where groupId = ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByG_L(long groupId, boolean latest, int start,
int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
finderArgs = new Object[] { groupId, latest };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
finderArgs = new Object[] {
groupId, latest,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if ((groupId != kbArticle.getGroupId()) ||
(latest != kbArticle.getLatest())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_L_GROUPID_2);
query.append(_FINDER_COLUMN_G_L_LATEST_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(latest);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article in the ordered set where groupId = ? and latest = ?.
*
* @param groupId the group ID
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByG_L_First(long groupId, boolean latest,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByG_L_First(groupId, latest,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", latest=");
msg.append(latest);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article in the ordered set where groupId = ? and latest = ?.
*
* @param groupId the group ID
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByG_L_First(long groupId, boolean latest,
OrderByComparator orderByComparator) {
List list = findByG_L(groupId, latest, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last k b article in the ordered set where groupId = ? and latest = ?.
*
* @param groupId the group ID
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByG_L_Last(long groupId, boolean latest,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByG_L_Last(groupId, latest, orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", latest=");
msg.append(latest);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article in the ordered set where groupId = ? and latest = ?.
*
* @param groupId the group ID
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByG_L_Last(long groupId, boolean latest,
OrderByComparator orderByComparator) {
int count = countByG_L(groupId, latest);
if (count == 0) {
return null;
}
List list = findByG_L(groupId, latest, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the k b articles before and after the current k b article in the ordered set where groupId = ? and latest = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param groupId the group ID
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByG_L_PrevAndNext(long kbArticleId, long groupId,
boolean latest, OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByG_L_PrevAndNext(session, kbArticle, groupId,
latest, orderByComparator, true);
array[1] = kbArticle;
array[2] = getByG_L_PrevAndNext(session, kbArticle, groupId,
latest, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByG_L_PrevAndNext(Session session,
KBArticle kbArticle, long groupId, boolean latest,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_L_GROUPID_2);
query.append(_FINDER_COLUMN_G_L_LATEST_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(latest);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the k b articles that the user has permission to view where groupId = ? and latest = ?.
*
* @param groupId the group ID
* @param latest the latest
* @return the matching k b articles that the user has permission to view
*/
@Override
public List filterFindByG_L(long groupId, boolean latest) {
return filterFindByG_L(groupId, latest, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles that the user has permission to view where groupId = ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles that the user has permission to view
*/
@Override
public List filterFindByG_L(long groupId, boolean latest,
int start, int end) {
return filterFindByG_L(groupId, latest, start, end, null);
}
/**
* Returns an ordered range of all the k b articles that the user has permissions to view where groupId = ? and latest = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param latest the latest
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles that the user has permission to view
*/
@Override
public List filterFindByG_L(long groupId, boolean latest,
int start, int end, OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_L(groupId, latest, start, end, orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE);
}
else {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_L_GROUPID_2);
query.append(_FINDER_COLUMN_G_L_LATEST_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator, true);
}
else {
appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
else {
query.append(KBArticleModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
q.addEntity(_FILTER_ENTITY_ALIAS, KBArticleImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(latest);
return (List)QueryUtil.list(q, getDialect(), start, end);
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
/**
* Returns the k b articles before and after the current k b article in the ordered set of k b articles that the user has permission to view where groupId = ? and latest = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param groupId the group ID
* @param latest the latest
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] filterFindByG_L_PrevAndNext(long kbArticleId,
long groupId, boolean latest,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_L_PrevAndNext(kbArticleId, groupId, latest,
orderByComparator);
}
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = filterGetByG_L_PrevAndNext(session, kbArticle, groupId,
latest, orderByComparator, true);
array[1] = kbArticle;
array[2] = filterGetByG_L_PrevAndNext(session, kbArticle, groupId,
latest, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle filterGetByG_L_PrevAndNext(Session session,
KBArticle kbArticle, long groupId, boolean latest,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE);
}
else {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_L_GROUPID_2);
query.append(_FINDER_COLUMN_G_L_LATEST_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(_ORDER_BY_ENTITY_ALIAS);
}
else {
query.append(_ORDER_BY_ENTITY_TABLE);
}
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(_ORDER_BY_ENTITY_ALIAS);
}
else {
query.append(_ORDER_BY_ENTITY_TABLE);
}
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
else {
query.append(KBArticleModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
q.addEntity(_FILTER_ENTITY_ALIAS, KBArticleImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(latest);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the k b articles where groupId = ? and latest = ? from the database.
*
* @param groupId the group ID
* @param latest the latest
*/
@Override
public void removeByG_L(long groupId, boolean latest) {
for (KBArticle kbArticle : findByG_L(groupId, latest,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where groupId = ? and latest = ?.
*
* @param groupId the group ID
* @param latest the latest
* @return the number of matching k b articles
*/
@Override
public int countByG_L(long groupId, boolean latest) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
Object[] finderArgs = new Object[] { groupId, latest };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_L_GROUPID_2);
query.append(_FINDER_COLUMN_G_L_LATEST_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(latest);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of k b articles that the user has permission to view where groupId = ? and latest = ?.
*
* @param groupId the group ID
* @param latest the latest
* @return the number of matching k b articles that the user has permission to view
*/
@Override
public int filterCountByG_L(long groupId, boolean latest) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_L(groupId, latest);
}
StringBundler query = new StringBundler(3);
query.append(_FILTER_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_L_GROUPID_2);
query.append(_FINDER_COLUMN_G_L_LATEST_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.addScalar(COUNT_COLUMN_NAME,
com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(latest);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "kbArticle.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_L_LATEST_2 = "kbArticle.latest = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_M",
new String[] {
Long.class.getName(), Boolean.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_M",
new String[] { Long.class.getName(), Boolean.class.getName() },
KBArticleModelImpl.GROUPID_COLUMN_BITMASK |
KBArticleModelImpl.MAIN_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_G_M = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_M",
new String[] { Long.class.getName(), Boolean.class.getName() });
/**
* Returns all the k b articles where groupId = ? and main = ?.
*
* @param groupId the group ID
* @param main the main
* @return the matching k b articles
*/
@Override
public List findByG_M(long groupId, boolean main) {
return findByG_M(groupId, main, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the k b articles where groupId = ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByG_M(long groupId, boolean main, int start,
int end) {
return findByG_M(groupId, main, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where groupId = ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByG_M(long groupId, boolean main, int start,
int end, OrderByComparator orderByComparator) {
return findByG_M(groupId, main, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where groupId = ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByG_M(long groupId, boolean main, int start,
int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M;
finderArgs = new Object[] { groupId, main };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M;
finderArgs = new Object[] {
groupId, main,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if ((groupId != kbArticle.getGroupId()) ||
(main != kbArticle.getMain())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_M_GROUPID_2);
query.append(_FINDER_COLUMN_G_M_MAIN_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(main);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article in the ordered set where groupId = ? and main = ?.
*
* @param groupId the group ID
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByG_M_First(long groupId, boolean main,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByG_M_First(groupId, main, orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", main=");
msg.append(main);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article in the ordered set where groupId = ? and main = ?.
*
* @param groupId the group ID
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByG_M_First(long groupId, boolean main,
OrderByComparator orderByComparator) {
List list = findByG_M(groupId, main, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last k b article in the ordered set where groupId = ? and main = ?.
*
* @param groupId the group ID
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByG_M_Last(long groupId, boolean main,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByG_M_Last(groupId, main, orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", main=");
msg.append(main);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article in the ordered set where groupId = ? and main = ?.
*
* @param groupId the group ID
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByG_M_Last(long groupId, boolean main,
OrderByComparator orderByComparator) {
int count = countByG_M(groupId, main);
if (count == 0) {
return null;
}
List list = findByG_M(groupId, main, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the k b articles before and after the current k b article in the ordered set where groupId = ? and main = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param groupId the group ID
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByG_M_PrevAndNext(long kbArticleId, long groupId,
boolean main, OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByG_M_PrevAndNext(session, kbArticle, groupId, main,
orderByComparator, true);
array[1] = kbArticle;
array[2] = getByG_M_PrevAndNext(session, kbArticle, groupId, main,
orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByG_M_PrevAndNext(Session session,
KBArticle kbArticle, long groupId, boolean main,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_M_GROUPID_2);
query.append(_FINDER_COLUMN_G_M_MAIN_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(main);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the k b articles that the user has permission to view where groupId = ? and main = ?.
*
* @param groupId the group ID
* @param main the main
* @return the matching k b articles that the user has permission to view
*/
@Override
public List filterFindByG_M(long groupId, boolean main) {
return filterFindByG_M(groupId, main, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles that the user has permission to view where groupId = ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles that the user has permission to view
*/
@Override
public List filterFindByG_M(long groupId, boolean main,
int start, int end) {
return filterFindByG_M(groupId, main, start, end, null);
}
/**
* Returns an ordered range of all the k b articles that the user has permissions to view where groupId = ? and main = ?.
*
*
* 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param main the main
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles that the user has permission to view
*/
@Override
public List filterFindByG_M(long groupId, boolean main,
int start, int end, OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_M(groupId, main, start, end, orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE);
}
else {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_M_GROUPID_2);
query.append(_FINDER_COLUMN_G_M_MAIN_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator, true);
}
else {
appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
else {
query.append(KBArticleModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
q.addEntity(_FILTER_ENTITY_ALIAS, KBArticleImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(main);
return (List)QueryUtil.list(q, getDialect(), start, end);
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
/**
* Returns the k b articles before and after the current k b article in the ordered set of k b articles that the user has permission to view where groupId = ? and main = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param groupId the group ID
* @param main the main
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] filterFindByG_M_PrevAndNext(long kbArticleId,
long groupId, boolean main,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_M_PrevAndNext(kbArticleId, groupId, main,
orderByComparator);
}
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = filterGetByG_M_PrevAndNext(session, kbArticle, groupId,
main, orderByComparator, true);
array[1] = kbArticle;
array[2] = filterGetByG_M_PrevAndNext(session, kbArticle, groupId,
main, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle filterGetByG_M_PrevAndNext(Session session,
KBArticle kbArticle, long groupId, boolean main,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE);
}
else {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_M_GROUPID_2);
query.append(_FINDER_COLUMN_G_M_MAIN_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(_ORDER_BY_ENTITY_ALIAS);
}
else {
query.append(_ORDER_BY_ENTITY_TABLE);
}
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(_ORDER_BY_ENTITY_ALIAS);
}
else {
query.append(_ORDER_BY_ENTITY_TABLE);
}
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
else {
query.append(KBArticleModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
q.addEntity(_FILTER_ENTITY_ALIAS, KBArticleImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(main);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the k b articles where groupId = ? and main = ? from the database.
*
* @param groupId the group ID
* @param main the main
*/
@Override
public void removeByG_M(long groupId, boolean main) {
for (KBArticle kbArticle : findByG_M(groupId, main, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(kbArticle);
}
}
/**
* Returns the number of k b articles where groupId = ? and main = ?.
*
* @param groupId the group ID
* @param main the main
* @return the number of matching k b articles
*/
@Override
public int countByG_M(long groupId, boolean main) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_G_M;
Object[] finderArgs = new Object[] { groupId, main };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_M_GROUPID_2);
query.append(_FINDER_COLUMN_G_M_MAIN_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(main);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of k b articles that the user has permission to view where groupId = ? and main = ?.
*
* @param groupId the group ID
* @param main the main
* @return the number of matching k b articles that the user has permission to view
*/
@Override
public int filterCountByG_M(long groupId, boolean main) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_M(groupId, main);
}
StringBundler query = new StringBundler(3);
query.append(_FILTER_SQL_COUNT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_M_GROUPID_2);
query.append(_FINDER_COLUMN_G_M_MAIN_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
KBArticle.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.addScalar(COUNT_COLUMN_NAME,
com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(main);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_M_GROUPID_2 = "kbArticle.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_M_MAIN_2 = "kbArticle.main = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, KBArticleImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
new String[] { Long.class.getName(), Integer.class.getName() },
KBArticleModelImpl.GROUPID_COLUMN_BITMASK |
KBArticleModelImpl.STATUS_COLUMN_BITMASK |
KBArticleModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(KBArticleModelImpl.ENTITY_CACHE_ENABLED,
KBArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
new String[] { Long.class.getName(), Integer.class.getName() });
/**
* Returns all the k b articles where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching k b articles
*/
@Override
public List findByG_S(long groupId, int status) {
return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the k b articles where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles
*/
@Override
public List findByG_S(long groupId, int status, int start,
int end) {
return findByG_S(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the k b articles where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching k b articles
*/
@Override
public List findByG_S(long groupId, int status, int start,
int end, OrderByComparator orderByComparator) {
return findByG_S(groupId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the k b articles where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching k b articles
*/
@Override
public List findByG_S(long groupId, int status, int start,
int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
finderArgs = new Object[] { groupId, status };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
finderArgs = new Object[] {
groupId, status,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (KBArticle kbArticle : list) {
if ((groupId != kbArticle.getGroupId()) ||
(status != kbArticle.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_S_GROUPID_2);
query.append(_FINDER_COLUMN_G_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
if (!pagination) {
list = (List)QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first k b article in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByG_S_First(long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByG_S_First(groupId, status,
orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", status=");
msg.append(status);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the first k b article in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByG_S_First(long groupId, int status,
OrderByComparator orderByComparator) {
List list = findByG_S(groupId, status, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last k b article in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article
* @throws NoSuchArticleException if a matching k b article could not be found
*/
@Override
public KBArticle findByG_S_Last(long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = fetchByG_S_Last(groupId, status, orderByComparator);
if (kbArticle != null) {
return kbArticle;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", status=");
msg.append(status);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchArticleException(msg.toString());
}
/**
* Returns the last k b article in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching k b article, or null
if a matching k b article could not be found
*/
@Override
public KBArticle fetchByG_S_Last(long groupId, int status,
OrderByComparator orderByComparator) {
int count = countByG_S(groupId, status);
if (count == 0) {
return null;
}
List list = findByG_S(groupId, status, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the k b articles before and after the current k b article in the ordered set where groupId = ? and status = ?.
*
* @param kbArticleId the primary key of the current k b article
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next k b article
* @throws NoSuchArticleException if a k b article with the primary key could not be found
*/
@Override
public KBArticle[] findByG_S_PrevAndNext(long kbArticleId, long groupId,
int status, OrderByComparator orderByComparator)
throws NoSuchArticleException {
KBArticle kbArticle = findByPrimaryKey(kbArticleId);
Session session = null;
try {
session = openSession();
KBArticle[] array = new KBArticleImpl[3];
array[0] = getByG_S_PrevAndNext(session, kbArticle, groupId,
status, orderByComparator, true);
array[1] = kbArticle;
array[2] = getByG_S_PrevAndNext(session, kbArticle, groupId,
status, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected KBArticle getByG_S_PrevAndNext(Session session,
KBArticle kbArticle, long groupId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_KBARTICLE_WHERE);
query.append(_FINDER_COLUMN_G_S_GROUPID_2);
query.append(_FINDER_COLUMN_G_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(KBArticleModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(kbArticle);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the k b articles that the user has permission to view where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching k b articles that the user has permission to view
*/
@Override
public List filterFindByG_S(long groupId, int status) {
return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the k b articles that the user has permission to view where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link KBArticleModelImpl}. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of k b articles
* @param end the upper bound of the range of k b articles (not inclusive)
* @return the range of matching k b articles that the user has permission to view
*/
@Override
public List filterFindByG_S(long groupId, int status, int start,
int end) {
return filterFindByG_S(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the k b articles that the user has permissions to view where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of