com.liferay.blogs.service.persistence.impl.BlogsEntryPersistenceImpl 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.blogs.service.persistence.impl;
import com.liferay.blogs.exception.NoSuchEntryException;
import com.liferay.blogs.model.BlogsEntry;
import com.liferay.blogs.model.impl.BlogsEntryImpl;
import com.liferay.blogs.model.impl.BlogsEntryModelImpl;
import com.liferay.blogs.service.persistence.BlogsEntryPersistence;
import com.liferay.blogs.service.persistence.impl.constants.BlogsPersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.sanitizer.Sanitizer;
import com.liferay.portal.kernel.sanitizer.SanitizerException;
import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.sql.Timestamp;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.sql.DataSource;
import org.osgi.annotation.versioning.ProviderType;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* The persistence implementation for the blogs entry service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
@Component(service = BlogsEntryPersistence.class)
@ProviderType
public class BlogsEntryPersistenceImpl
extends BasePersistenceImpl implements BlogsEntryPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use BlogsEntryUtil
to access the blogs entry persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
BlogsEntryImpl.class.getName();
public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List1";
public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List2";
private FinderPath _finderPathWithPaginationFindAll;
private FinderPath _finderPathWithoutPaginationFindAll;
private FinderPath _finderPathCountAll;
private FinderPath _finderPathWithPaginationFindByUuid;
private FinderPath _finderPathWithoutPaginationFindByUuid;
private FinderPath _finderPathCountByUuid;
/**
* Returns all the blogs entries where uuid = ?.
*
* @param uuid the uuid
* @return the matching blogs entries
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@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 blogs entries where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
uuid = Objects.toString(uuid, "");
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] {uuid};
}
else {
finderPath = _finderPathWithPaginationFindByUuid;
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 (BlogsEntry blogsEntry : list) {
if (!uuid.equals(blogsEntry.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_BLOGSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.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 blogs entry 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 blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry 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 blogs entry 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 blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry 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 blogs entries before and after the current blogs entry in the ordered set where uuid = ?.
*
* @param entryId the primary key of the current blogs entry
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByUuid_PrevAndNext(
long entryId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
uuid = Objects.toString(uuid, "");
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByUuid_PrevAndNext(
session, blogsEntry, uuid, orderByComparator, true);
array[1] = blogsEntry;
array[2] = getByUuid_PrevAndNext(
session, blogsEntry, uuid, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByUuid_PrevAndNext(
Session session, BlogsEntry blogsEntry, 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_BLOGSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (BlogsEntry blogsEntry :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching blogs entries
*/
@Override
public int countByUuid(String uuid) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid;
Object[] finderArgs = new Object[] {uuid};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"blogsEntry.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
private FinderPath _finderPathFetchByUUID_G;
private FinderPath _finderPathCountByUUID_G;
/**
* Returns the blogs entry where uuid = ? and groupId = ? or throws a NoSuchEntryException
if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByUUID_G(String uuid, long groupId)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
if (blogsEntry == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchEntryException(msg.toString());
}
return blogsEntry;
}
/**
* Returns the blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
}
/**
* Returns the blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByUUID_G(
String uuid, long groupId, boolean retrieveFromCache) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = new Object[] {uuid, groupId};
Object result = null;
if (retrieveFromCache) {
result = finderCache.getResult(
_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof BlogsEntry) {
BlogsEntry blogsEntry = (BlogsEntry)result;
if (!Objects.equals(uuid, blogsEntry.getUuid()) ||
(groupId != blogsEntry.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
List list = q.list();
if (list.isEmpty()) {
finderCache.putResult(
_finderPathFetchByUUID_G, finderArgs, list);
}
else {
BlogsEntry blogsEntry = list.get(0);
result = blogsEntry;
cacheResult(blogsEntry);
}
}
catch (Exception e) {
finderCache.removeResult(_finderPathFetchByUUID_G, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (BlogsEntry)result;
}
}
/**
* Removes the blogs entry where uuid = ? and groupId = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the blogs entry that was removed
*/
@Override
public BlogsEntry removeByUUID_G(String uuid, long groupId)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
return remove(blogsEntry);
}
/**
* Returns the number of blogs entries where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching blogs entries
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUUID_G;
Object[] finderArgs = new Object[] {uuid, groupId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_G_UUID_2 =
"blogsEntry.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_3 =
"(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 =
"blogsEntry.groupId = ?";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the blogs entries where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching blogs entries
*/
@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 blogs entries where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@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 blogs entries where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@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 blogs entries where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
uuid = Objects.toString(uuid, "");
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] {uuid, companyId};
}
else {
finderPath = _finderPathWithPaginationFindByUuid_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 (BlogsEntry blogsEntry : list) {
if (!uuid.equals(blogsEntry.getUuid()) ||
(companyId != blogsEntry.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_BLOGSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.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 blogs entry 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 blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", companyId=");
msg.append(companyId);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry 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 blogs entry 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 blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", companyId=");
msg.append(companyId);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry 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 blogs entries before and after the current blogs entry in the ordered set where uuid = ? and companyId = ?.
*
* @param entryId the primary key of the current blogs entry
* @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 blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByUuid_C_PrevAndNext(
long entryId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
uuid = Objects.toString(uuid, "");
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, blogsEntry, uuid, companyId, orderByComparator, true);
array[1] = blogsEntry;
array[2] = getByUuid_C_PrevAndNext(
session, blogsEntry, uuid, companyId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByUuid_C_PrevAndNext(
Session session, BlogsEntry blogsEntry, 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_BLOGSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries 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 (BlogsEntry blogsEntry :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching blogs entries
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid_C;
Object[] finderArgs = new Object[] {uuid, companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"blogsEntry.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"blogsEntry.companyId = ?";
private FinderPath _finderPathWithPaginationFindByGroupId;
private FinderPath _finderPathWithoutPaginationFindByGroupId;
private FinderPath _finderPathCountByGroupId;
/**
* Returns all the blogs entries where groupId = ?.
*
* @param groupId the group ID
* @return the matching blogs entries
*/
@Override
public List findByGroupId(long groupId) {
return findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByGroupId(long groupId, int start, int end) {
return findByGroupId(groupId, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator) {
return findByGroupId(groupId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByGroupId(
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 = _finderPathWithoutPaginationFindByGroupId;
finderArgs = new Object[] {groupId};
}
else {
finderPath = _finderPathWithPaginationFindByGroupId;
finderArgs = new Object[] {groupId, start, end, orderByComparator};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BlogsEntry blogsEntry : list) {
if ((groupId != blogsEntry.getGroupId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first blogs entry in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByGroupId_First(
long groupId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByGroupId_First(
groupId, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByGroupId_First(
long groupId, OrderByComparator orderByComparator) {
List list = findByGroupId(groupId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last blogs entry in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByGroupId_Last(
long groupId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByGroupId_Last(
long groupId, OrderByComparator orderByComparator) {
int count = countByGroupId(groupId);
if (count == 0) {
return null;
}
List list = findByGroupId(
groupId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = ?.
*
* @param entryId the primary key of the current blogs entry
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByGroupId_PrevAndNext(
long entryId, long groupId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByGroupId_PrevAndNext(
session, blogsEntry, groupId, orderByComparator, true);
array[1] = blogsEntry;
array[2] = getByGroupId_PrevAndNext(
session, blogsEntry, groupId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByGroupId_PrevAndNext(
Session session, BlogsEntry blogsEntry, long groupId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the blogs entries that the user has permission to view where groupId = ?.
*
* @param groupId the group ID
* @return the matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByGroupId(long groupId) {
return filterFindByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries that the user has permission to view where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByGroupId(
long groupId, int start, int end) {
return filterFindByGroupId(groupId, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByGroupId(groupId, start, end, orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
}
else {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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, BlogsEntryImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
return (List)QueryUtil.list(
q, getDialect(), start, end);
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = ?.
*
* @param entryId the primary key of the current blogs entry
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] filterFindByGroupId_PrevAndNext(
long entryId, long groupId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByGroupId_PrevAndNext(
entryId, groupId, orderByComparator);
}
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = filterGetByGroupId_PrevAndNext(
session, blogsEntry, groupId, orderByComparator, true);
array[1] = blogsEntry;
array[2] = filterGetByGroupId_PrevAndNext(
session, blogsEntry, groupId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry filterGetByGroupId_PrevAndNext(
Session session, BlogsEntry blogsEntry, long groupId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
}
else {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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, BlogsEntryImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where groupId = ? from the database.
*
* @param groupId the group ID
*/
@Override
public void removeByGroupId(long groupId) {
for (BlogsEntry blogsEntry :
findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where groupId = ?.
*
* @param groupId the group ID
* @return the number of matching blogs entries
*/
@Override
public int countByGroupId(long groupId) {
FinderPath finderPath = _finderPathCountByGroupId;
Object[] finderArgs = new Object[] {groupId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of blogs entries that the user has permission to view where groupId = ?.
*
* @param groupId the group ID
* @return the number of matching blogs entries that the user has permission to view
*/
@Override
public int filterCountByGroupId(long groupId) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByGroupId(groupId);
}
StringBundler query = new StringBundler(2);
query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 =
"blogsEntry.groupId = ?";
private FinderPath _finderPathWithPaginationFindByCompanyId;
private FinderPath _finderPathWithoutPaginationFindByCompanyId;
private FinderPath _finderPathCountByCompanyId;
/**
* Returns all the blogs entries where companyId = ?.
*
* @param companyId the company ID
* @return the matching blogs entries
*/
@Override
public List findByCompanyId(long companyId) {
return findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByCompanyId(
long companyId, int start, int end) {
return findByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByCompanyId(companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByCompanyId(
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 = _finderPathWithoutPaginationFindByCompanyId;
finderArgs = new Object[] {companyId};
}
else {
finderPath = _finderPathWithPaginationFindByCompanyId;
finderArgs = new Object[] {
companyId, start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BlogsEntry blogsEntry : list) {
if ((companyId != blogsEntry.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
if (!pagination) {
list = (List)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 blogs entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByCompanyId_First(
long companyId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByCompanyId_First(
companyId, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByCompanyId_First(
long companyId, OrderByComparator orderByComparator) {
List list = findByCompanyId(
companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last blogs entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByCompanyId_Last(
long companyId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByCompanyId_Last(
companyId, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByCompanyId_Last(
long companyId, OrderByComparator orderByComparator) {
int count = countByCompanyId(companyId);
if (count == 0) {
return null;
}
List list = findByCompanyId(
companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = ?.
*
* @param entryId the primary key of the current blogs entry
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByCompanyId_PrevAndNext(
long entryId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByCompanyId_PrevAndNext(
session, blogsEntry, companyId, orderByComparator, true);
array[1] = blogsEntry;
array[2] = getByCompanyId_PrevAndNext(
session, blogsEntry, companyId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByCompanyId_PrevAndNext(
Session session, BlogsEntry blogsEntry, long companyId,
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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where companyId = ? from the database.
*
* @param companyId the company ID
*/
@Override
public void removeByCompanyId(long companyId) {
for (BlogsEntry blogsEntry :
findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching blogs entries
*/
@Override
public int countByCompanyId(long companyId) {
FinderPath finderPath = _finderPathCountByCompanyId;
Object[] finderArgs = new Object[] {companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 =
"blogsEntry.companyId = ?";
private FinderPath _finderPathFetchByG_UT;
private FinderPath _finderPathCountByG_UT;
/**
* Returns the blogs entry where groupId = ? and urlTitle = ? or throws a NoSuchEntryException
if it could not be found.
*
* @param groupId the group ID
* @param urlTitle the url title
* @return the matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByG_UT(long groupId, String urlTitle)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
if (blogsEntry == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", urlTitle=");
msg.append(urlTitle);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchEntryException(msg.toString());
}
return blogsEntry;
}
/**
* Returns the blogs entry where groupId = ? and urlTitle = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param groupId the group ID
* @param urlTitle the url title
* @return the matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
return fetchByG_UT(groupId, urlTitle, true);
}
/**
* Returns the blogs entry where groupId = ? and urlTitle = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param groupId the group ID
* @param urlTitle the url title
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByG_UT(
long groupId, String urlTitle, boolean retrieveFromCache) {
urlTitle = Objects.toString(urlTitle, "");
Object[] finderArgs = new Object[] {groupId, urlTitle};
Object result = null;
if (retrieveFromCache) {
result = finderCache.getResult(
_finderPathFetchByG_UT, finderArgs, this);
}
if (result instanceof BlogsEntry) {
BlogsEntry blogsEntry = (BlogsEntry)result;
if ((groupId != blogsEntry.getGroupId()) ||
!Objects.equals(urlTitle, blogsEntry.getUrlTitle())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
boolean bindUrlTitle = false;
if (urlTitle.isEmpty()) {
query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
}
else {
bindUrlTitle = true;
query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindUrlTitle) {
qPos.add(urlTitle);
}
List list = q.list();
if (list.isEmpty()) {
finderCache.putResult(
_finderPathFetchByG_UT, finderArgs, list);
}
else {
BlogsEntry blogsEntry = list.get(0);
result = blogsEntry;
cacheResult(blogsEntry);
}
}
catch (Exception e) {
finderCache.removeResult(_finderPathFetchByG_UT, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (BlogsEntry)result;
}
}
/**
* Removes the blogs entry where groupId = ? and urlTitle = ? from the database.
*
* @param groupId the group ID
* @param urlTitle the url title
* @return the blogs entry that was removed
*/
@Override
public BlogsEntry removeByG_UT(long groupId, String urlTitle)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
return remove(blogsEntry);
}
/**
* Returns the number of blogs entries where groupId = ? and urlTitle = ?.
*
* @param groupId the group ID
* @param urlTitle the url title
* @return the number of matching blogs entries
*/
@Override
public int countByG_UT(long groupId, String urlTitle) {
urlTitle = Objects.toString(urlTitle, "");
FinderPath finderPath = _finderPathCountByG_UT;
Object[] finderArgs = new Object[] {groupId, urlTitle};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
boolean bindUrlTitle = false;
if (urlTitle.isEmpty()) {
query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
}
else {
bindUrlTitle = true;
query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindUrlTitle) {
qPos.add(urlTitle);
}
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_G_UT_GROUPID_2 =
"blogsEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 =
"blogsEntry.urlTitle = ?";
private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 =
"(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
private FinderPath _finderPathWithPaginationFindByG_LtD;
private FinderPath _finderPathWithPaginationCountByG_LtD;
/**
* Returns all the blogs entries where groupId = ? and displayDate < ?.
*
* @param groupId the group ID
* @param displayDate the display date
* @return the matching blogs entries
*/
@Override
public List findByG_LtD(long groupId, Date displayDate) {
return findByG_LtD(
groupId, displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where groupId = ? and displayDate < ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 displayDate the display date
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByG_LtD(
long groupId, Date displayDate, int start, int end) {
return findByG_LtD(groupId, displayDate, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where groupId = ? and displayDate < ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 displayDate the display date
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByG_LtD(
long groupId, Date displayDate, int start, int end,
OrderByComparator orderByComparator) {
return findByG_LtD(
groupId, displayDate, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where groupId = ? and displayDate < ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 displayDate the display date
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByG_LtD(
long groupId, Date displayDate, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByG_LtD;
finderArgs = new Object[] {
groupId, _getTime(displayDate), start, end, orderByComparator
};
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BlogsEntry blogsEntry : list) {
if ((groupId != blogsEntry.getGroupId()) ||
(displayDate.getTime() <=
blogsEntry.getDisplayDate().getTime())) {
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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first blogs entry in the ordered set where groupId = ? and displayDate < ?.
*
* @param groupId the group ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByG_LtD_First(
long groupId, Date displayDate,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByG_LtD_First(
groupId, displayDate, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", displayDate=");
msg.append(displayDate);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry in the ordered set where groupId = ? and displayDate < ?.
*
* @param groupId the group ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByG_LtD_First(
long groupId, Date displayDate,
OrderByComparator orderByComparator) {
List list = findByG_LtD(
groupId, displayDate, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last blogs entry in the ordered set where groupId = ? and displayDate < ?.
*
* @param groupId the group ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByG_LtD_Last(
long groupId, Date displayDate,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByG_LtD_Last(
groupId, displayDate, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", displayDate=");
msg.append(displayDate);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry in the ordered set where groupId = ? and displayDate < ?.
*
* @param groupId the group ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByG_LtD_Last(
long groupId, Date displayDate,
OrderByComparator orderByComparator) {
int count = countByG_LtD(groupId, displayDate);
if (count == 0) {
return null;
}
List list = findByG_LtD(
groupId, displayDate, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = ? and displayDate < ?.
*
* @param entryId the primary key of the current blogs entry
* @param groupId the group ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByG_LtD_PrevAndNext(
long entryId, long groupId, Date displayDate,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByG_LtD_PrevAndNext(
session, blogsEntry, groupId, displayDate, orderByComparator,
true);
array[1] = blogsEntry;
array[2] = getByG_LtD_PrevAndNext(
session, blogsEntry, groupId, displayDate, orderByComparator,
false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByG_LtD_PrevAndNext(
Session session, BlogsEntry blogsEntry, long groupId, Date displayDate,
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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the blogs entries that the user has permission to view where groupId = ? and displayDate < ?.
*
* @param groupId the group ID
* @param displayDate the display date
* @return the matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByG_LtD(long groupId, Date displayDate) {
return filterFindByG_LtD(
groupId, displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries that the user has permission to view where groupId = ? and displayDate < ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 displayDate the display date
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByG_LtD(
long groupId, Date displayDate, int start, int end) {
return filterFindByG_LtD(groupId, displayDate, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = ? and displayDate < ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 displayDate the display date
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByG_LtD(
long groupId, Date displayDate, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_LtD(
groupId, displayDate, 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_BLOGSENTRY_WHERE);
}
else {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
}
if (!getDB().isSupportsInlineDistinct()) {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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, BlogsEntryImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
return (List)QueryUtil.list(
q, getDialect(), start, end);
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = ? and displayDate < ?.
*
* @param entryId the primary key of the current blogs entry
* @param groupId the group ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] filterFindByG_LtD_PrevAndNext(
long entryId, long groupId, Date displayDate,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_LtD_PrevAndNext(
entryId, groupId, displayDate, orderByComparator);
}
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = filterGetByG_LtD_PrevAndNext(
session, blogsEntry, groupId, displayDate, orderByComparator,
true);
array[1] = blogsEntry;
array[2] = filterGetByG_LtD_PrevAndNext(
session, blogsEntry, groupId, displayDate, orderByComparator,
false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry filterGetByG_LtD_PrevAndNext(
Session session, BlogsEntry blogsEntry, long groupId, Date displayDate,
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_BLOGSENTRY_WHERE);
}
else {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
}
if (!getDB().isSupportsInlineDistinct()) {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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, BlogsEntryImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where groupId = ? and displayDate < ? from the database.
*
* @param groupId the group ID
* @param displayDate the display date
*/
@Override
public void removeByG_LtD(long groupId, Date displayDate) {
for (BlogsEntry blogsEntry :
findByG_LtD(
groupId, displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where groupId = ? and displayDate < ?.
*
* @param groupId the group ID
* @param displayDate the display date
* @return the number of matching blogs entries
*/
@Override
public int countByG_LtD(long groupId, Date displayDate) {
FinderPath finderPath = _finderPathWithPaginationCountByG_LtD;
Object[] finderArgs = new Object[] {groupId, _getTime(displayDate)};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of blogs entries that the user has permission to view where groupId = ? and displayDate < ?.
*
* @param groupId the group ID
* @param displayDate the display date
* @return the number of matching blogs entries that the user has permission to view
*/
@Override
public int filterCountByG_LtD(long groupId, Date displayDate) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_LtD(groupId, displayDate);
}
StringBundler query = new StringBundler(3);
query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 =
"blogsEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 =
"blogsEntry.displayDate IS NULL";
private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 =
"blogsEntry.displayDate < ?";
private FinderPath _finderPathWithPaginationFindByG_S;
private FinderPath _finderPathWithoutPaginationFindByG_S;
private FinderPath _finderPathCountByG_S;
/**
* Returns all the blogs entries where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching blogs entries
*/
@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 blogs entries where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@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 blogs entries where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@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 blogs entries where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@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 = _finderPathWithoutPaginationFindByG_S;
finderArgs = new Object[] {groupId, status};
}
else {
finderPath = _finderPathWithPaginationFindByG_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 (BlogsEntry blogsEntry : list) {
if ((groupId != blogsEntry.getGroupId()) ||
(status != blogsEntry.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_BLOGSENTRY_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(BlogsEntryModelImpl.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 blogs entry 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 blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByG_S_First(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByG_S_First(
groupId, status, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", status=");
msg.append(status);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry 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 blogs entry 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 blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByG_S_Last(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByG_S_Last(
groupId, status, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", status=");
msg.append(status);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry 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 blogs entries before and after the current blogs entry in the ordered set where groupId = ? and status = ?.
*
* @param entryId the primary key of the current blogs entry
* @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 blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByG_S_PrevAndNext(
long entryId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByG_S_PrevAndNext(
session, blogsEntry, groupId, status, orderByComparator, true);
array[1] = blogsEntry;
array[2] = getByG_S_PrevAndNext(
session, blogsEntry, groupId, status, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByG_S_PrevAndNext(
Session session, BlogsEntry blogsEntry, 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_BLOGSENTRY_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the blogs entries that the user has permission to view where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching blogs entries 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 blogs entries that the user has permission to view where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries 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 blogs entries that the user has permissions to view where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByG_S(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_S(groupId, status, start, end, orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
}
else {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_S_GROUPID_2);
query.append(_FINDER_COLUMN_G_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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, BlogsEntryImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
return (List)QueryUtil.list(
q, getDialect(), start, end);
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = ? and status = ?.
*
* @param entryId the primary key of the current blogs entry
* @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 blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] filterFindByG_S_PrevAndNext(
long entryId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_S_PrevAndNext(
entryId, groupId, status, orderByComparator);
}
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = filterGetByG_S_PrevAndNext(
session, blogsEntry, groupId, status, orderByComparator, true);
array[1] = blogsEntry;
array[2] = filterGetByG_S_PrevAndNext(
session, blogsEntry, groupId, status, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry filterGetByG_S_PrevAndNext(
Session session, BlogsEntry blogsEntry, long groupId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
}
else {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_S_GROUPID_2);
query.append(_FINDER_COLUMN_G_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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, BlogsEntryImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where groupId = ? and status = ? from the database.
*
* @param groupId the group ID
* @param status the status
*/
@Override
public void removeByG_S(long groupId, int status) {
for (BlogsEntry blogsEntry :
findByG_S(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the number of matching blogs entries
*/
@Override
public int countByG_S(long groupId, int status) {
FinderPath finderPath = _finderPathCountByG_S;
Object[] finderArgs = new Object[] {groupId, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_S_GROUPID_2);
query.append(_FINDER_COLUMN_G_S_STATUS_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of blogs entries that the user has permission to view where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the number of matching blogs entries that the user has permission to view
*/
@Override
public int filterCountByG_S(long groupId, int status) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_S(groupId, status);
}
StringBundler query = new StringBundler(3);
query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_S_GROUPID_2);
query.append(_FINDER_COLUMN_G_S_STATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_S_GROUPID_2 =
"blogsEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_S_STATUS_2 =
"blogsEntry.status = ?";
private FinderPath _finderPathWithPaginationFindByG_NotS;
private FinderPath _finderPathWithPaginationCountByG_NotS;
/**
* Returns all the blogs entries where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching blogs entries
*/
@Override
public List findByG_NotS(long groupId, int status) {
return findByG_NotS(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByG_NotS(
long groupId, int status, int start, int end) {
return findByG_NotS(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByG_NotS(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByG_NotS(
groupId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByG_NotS(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByG_NotS;
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 (BlogsEntry blogsEntry : list) {
if ((groupId != blogsEntry.getGroupId()) ||
(status == blogsEntry.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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.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 blogs entry 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 blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByG_NotS_First(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByG_NotS_First(
groupId, status, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", status=");
msg.append(status);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByG_NotS_First(
long groupId, int status,
OrderByComparator orderByComparator) {
List list = findByG_NotS(
groupId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last blogs entry 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 blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByG_NotS_Last(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByG_NotS_Last(
groupId, status, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", status=");
msg.append(status);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry 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 blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByG_NotS_Last(
long groupId, int status,
OrderByComparator orderByComparator) {
int count = countByG_NotS(groupId, status);
if (count == 0) {
return null;
}
List list = findByG_NotS(
groupId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = ? and status ≠ ?.
*
* @param entryId the primary key of the current blogs entry
* @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 blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByG_NotS_PrevAndNext(
long entryId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByG_NotS_PrevAndNext(
session, blogsEntry, groupId, status, orderByComparator, true);
array[1] = blogsEntry;
array[2] = getByG_NotS_PrevAndNext(
session, blogsEntry, groupId, status, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByG_NotS_PrevAndNext(
Session session, BlogsEntry blogsEntry, 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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
query.append(_FINDER_COLUMN_G_NOTS_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the blogs entries that the user has permission to view where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByG_NotS(long groupId, int status) {
return filterFindByG_NotS(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries that the user has permission to view where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByG_NotS(
long groupId, int status, int start, int end) {
return filterFindByG_NotS(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries that the user has permission to view
*/
@Override
public List filterFindByG_NotS(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_NotS(groupId, status, start, end, orderByComparator);
}
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
}
else {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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, BlogsEntryImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
return (List)QueryUtil.list(
q, getDialect(), start, end);
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = ? and status ≠ ?.
*
* @param entryId the primary key of the current blogs entry
* @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 blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] filterFindByG_NotS_PrevAndNext(
long entryId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_NotS_PrevAndNext(
entryId, groupId, status, orderByComparator);
}
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = filterGetByG_NotS_PrevAndNext(
session, blogsEntry, groupId, status, orderByComparator, true);
array[1] = blogsEntry;
array[2] = filterGetByG_NotS_PrevAndNext(
session, blogsEntry, groupId, status, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry filterGetByG_NotS_PrevAndNext(
Session session, BlogsEntry blogsEntry, long groupId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
}
else {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
query.append(
_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
query.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
query.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.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, BlogsEntryImpl.class);
}
else {
q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
}
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where groupId = ? and status ≠ ? from the database.
*
* @param groupId the group ID
* @param status the status
*/
@Override
public void removeByG_NotS(long groupId, int status) {
for (BlogsEntry blogsEntry :
findByG_NotS(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @return the number of matching blogs entries
*/
@Override
public int countByG_NotS(long groupId, int status) {
FinderPath finderPath = _finderPathWithPaginationCountByG_NotS;
Object[] finderArgs = new Object[] {groupId, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of blogs entries that the user has permission to view where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @return the number of matching blogs entries that the user has permission to view
*/
@Override
public int filterCountByG_NotS(long groupId, int status) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_NotS(groupId, status);
}
StringBundler query = new StringBundler(3);
query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
query.toString(), BlogsEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery q = session.createSynchronizedSQLQuery(sql);
q.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(status);
Long count = (Long)q.uniqueResult();
return count.intValue();
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 =
"blogsEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 =
"blogsEntry.status != ?";
private FinderPath _finderPathWithPaginationFindByC_U;
private FinderPath _finderPathWithoutPaginationFindByC_U;
private FinderPath _finderPathCountByC_U;
/**
* Returns all the blogs entries where companyId = ? and userId = ?.
*
* @param companyId the company ID
* @param userId the user ID
* @return the matching blogs entries
*/
@Override
public List findByC_U(long companyId, long userId) {
return findByC_U(
companyId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where companyId = ? and userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param userId the user ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByC_U(
long companyId, long userId, int start, int end) {
return findByC_U(companyId, userId, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ? and userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param userId the user ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByC_U(
long companyId, long userId, int start, int end,
OrderByComparator orderByComparator) {
return findByC_U(
companyId, userId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ? and userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param userId the user ID
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByC_U(
long companyId, long userId, 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 = _finderPathWithoutPaginationFindByC_U;
finderArgs = new Object[] {companyId, userId};
}
else {
finderPath = _finderPathWithPaginationFindByC_U;
finderArgs = new Object[] {
companyId, userId, start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BlogsEntry blogsEntry : list) {
if ((companyId != blogsEntry.getCompanyId()) ||
(userId != blogsEntry.getUserId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
query.append(_FINDER_COLUMN_C_U_USERID_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(userId);
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 blogs entry in the ordered set where companyId = ? and userId = ?.
*
* @param companyId the company ID
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByC_U_First(
long companyId, long userId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByC_U_First(
companyId, userId, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", userId=");
msg.append(userId);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry in the ordered set where companyId = ? and userId = ?.
*
* @param companyId the company ID
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByC_U_First(
long companyId, long userId,
OrderByComparator orderByComparator) {
List list = findByC_U(
companyId, userId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last blogs entry in the ordered set where companyId = ? and userId = ?.
*
* @param companyId the company ID
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByC_U_Last(
long companyId, long userId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByC_U_Last(
companyId, userId, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", userId=");
msg.append(userId);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry in the ordered set where companyId = ? and userId = ?.
*
* @param companyId the company ID
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByC_U_Last(
long companyId, long userId,
OrderByComparator orderByComparator) {
int count = countByC_U(companyId, userId);
if (count == 0) {
return null;
}
List list = findByC_U(
companyId, userId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = ? and userId = ?.
*
* @param entryId the primary key of the current blogs entry
* @param companyId the company ID
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByC_U_PrevAndNext(
long entryId, long companyId, long userId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByC_U_PrevAndNext(
session, blogsEntry, companyId, userId, orderByComparator,
true);
array[1] = blogsEntry;
array[2] = getByC_U_PrevAndNext(
session, blogsEntry, companyId, userId, orderByComparator,
false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByC_U_PrevAndNext(
Session session, BlogsEntry blogsEntry, long companyId, long userId,
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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
query.append(_FINDER_COLUMN_C_U_USERID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(userId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where companyId = ? and userId = ? from the database.
*
* @param companyId the company ID
* @param userId the user ID
*/
@Override
public void removeByC_U(long companyId, long userId) {
for (BlogsEntry blogsEntry :
findByC_U(
companyId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where companyId = ? and userId = ?.
*
* @param companyId the company ID
* @param userId the user ID
* @return the number of matching blogs entries
*/
@Override
public int countByC_U(long companyId, long userId) {
FinderPath finderPath = _finderPathCountByC_U;
Object[] finderArgs = new Object[] {companyId, userId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
query.append(_FINDER_COLUMN_C_U_USERID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(userId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_U_COMPANYID_2 =
"blogsEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_U_USERID_2 =
"blogsEntry.userId = ?";
private FinderPath _finderPathWithPaginationFindByC_LtD;
private FinderPath _finderPathWithPaginationCountByC_LtD;
/**
* Returns all the blogs entries where companyId = ? and displayDate < ?.
*
* @param companyId the company ID
* @param displayDate the display date
* @return the matching blogs entries
*/
@Override
public List findByC_LtD(long companyId, Date displayDate) {
return findByC_LtD(
companyId, displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where companyId = ? and displayDate < ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param displayDate the display date
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByC_LtD(
long companyId, Date displayDate, int start, int end) {
return findByC_LtD(companyId, displayDate, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ? and displayDate < ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param displayDate the display date
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByC_LtD(
long companyId, Date displayDate, int start, int end,
OrderByComparator orderByComparator) {
return findByC_LtD(
companyId, displayDate, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ? and displayDate < ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param displayDate the display date
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByC_LtD(
long companyId, Date displayDate, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByC_LtD;
finderArgs = new Object[] {
companyId, _getTime(displayDate), start, end, orderByComparator
};
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BlogsEntry blogsEntry : list) {
if ((companyId != blogsEntry.getCompanyId()) ||
(displayDate.getTime() <=
blogsEntry.getDisplayDate().getTime())) {
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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
if (!pagination) {
list = (List)QueryUtil.list(
q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(
q, getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first blogs entry in the ordered set where companyId = ? and displayDate < ?.
*
* @param companyId the company ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByC_LtD_First(
long companyId, Date displayDate,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByC_LtD_First(
companyId, displayDate, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", displayDate=");
msg.append(displayDate);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry in the ordered set where companyId = ? and displayDate < ?.
*
* @param companyId the company ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByC_LtD_First(
long companyId, Date displayDate,
OrderByComparator orderByComparator) {
List list = findByC_LtD(
companyId, displayDate, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last blogs entry in the ordered set where companyId = ? and displayDate < ?.
*
* @param companyId the company ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByC_LtD_Last(
long companyId, Date displayDate,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByC_LtD_Last(
companyId, displayDate, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", displayDate=");
msg.append(displayDate);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry in the ordered set where companyId = ? and displayDate < ?.
*
* @param companyId the company ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByC_LtD_Last(
long companyId, Date displayDate,
OrderByComparator orderByComparator) {
int count = countByC_LtD(companyId, displayDate);
if (count == 0) {
return null;
}
List list = findByC_LtD(
companyId, displayDate, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = ? and displayDate < ?.
*
* @param entryId the primary key of the current blogs entry
* @param companyId the company ID
* @param displayDate the display date
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByC_LtD_PrevAndNext(
long entryId, long companyId, Date displayDate,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByC_LtD_PrevAndNext(
session, blogsEntry, companyId, displayDate, orderByComparator,
true);
array[1] = blogsEntry;
array[2] = getByC_LtD_PrevAndNext(
session, blogsEntry, companyId, displayDate, orderByComparator,
false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByC_LtD_PrevAndNext(
Session session, BlogsEntry blogsEntry, long companyId,
Date displayDate, 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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where companyId = ? and displayDate < ? from the database.
*
* @param companyId the company ID
* @param displayDate the display date
*/
@Override
public void removeByC_LtD(long companyId, Date displayDate) {
for (BlogsEntry blogsEntry :
findByC_LtD(
companyId, displayDate, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where companyId = ? and displayDate < ?.
*
* @param companyId the company ID
* @param displayDate the display date
* @return the number of matching blogs entries
*/
@Override
public int countByC_LtD(long companyId, Date displayDate) {
FinderPath finderPath = _finderPathWithPaginationCountByC_LtD;
Object[] finderArgs = new Object[] {companyId, _getTime(displayDate)};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 =
"blogsEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 =
"blogsEntry.displayDate IS NULL";
private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 =
"blogsEntry.displayDate < ?";
private FinderPath _finderPathWithPaginationFindByC_S;
private FinderPath _finderPathWithoutPaginationFindByC_S;
private FinderPath _finderPathCountByC_S;
/**
* Returns all the blogs entries where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @return the matching blogs entries
*/
@Override
public List findByC_S(long companyId, int status) {
return findByC_S(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where companyId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByC_S(
long companyId, int status, int start, int end) {
return findByC_S(companyId, status, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByC_S(
long companyId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByC_S(
companyId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByC_S(
long companyId, 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 = _finderPathWithoutPaginationFindByC_S;
finderArgs = new Object[] {companyId, status};
}
else {
finderPath = _finderPathWithPaginationFindByC_S;
finderArgs = new Object[] {
companyId, status, start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BlogsEntry blogsEntry : list) {
if ((companyId != blogsEntry.getCompanyId()) ||
(status != blogsEntry.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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
query.append(_FINDER_COLUMN_C_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(status);
if (!pagination) {
list = (List)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 blogs entry in the ordered set where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByC_S_First(
long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByC_S_First(
companyId, status, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", status=");
msg.append(status);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry in the ordered set where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByC_S_First(
long companyId, int status,
OrderByComparator orderByComparator) {
List list = findByC_S(
companyId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last blogs entry in the ordered set where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByC_S_Last(
long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByC_S_Last(
companyId, status, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", status=");
msg.append(status);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry in the ordered set where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByC_S_Last(
long companyId, int status,
OrderByComparator orderByComparator) {
int count = countByC_S(companyId, status);
if (count == 0) {
return null;
}
List list = findByC_S(
companyId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = ? and status = ?.
*
* @param entryId the primary key of the current blogs entry
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByC_S_PrevAndNext(
long entryId, long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByC_S_PrevAndNext(
session, blogsEntry, companyId, status, orderByComparator,
true);
array[1] = blogsEntry;
array[2] = getByC_S_PrevAndNext(
session, blogsEntry, companyId, status, orderByComparator,
false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByC_S_PrevAndNext(
Session session, BlogsEntry blogsEntry, long companyId, 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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
query.append(_FINDER_COLUMN_C_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
query.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(WHERE_GREATER_THAN);
}
else {
query.append(WHERE_LESSER_THAN);
}
}
}
query.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
query.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
query.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
query.append(ORDER_BY_ASC);
}
else {
query.append(ORDER_BY_DESC);
}
}
}
}
else {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where companyId = ? and status = ? from the database.
*
* @param companyId the company ID
* @param status the status
*/
@Override
public void removeByC_S(long companyId, int status) {
for (BlogsEntry blogsEntry :
findByC_S(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @return the number of matching blogs entries
*/
@Override
public int countByC_S(long companyId, int status) {
FinderPath finderPath = _finderPathCountByC_S;
Object[] finderArgs = new Object[] {companyId, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
query.append(_FINDER_COLUMN_C_S_STATUS_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(status);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_S_COMPANYID_2 =
"blogsEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_S_STATUS_2 =
"blogsEntry.status = ?";
private FinderPath _finderPathWithPaginationFindByC_NotS;
private FinderPath _finderPathWithPaginationCountByC_NotS;
/**
* Returns all the blogs entries where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @return the matching blogs entries
*/
@Override
public List findByC_NotS(long companyId, int status) {
return findByC_NotS(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where companyId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByC_NotS(
long companyId, int status, int start, int end) {
return findByC_NotS(companyId, status, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByC_NotS(
long companyId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByC_NotS(
companyId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where companyId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 companyId the company ID
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByC_NotS(
long companyId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByC_NotS;
finderArgs = new Object[] {
companyId, status, start, end, orderByComparator
};
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BlogsEntry blogsEntry : list) {
if ((companyId != blogsEntry.getCompanyId()) ||
(status == blogsEntry.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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else if (pagination) {
query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(status);
if (!pagination) {
list = (List)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 blogs entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByC_NotS_First(
long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByC_NotS_First(
companyId, status, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", status=");
msg.append(status);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first blogs entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByC_NotS_First(
long companyId, int status,
OrderByComparator orderByComparator) {
List list = findByC_NotS(
companyId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last blogs entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry
* @throws NoSuchEntryException if a matching blogs entry could not be found
*/
@Override
public BlogsEntry findByC_NotS_Last(
long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = fetchByC_NotS_Last(
companyId, status, orderByComparator);
if (blogsEntry != null) {
return blogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", status=");
msg.append(status);
msg.append("}");
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last blogs entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching blogs entry, or null
if a matching blogs entry could not be found
*/
@Override
public BlogsEntry fetchByC_NotS_Last(
long companyId, int status,
OrderByComparator orderByComparator) {
int count = countByC_NotS(companyId, status);
if (count == 0) {
return null;
}
List list = findByC_NotS(
companyId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param entryId the primary key of the current blogs entry
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next blogs entry
* @throws NoSuchEntryException if a blogs entry with the primary key could not be found
*/
@Override
public BlogsEntry[] findByC_NotS_PrevAndNext(
long entryId, long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BlogsEntry blogsEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BlogsEntry[] array = new BlogsEntryImpl[3];
array[0] = getByC_NotS_PrevAndNext(
session, blogsEntry, companyId, status, orderByComparator,
true);
array[1] = blogsEntry;
array[2] = getByC_NotS_PrevAndNext(
session, blogsEntry, companyId, status, orderByComparator,
false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected BlogsEntry getByC_NotS_PrevAndNext(
Session session, BlogsEntry blogsEntry, long companyId, 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_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
query.append(_FINDER_COLUMN_C_NOTS_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(BlogsEntryModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(blogsEntry)) {
qPos.add(orderByConditionValue);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the blogs entries where companyId = ? and status ≠ ? from the database.
*
* @param companyId the company ID
* @param status the status
*/
@Override
public void removeByC_NotS(long companyId, int status) {
for (BlogsEntry blogsEntry :
findByC_NotS(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(blogsEntry);
}
}
/**
* Returns the number of blogs entries where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @return the number of matching blogs entries
*/
@Override
public int countByC_NotS(long companyId, int status) {
FinderPath finderPath = _finderPathWithPaginationCountByC_NotS;
Object[] finderArgs = new Object[] {companyId, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(status);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 =
"blogsEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 =
"blogsEntry.status != ?";
private FinderPath _finderPathWithPaginationFindByLtD_S;
private FinderPath _finderPathWithPaginationCountByLtD_S;
/**
* Returns all the blogs entries where displayDate < ? and status = ?.
*
* @param displayDate the display date
* @param status the status
* @return the matching blogs entries
*/
@Override
public List findByLtD_S(Date displayDate, int status) {
return findByLtD_S(
displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the blogs entries where displayDate < ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 displayDate the display date
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @return the range of matching blogs entries
*/
@Override
public List findByLtD_S(
Date displayDate, int status, int start, int end) {
return findByLtD_S(displayDate, status, start, end, null);
}
/**
* Returns an ordered range of all the blogs entries where displayDate < ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 displayDate the display date
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching blogs entries
*/
@Override
public List findByLtD_S(
Date displayDate, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByLtD_S(
displayDate, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the blogs entries where displayDate < ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from BlogsEntryModelImpl
. 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 displayDate the display date
* @param status the status
* @param start the lower bound of the range of blogs entries
* @param end the upper bound of the range of blogs entries (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 blogs entries
*/
@Override
public List findByLtD_S(
Date displayDate, int status, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByLtD_S;
finderArgs = new Object[] {
_getTime(displayDate), status, start, end, orderByComparator
};
List