
com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl 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.microblogs.service.persistence.impl;
import aQute.bnd.annotation.ProviderType;
import com.liferay.microblogs.exception.NoSuchEntryException;
import com.liferay.microblogs.model.MicroblogsEntry;
import com.liferay.microblogs.model.impl.MicroblogsEntryImpl;
import com.liferay.microblogs.model.impl.MicroblogsEntryModelImpl;
import com.liferay.microblogs.service.persistence.MicroblogsEntryPersistence;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.CompanyProvider;
import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.spring.extender.service.ServiceReference;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* The persistence implementation for the microblogs entry service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @see MicroblogsEntryPersistence
* @see com.liferay.microblogs.service.persistence.MicroblogsEntryUtil
* @generated
*/
@ProviderType
public class MicroblogsEntryPersistenceImpl extends BasePersistenceImpl
implements MicroblogsEntryPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use {@link MicroblogsEntryUtil} to access the microblogs entry persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY = MicroblogsEntryImpl.class.getName();
public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
".List1";
public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
".List2";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findAll", new String[0]);
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByCompanyId",
new String[] {
Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
new String[] { Long.class.getName() },
MicroblogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
new String[] { Long.class.getName() });
/**
* Returns all the microblogs entries where companyId = ?.
*
* @param companyId the company ID
* @return the matching microblogs entries
*/
@Override
public List findByCompanyId(long companyId) {
return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the microblogs 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByCompanyId(long companyId, int start,
int end) {
return findByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the microblogs 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs 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 microblogs 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 {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs 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 = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
finderArgs = new Object[] { companyId };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
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 (MicroblogsEntry microblogsEntry : list) {
if ((companyId != microblogsEntry.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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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 microblogs 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 microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByCompanyId_First(long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByCompanyId_First(companyId,
orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs 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 microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry 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 microblogs 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 microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByCompanyId_Last(long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByCompanyId_Last(companyId,
orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs 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 microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry 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 microblogs entries before and after the current microblogs entry in the ordered set where companyId = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByCompanyId_PrevAndNext(
long microblogsEntryId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByCompanyId_PrevAndNext(session, microblogsEntry,
companyId, orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByCompanyId_PrevAndNext(session, microblogsEntry,
companyId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByCompanyId_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, 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_MICROBLOGSENTRY_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(MicroblogsEntryModelImpl.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) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the microblogs entries where companyId = ? from the database.
*
* @param companyId the company ID
*/
@Override
public void removeByCompanyId(long companyId) {
for (MicroblogsEntry microblogsEntry : findByCompanyId(companyId,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching microblogs entries
*/
@Override
public int countByCompanyId(long companyId) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
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_MICROBLOGSENTRY_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 = "microblogsEntry.companyId = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByUserId",
new String[] {
Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
new String[] { Long.class.getName() },
MicroblogsEntryModelImpl.USERID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
new String[] { Long.class.getName() });
/**
* Returns all the microblogs entries where userId = ?.
*
* @param userId the user ID
* @return the matching microblogs entries
*/
@Override
public List findByUserId(long userId) {
return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByUserId(long userId, int start, int end) {
return findByUserId(userId, start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByUserId(long userId, int start, int end,
OrderByComparator orderByComparator) {
return findByUserId(userId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByUserId(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 = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
finderArgs = new Object[] { userId };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
finderArgs = new Object[] { userId, start, end, orderByComparator };
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((userId != microblogsEntry.getUserId())) {
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_USERID_USERID_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(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 microblogs entry in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByUserId_First(long userId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByUserId_First(userId,
orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("userId=");
msg.append(userId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByUserId_First(long userId,
OrderByComparator orderByComparator) {
List list = findByUserId(userId, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByUserId_Last(long userId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByUserId_Last(userId,
orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("userId=");
msg.append(userId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByUserId_Last(long userId,
OrderByComparator orderByComparator) {
int count = countByUserId(userId);
if (count == 0) {
return null;
}
List list = findByUserId(userId, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where userId = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByUserId_PrevAndNext(long microblogsEntryId,
long userId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByUserId_PrevAndNext(session, microblogsEntry,
userId, orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByUserId_PrevAndNext(session, microblogsEntry,
userId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByUserId_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long userId,
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_USERID_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(MicroblogsEntryModelImpl.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(userId);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the microblogs entries where userId = ? from the database.
*
* @param userId the user ID
*/
@Override
public void removeByUserId(long userId) {
for (MicroblogsEntry microblogsEntry : findByUserId(userId,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where userId = ?.
*
* @param userId the user ID
* @return the number of matching microblogs entries
*/
@Override
public int countByUserId(long userId) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
Object[] finderArgs = new Object[] { userId };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_USERID_USERID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
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_USERID_USERID_2 = "microblogsEntry.userId = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByU_T",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_T",
new String[] { Long.class.getName(), Integer.class.getName() },
MicroblogsEntryModelImpl.USERID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.TYPE_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_U_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_T",
new String[] { Long.class.getName(), Integer.class.getName() });
/**
* Returns all the microblogs entries where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @return the matching microblogs entries
*/
@Override
public List findByU_T(long userId, int type) {
return findByU_T(userId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the microblogs entries where userId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByU_T(long userId, int type, int start,
int end) {
return findByU_T(userId, type, start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where userId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByU_T(long userId, int type, int start,
int end, OrderByComparator orderByComparator) {
return findByU_T(userId, type, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where userId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByU_T(long userId, int type, int start,
int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T;
finderArgs = new Object[] { userId, type };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_T;
finderArgs = new Object[] {
userId, type,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((userId != microblogsEntry.getUserId()) ||
(type != microblogsEntry.getType())) {
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_U_T_USERID_2);
query.append(_FINDER_COLUMN_U_T_TYPE_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(userId);
qPos.add(type);
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 microblogs entry in the ordered set where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByU_T_First(long userId, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByU_T_First(userId, type,
orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("userId=");
msg.append(userId);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByU_T_First(long userId, int type,
OrderByComparator orderByComparator) {
List list = findByU_T(userId, type, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByU_T_Last(long userId, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByU_T_Last(userId, type,
orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("userId=");
msg.append(userId);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByU_T_Last(long userId, int type,
OrderByComparator orderByComparator) {
int count = countByU_T(userId, type);
if (count == 0) {
return null;
}
List list = findByU_T(userId, type, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where userId = ? and type = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByU_T_PrevAndNext(long microblogsEntryId,
long userId, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByU_T_PrevAndNext(session, microblogsEntry, userId,
type, orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByU_T_PrevAndNext(session, microblogsEntry, userId,
type, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByU_T_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long userId, int type,
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_U_T_USERID_2);
query.append(_FINDER_COLUMN_U_T_TYPE_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(MicroblogsEntryModelImpl.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(userId);
qPos.add(type);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the microblogs entries where userId = ? and type = ? from the database.
*
* @param userId the user ID
* @param type the type
*/
@Override
public void removeByU_T(long userId, int type) {
for (MicroblogsEntry microblogsEntry : findByU_T(userId, type,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @return the number of matching microblogs entries
*/
@Override
public int countByU_T(long userId, int type) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_U_T;
Object[] finderArgs = new Object[] { userId, type };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_U_T_USERID_2);
query.append(_FINDER_COLUMN_U_T_TYPE_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(userId);
qPos.add(type);
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_U_T_USERID_2 = "microblogsEntry.userId = ? AND ";
private static final String _FINDER_COLUMN_U_T_TYPE_2 = "microblogsEntry.type = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByCCNI_CCPK",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CCNI_CCPK =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCCNI_CCPK",
new String[] { Long.class.getName(), Long.class.getName() },
MicroblogsEntryModelImpl.CREATORCLASSNAMEID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATORCLASSPK_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_CCNI_CCPK = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCCNI_CCPK",
new String[] { Long.class.getName(), Long.class.getName() });
public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByCCNI_CCPK",
new String[] { Long.class.getName(), Long.class.getName() });
/**
* Returns all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @return the matching microblogs entries
*/
@Override
public List findByCCNI_CCPK(long creatorClassNameId,
long creatorClassPK) {
return findByCCNI_CCPK(creatorClassNameId, creatorClassPK,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByCCNI_CCPK(long creatorClassNameId,
long creatorClassPK, int start, int end) {
return findByCCNI_CCPK(creatorClassNameId, creatorClassPK, start, end,
null);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByCCNI_CCPK(long creatorClassNameId,
long creatorClassPK, int start, int end,
OrderByComparator orderByComparator) {
return findByCCNI_CCPK(creatorClassNameId, creatorClassPK, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByCCNI_CCPK(long creatorClassNameId,
long creatorClassPK, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CCNI_CCPK;
finderArgs = new Object[] { creatorClassNameId, creatorClassPK };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK;
finderArgs = new Object[] {
creatorClassNameId, creatorClassPK,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
(creatorClassPK != microblogsEntry.getCreatorClassPK())) {
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(creatorClassPK);
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 microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByCCNI_CCPK_First(long creatorClassNameId,
long creatorClassPK,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByCCNI_CCPK_First(creatorClassNameId,
creatorClassPK, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", creatorClassPK=");
msg.append(creatorClassPK);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByCCNI_CCPK_First(long creatorClassNameId,
long creatorClassPK,
OrderByComparator orderByComparator) {
List list = findByCCNI_CCPK(creatorClassNameId,
creatorClassPK, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByCCNI_CCPK_Last(long creatorClassNameId,
long creatorClassPK,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByCCNI_CCPK_Last(creatorClassNameId,
creatorClassPK, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", creatorClassPK=");
msg.append(creatorClassPK);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByCCNI_CCPK_Last(long creatorClassNameId,
long creatorClassPK,
OrderByComparator orderByComparator) {
int count = countByCCNI_CCPK(creatorClassNameId, creatorClassPK);
if (count == 0) {
return null;
}
List list = findByCCNI_CCPK(creatorClassNameId,
creatorClassPK, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByCCNI_CCPK_PrevAndNext(
long microblogsEntryId, long creatorClassNameId, long creatorClassPK,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByCCNI_CCPK_PrevAndNext(session, microblogsEntry,
creatorClassNameId, creatorClassPK, orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByCCNI_CCPK_PrevAndNext(session, microblogsEntry,
creatorClassNameId, creatorClassPK, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByCCNI_CCPK_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long creatorClassNameId,
long creatorClassPK,
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_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(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(creatorClassPK);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @return the matching microblogs entries
*/
@Override
public List findByCCNI_CCPK(long creatorClassNameId,
long[] creatorClassPKs) {
return findByCCNI_CCPK(creatorClassNameId, creatorClassPKs,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByCCNI_CCPK(long creatorClassNameId,
long[] creatorClassPKs, int start, int end) {
return findByCCNI_CCPK(creatorClassNameId, creatorClassPKs, start, end,
null);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByCCNI_CCPK(long creatorClassNameId,
long[] creatorClassPKs, int start, int end,
OrderByComparator orderByComparator) {
return findByCCNI_CCPK(creatorClassNameId, creatorClassPKs, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByCCNI_CCPK(long creatorClassNameId,
long[] creatorClassPKs, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
if (creatorClassPKs == null) {
creatorClassPKs = new long[0];
}
else if (creatorClassPKs.length > 1) {
creatorClassPKs = ArrayUtil.unique(creatorClassPKs);
Arrays.sort(creatorClassPKs);
}
if (creatorClassPKs.length == 1) {
return findByCCNI_CCPK(creatorClassNameId, creatorClassPKs[0],
start, end, orderByComparator);
}
boolean pagination = true;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderArgs = new Object[] {
creatorClassNameId, StringUtil.merge(creatorClassPKs)
};
}
else {
finderArgs = new Object[] {
creatorClassNameId, StringUtil.merge(creatorClassPKs),
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
!ArrayUtil.contains(creatorClassPKs,
microblogsEntry.getCreatorClassPK())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = new StringBundler();
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2);
if (creatorClassPKs.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_7);
query.append(StringUtil.merge(creatorClassPKs));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
}
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
if (!pagination) {
list = (List)QueryUtil.list(q,
getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q,
getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK,
finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ? from the database.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
*/
@Override
public void removeByCCNI_CCPK(long creatorClassNameId, long creatorClassPK) {
for (MicroblogsEntry microblogsEntry : findByCCNI_CCPK(
creatorClassNameId, creatorClassPK, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where creatorClassNameId = ? and creatorClassPK = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @return the number of matching microblogs entries
*/
@Override
public int countByCCNI_CCPK(long creatorClassNameId, long creatorClassPK) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_CCNI_CCPK;
Object[] finderArgs = new Object[] { creatorClassNameId, creatorClassPK };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(creatorClassNameId);
qPos.add(creatorClassPK);
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 microblogs entries where creatorClassNameId = ? and creatorClassPK = any ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @return the number of matching microblogs entries
*/
@Override
public int countByCCNI_CCPK(long creatorClassNameId, long[] creatorClassPKs) {
if (creatorClassPKs == null) {
creatorClassPKs = new long[0];
}
else if (creatorClassPKs.length > 1) {
creatorClassPKs = ArrayUtil.unique(creatorClassPKs);
Arrays.sort(creatorClassPKs);
}
Object[] finderArgs = new Object[] {
creatorClassNameId, StringUtil.merge(creatorClassPKs)
};
Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK,
finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler();
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2);
if (creatorClassPKs.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_7);
query.append(StringUtil.merge(creatorClassPKs));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
}
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(creatorClassNameId);
count = (Long)q.uniqueResult();
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK,
finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2 = "microblogsEntry.creatorClassNameId = ? AND ";
private static final String _FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_2 = "microblogsEntry.creatorClassPK = ?";
private static final String _FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_7 = "microblogsEntry.creatorClassPK IN (";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByCCNI_T",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CCNI_T =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCCNI_T",
new String[] { Long.class.getName(), Integer.class.getName() },
MicroblogsEntryModelImpl.CREATORCLASSNAMEID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.TYPE_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_CCNI_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCCNI_T",
new String[] { Long.class.getName(), Integer.class.getName() });
/**
* Returns all the microblogs entries where creatorClassNameId = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param type the type
* @return the matching microblogs entries
*/
@Override
public List findByCCNI_T(long creatorClassNameId, int type) {
return findByCCNI_T(creatorClassNameId, type, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where creatorClassNameId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByCCNI_T(long creatorClassNameId,
int type, int start, int end) {
return findByCCNI_T(creatorClassNameId, type, start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByCCNI_T(long creatorClassNameId,
int type, int start, int end,
OrderByComparator orderByComparator) {
return findByCCNI_T(creatorClassNameId, type, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByCCNI_T(long creatorClassNameId,
int type, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CCNI_T;
finderArgs = new Object[] { creatorClassNameId, type };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_T;
finderArgs = new Object[] {
creatorClassNameId, type,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
(type != microblogsEntry.getType())) {
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_T_TYPE_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(type);
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 microblogs entry in the ordered set where creatorClassNameId = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByCCNI_T_First(long creatorClassNameId,
int type, OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByCCNI_T_First(creatorClassNameId,
type, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where creatorClassNameId = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByCCNI_T_First(long creatorClassNameId,
int type, OrderByComparator orderByComparator) {
List list = findByCCNI_T(creatorClassNameId, type, 0,
1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where creatorClassNameId = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByCCNI_T_Last(long creatorClassNameId, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByCCNI_T_Last(creatorClassNameId,
type, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where creatorClassNameId = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByCCNI_T_Last(long creatorClassNameId,
int type, OrderByComparator orderByComparator) {
int count = countByCCNI_T(creatorClassNameId, type);
if (count == 0) {
return null;
}
List list = findByCCNI_T(creatorClassNameId, type,
count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where creatorClassNameId = ? and type = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByCCNI_T_PrevAndNext(long microblogsEntryId,
long creatorClassNameId, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByCCNI_T_PrevAndNext(session, microblogsEntry,
creatorClassNameId, type, orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByCCNI_T_PrevAndNext(session, microblogsEntry,
creatorClassNameId, type, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByCCNI_T_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long creatorClassNameId, int type,
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_T_TYPE_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(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(type);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the microblogs entries where creatorClassNameId = ? and type = ? from the database.
*
* @param creatorClassNameId the creator class name ID
* @param type the type
*/
@Override
public void removeByCCNI_T(long creatorClassNameId, int type) {
for (MicroblogsEntry microblogsEntry : findByCCNI_T(
creatorClassNameId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where creatorClassNameId = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param type the type
* @return the number of matching microblogs entries
*/
@Override
public int countByCCNI_T(long creatorClassNameId, int type) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_CCNI_T;
Object[] finderArgs = new Object[] { creatorClassNameId, type };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_T_TYPE_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(creatorClassNameId);
qPos.add(type);
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_CCNI_T_CREATORCLASSNAMEID_2 = "microblogsEntry.creatorClassNameId = ? AND ";
private static final String _FINDER_COLUMN_CCNI_T_TYPE_2 = "microblogsEntry.type = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_P = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByT_P",
new String[] {
Integer.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_P",
new String[] { Integer.class.getName(), Long.class.getName() },
MicroblogsEntryModelImpl.TYPE_COLUMN_BITMASK |
MicroblogsEntryModelImpl.PARENTMICROBLOGSENTRYID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_T_P = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_P",
new String[] { Integer.class.getName(), Long.class.getName() });
/**
* Returns all the microblogs entries where type = ? and parentMicroblogsEntryId = ?.
*
* @param type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @return the matching microblogs entries
*/
@Override
public List findByT_P(int type,
long parentMicroblogsEntryId) {
return findByT_P(type, parentMicroblogsEntryId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where type = ? and parentMicroblogsEntryId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByT_P(int type,
long parentMicroblogsEntryId, int start, int end) {
return findByT_P(type, parentMicroblogsEntryId, start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where type = ? and parentMicroblogsEntryId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByT_P(int type,
long parentMicroblogsEntryId, int start, int end,
OrderByComparator orderByComparator) {
return findByT_P(type, parentMicroblogsEntryId, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where type = ? and parentMicroblogsEntryId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByT_P(int type,
long parentMicroblogsEntryId, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P;
finderArgs = new Object[] { type, parentMicroblogsEntryId };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_P;
finderArgs = new Object[] {
type, parentMicroblogsEntryId,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((type != microblogsEntry.getType()) ||
(parentMicroblogsEntryId != microblogsEntry.getParentMicroblogsEntryId())) {
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_T_P_TYPE_2);
query.append(_FINDER_COLUMN_T_P_PARENTMICROBLOGSENTRYID_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(type);
qPos.add(parentMicroblogsEntryId);
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 microblogs entry in the ordered set where type = ? and parentMicroblogsEntryId = ?.
*
* @param type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByT_P_First(int type,
long parentMicroblogsEntryId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByT_P_First(type,
parentMicroblogsEntryId, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("type=");
msg.append(type);
msg.append(", parentMicroblogsEntryId=");
msg.append(parentMicroblogsEntryId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where type = ? and parentMicroblogsEntryId = ?.
*
* @param type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByT_P_First(int type,
long parentMicroblogsEntryId,
OrderByComparator orderByComparator) {
List list = findByT_P(type, parentMicroblogsEntryId,
0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where type = ? and parentMicroblogsEntryId = ?.
*
* @param type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByT_P_Last(int type,
long parentMicroblogsEntryId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByT_P_Last(type,
parentMicroblogsEntryId, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("type=");
msg.append(type);
msg.append(", parentMicroblogsEntryId=");
msg.append(parentMicroblogsEntryId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where type = ? and parentMicroblogsEntryId = ?.
*
* @param type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByT_P_Last(int type,
long parentMicroblogsEntryId,
OrderByComparator orderByComparator) {
int count = countByT_P(type, parentMicroblogsEntryId);
if (count == 0) {
return null;
}
List list = findByT_P(type, parentMicroblogsEntryId,
count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where type = ? and parentMicroblogsEntryId = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByT_P_PrevAndNext(long microblogsEntryId,
int type, long parentMicroblogsEntryId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByT_P_PrevAndNext(session, microblogsEntry, type,
parentMicroblogsEntryId, orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByT_P_PrevAndNext(session, microblogsEntry, type,
parentMicroblogsEntryId, orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByT_P_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, int type,
long parentMicroblogsEntryId,
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_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_T_P_TYPE_2);
query.append(_FINDER_COLUMN_T_P_PARENTMICROBLOGSENTRYID_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(MicroblogsEntryModelImpl.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(type);
qPos.add(parentMicroblogsEntryId);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the microblogs entries where type = ? and parentMicroblogsEntryId = ? from the database.
*
* @param type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
*/
@Override
public void removeByT_P(int type, long parentMicroblogsEntryId) {
for (MicroblogsEntry microblogsEntry : findByT_P(type,
parentMicroblogsEntryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where type = ? and parentMicroblogsEntryId = ?.
*
* @param type the type
* @param parentMicroblogsEntryId the parent microblogs entry ID
* @return the number of matching microblogs entries
*/
@Override
public int countByT_P(int type, long parentMicroblogsEntryId) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_T_P;
Object[] finderArgs = new Object[] { type, parentMicroblogsEntryId };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_T_P_TYPE_2);
query.append(_FINDER_COLUMN_T_P_PARENTMICROBLOGSENTRYID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(type);
qPos.add(parentMicroblogsEntryId);
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_T_P_TYPE_2 = "microblogsEntry.type = ? AND ";
private static final String _FINDER_COLUMN_T_P_PARENTMICROBLOGSENTRYID_2 = "microblogsEntry.parentMicroblogsEntryId = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByC_CCNI_CCPK",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CCNI_CCPK =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_CCNI_CCPK",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName()
},
MicroblogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATORCLASSNAMEID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATORCLASSPK_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_C_CCNI_CCPK = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_CCNI_CCPK",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName()
});
public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CCNI_CCPK =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_CCNI_CCPK",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName()
});
/**
* Returns all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @return the matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK(long companyId,
long creatorClassNameId, long creatorClassPK) {
return findByC_CCNI_CCPK(companyId, creatorClassNameId, creatorClassPK,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK(long companyId,
long creatorClassNameId, long creatorClassPK, int start, int end) {
return findByC_CCNI_CCPK(companyId, creatorClassNameId, creatorClassPK,
start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK(long companyId,
long creatorClassNameId, long creatorClassPK, int start, int end,
OrderByComparator orderByComparator) {
return findByC_CCNI_CCPK(companyId, creatorClassNameId, creatorClassPK,
start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByC_CCNI_CCPK(long companyId,
long creatorClassNameId, long creatorClassPK, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CCNI_CCPK;
finderArgs = new Object[] {
companyId, creatorClassNameId, creatorClassPK
};
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK;
finderArgs = new Object[] {
companyId, creatorClassNameId, creatorClassPK,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((companyId != microblogsEntry.getCompanyId()) ||
(creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
(creatorClassPK != microblogsEntry.getCreatorClassPK())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSPK_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(creatorClassPK);
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 microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByC_CCNI_CCPK_First(long companyId,
long creatorClassNameId, long creatorClassPK,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByC_CCNI_CCPK_First(companyId,
creatorClassNameId, creatorClassPK, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", creatorClassPK=");
msg.append(creatorClassPK);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByC_CCNI_CCPK_First(long companyId,
long creatorClassNameId, long creatorClassPK,
OrderByComparator orderByComparator) {
List list = findByC_CCNI_CCPK(companyId,
creatorClassNameId, creatorClassPK, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByC_CCNI_CCPK_Last(long companyId,
long creatorClassNameId, long creatorClassPK,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByC_CCNI_CCPK_Last(companyId,
creatorClassNameId, creatorClassPK, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", creatorClassPK=");
msg.append(creatorClassPK);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByC_CCNI_CCPK_Last(long companyId,
long creatorClassNameId, long creatorClassPK,
OrderByComparator orderByComparator) {
int count = countByC_CCNI_CCPK(companyId, creatorClassNameId,
creatorClassPK);
if (count == 0) {
return null;
}
List list = findByC_CCNI_CCPK(companyId,
creatorClassNameId, creatorClassPK, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByC_CCNI_CCPK_PrevAndNext(
long microblogsEntryId, long companyId, long creatorClassNameId,
long creatorClassPK,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByC_CCNI_CCPK_PrevAndNext(session, microblogsEntry,
companyId, creatorClassNameId, creatorClassPK,
orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByC_CCNI_CCPK_PrevAndNext(session, microblogsEntry,
companyId, creatorClassNameId, creatorClassPK,
orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByC_CCNI_CCPK_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long companyId,
long creatorClassNameId, long creatorClassPK,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(5);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSPK_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(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(creatorClassPK);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @return the matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK(long companyId,
long creatorClassNameId, long[] creatorClassPKs) {
return findByC_CCNI_CCPK(companyId, creatorClassNameId,
creatorClassPKs, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK(long companyId,
long creatorClassNameId, long[] creatorClassPKs, int start, int end) {
return findByC_CCNI_CCPK(companyId, creatorClassNameId,
creatorClassPKs, start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK(long companyId,
long creatorClassNameId, long[] creatorClassPKs, int start, int end,
OrderByComparator orderByComparator) {
return findByC_CCNI_CCPK(companyId, creatorClassNameId,
creatorClassPKs, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByC_CCNI_CCPK(long companyId,
long creatorClassNameId, long[] creatorClassPKs, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
if (creatorClassPKs == null) {
creatorClassPKs = new long[0];
}
else if (creatorClassPKs.length > 1) {
creatorClassPKs = ArrayUtil.unique(creatorClassPKs);
Arrays.sort(creatorClassPKs);
}
if (creatorClassPKs.length == 1) {
return findByC_CCNI_CCPK(companyId, creatorClassNameId,
creatorClassPKs[0], start, end, orderByComparator);
}
boolean pagination = true;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderArgs = new Object[] {
companyId, creatorClassNameId,
StringUtil.merge(creatorClassPKs)
};
}
else {
finderArgs = new Object[] {
companyId, creatorClassNameId,
StringUtil.merge(creatorClassPKs),
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((companyId != microblogsEntry.getCompanyId()) ||
(creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
!ArrayUtil.contains(creatorClassPKs,
microblogsEntry.getCreatorClassPK())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = new StringBundler();
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSNAMEID_2);
if (creatorClassPKs.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSPK_7);
query.append(StringUtil.merge(creatorClassPKs));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
}
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
if (!pagination) {
list = (List)QueryUtil.list(q,
getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q,
getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK,
finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? from the database.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
*/
@Override
public void removeByC_CCNI_CCPK(long companyId, long creatorClassNameId,
long creatorClassPK) {
for (MicroblogsEntry microblogsEntry : findByC_CCNI_CCPK(companyId,
creatorClassNameId, creatorClassPK, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @return the number of matching microblogs entries
*/
@Override
public int countByC_CCNI_CCPK(long companyId, long creatorClassNameId,
long creatorClassPK) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_C_CCNI_CCPK;
Object[] finderArgs = new Object[] {
companyId, creatorClassNameId, creatorClassPK
};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSPK_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(creatorClassNameId);
qPos.add(creatorClassPK);
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 microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = any ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @return the number of matching microblogs entries
*/
@Override
public int countByC_CCNI_CCPK(long companyId, long creatorClassNameId,
long[] creatorClassPKs) {
if (creatorClassPKs == null) {
creatorClassPKs = new long[0];
}
else if (creatorClassPKs.length > 1) {
creatorClassPKs = ArrayUtil.unique(creatorClassPKs);
Arrays.sort(creatorClassPKs);
}
Object[] finderArgs = new Object[] {
companyId, creatorClassNameId, StringUtil.merge(creatorClassPKs)
};
Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CCNI_CCPK,
finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler();
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSNAMEID_2);
if (creatorClassPKs.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSPK_7);
query.append(StringUtil.merge(creatorClassPKs));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
}
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(creatorClassNameId);
count = (Long)q.uniqueResult();
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CCNI_CCPK,
finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CCNI_CCPK,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_CCNI_CCPK_COMPANYID_2 = "microblogsEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSNAMEID_2 = "microblogsEntry.creatorClassNameId = ? AND ";
private static final String _FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSPK_2 = "microblogsEntry.creatorClassPK = ?";
private static final String _FINDER_COLUMN_C_CCNI_CCPK_CREATORCLASSPK_7 = "microblogsEntry.creatorClassPK IN (";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByC_CCNI_T",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CCNI_T =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_CCNI_T",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName()
},
MicroblogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATORCLASSNAMEID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.TYPE_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_C_CCNI_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_CCNI_T",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName()
});
/**
* Returns all the microblogs entries where companyId = ? and creatorClassNameId = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param type the type
* @return the matching microblogs entries
*/
@Override
public List findByC_CCNI_T(long companyId,
long creatorClassNameId, int type) {
return findByC_CCNI_T(companyId, creatorClassNameId, type,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByC_CCNI_T(long companyId,
long creatorClassNameId, int type, int start, int end) {
return findByC_CCNI_T(companyId, creatorClassNameId, type, start, end,
null);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByC_CCNI_T(long companyId,
long creatorClassNameId, int type, int start, int end,
OrderByComparator orderByComparator) {
return findByC_CCNI_T(companyId, creatorClassNameId, type, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByC_CCNI_T(long companyId,
long creatorClassNameId, int type, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CCNI_T;
finderArgs = new Object[] { companyId, creatorClassNameId, type };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_T;
finderArgs = new Object[] {
companyId, creatorClassNameId, type,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((companyId != microblogsEntry.getCompanyId()) ||
(creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
(type != microblogsEntry.getType())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_T_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_T_TYPE_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(type);
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 microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByC_CCNI_T_First(long companyId,
long creatorClassNameId, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByC_CCNI_T_First(companyId,
creatorClassNameId, type, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByC_CCNI_T_First(long companyId,
long creatorClassNameId, int type,
OrderByComparator orderByComparator) {
List list = findByC_CCNI_T(companyId,
creatorClassNameId, type, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByC_CCNI_T_Last(long companyId,
long creatorClassNameId, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByC_CCNI_T_Last(companyId,
creatorClassNameId, type, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByC_CCNI_T_Last(long companyId,
long creatorClassNameId, int type,
OrderByComparator orderByComparator) {
int count = countByC_CCNI_T(companyId, creatorClassNameId, type);
if (count == 0) {
return null;
}
List list = findByC_CCNI_T(companyId,
creatorClassNameId, type, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and type = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByC_CCNI_T_PrevAndNext(
long microblogsEntryId, long companyId, long creatorClassNameId,
int type, OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByC_CCNI_T_PrevAndNext(session, microblogsEntry,
companyId, creatorClassNameId, type, orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByC_CCNI_T_PrevAndNext(session, microblogsEntry,
companyId, creatorClassNameId, type, orderByComparator,
false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByC_CCNI_T_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long companyId,
long creatorClassNameId, int type,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(5);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_T_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_T_TYPE_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(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(type);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the microblogs entries where companyId = ? and creatorClassNameId = ? and type = ? from the database.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param type the type
*/
@Override
public void removeByC_CCNI_T(long companyId, long creatorClassNameId,
int type) {
for (MicroblogsEntry microblogsEntry : findByC_CCNI_T(companyId,
creatorClassNameId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where companyId = ? and creatorClassNameId = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param type the type
* @return the number of matching microblogs entries
*/
@Override
public int countByC_CCNI_T(long companyId, long creatorClassNameId, int type) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_C_CCNI_T;
Object[] finderArgs = new Object[] { companyId, creatorClassNameId, type };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_T_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_T_TYPE_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(creatorClassNameId);
qPos.add(type);
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_CCNI_T_COMPANYID_2 = "microblogsEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_CCNI_T_CREATORCLASSNAMEID_2 = "microblogsEntry.creatorClassNameId = ? AND ";
private static final String _FINDER_COLUMN_C_CCNI_T_TYPE_2 = "microblogsEntry.type = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByCCNI_CCPK_T",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CCNI_CCPK_T =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCCNI_CCPK_T",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName()
},
MicroblogsEntryModelImpl.CREATORCLASSNAMEID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATORCLASSPK_COLUMN_BITMASK |
MicroblogsEntryModelImpl.TYPE_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_CCNI_CCPK_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCCNI_CCPK_T",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName()
});
public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK_T =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByCCNI_CCPK_T",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName()
});
/**
* Returns all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @return the matching microblogs entries
*/
@Override
public List findByCCNI_CCPK_T(long creatorClassNameId,
long creatorClassPK, int type) {
return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPK, type,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByCCNI_CCPK_T(long creatorClassNameId,
long creatorClassPK, int type, int start, int end) {
return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPK, type,
start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByCCNI_CCPK_T(long creatorClassNameId,
long creatorClassPK, int type, int start, int end,
OrderByComparator orderByComparator) {
return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPK, type,
start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByCCNI_CCPK_T(long creatorClassNameId,
long creatorClassPK, int type, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CCNI_CCPK_T;
finderArgs = new Object[] { creatorClassNameId, creatorClassPK, type };
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T;
finderArgs = new Object[] {
creatorClassNameId, creatorClassPK, type,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
(creatorClassPK != microblogsEntry.getCreatorClassPK()) ||
(type != microblogsEntry.getType())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(5);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(creatorClassPK);
qPos.add(type);
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 microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByCCNI_CCPK_T_First(long creatorClassNameId,
long creatorClassPK, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByCCNI_CCPK_T_First(creatorClassNameId,
creatorClassPK, type, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", creatorClassPK=");
msg.append(creatorClassPK);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByCCNI_CCPK_T_First(long creatorClassNameId,
long creatorClassPK, int type,
OrderByComparator orderByComparator) {
List list = findByCCNI_CCPK_T(creatorClassNameId,
creatorClassPK, type, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByCCNI_CCPK_T_Last(long creatorClassNameId,
long creatorClassPK, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByCCNI_CCPK_T_Last(creatorClassNameId,
creatorClassPK, type, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", creatorClassPK=");
msg.append(creatorClassPK);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByCCNI_CCPK_T_Last(long creatorClassNameId,
long creatorClassPK, int type,
OrderByComparator orderByComparator) {
int count = countByCCNI_CCPK_T(creatorClassNameId, creatorClassPK, type);
if (count == 0) {
return null;
}
List list = findByCCNI_CCPK_T(creatorClassNameId,
creatorClassPK, type, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByCCNI_CCPK_T_PrevAndNext(
long microblogsEntryId, long creatorClassNameId, long creatorClassPK,
int type, OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByCCNI_CCPK_T_PrevAndNext(session, microblogsEntry,
creatorClassNameId, creatorClassPK, type,
orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByCCNI_CCPK_T_PrevAndNext(session, microblogsEntry,
creatorClassNameId, creatorClassPK, type,
orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByCCNI_CCPK_T_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long creatorClassNameId,
long creatorClassPK, int type,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(5);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_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(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(creatorClassPK);
qPos.add(type);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param type the type
* @return the matching microblogs entries
*/
@Override
public List findByCCNI_CCPK_T(long creatorClassNameId,
long[] creatorClassPKs, int type) {
return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs, type,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByCCNI_CCPK_T(long creatorClassNameId,
long[] creatorClassPKs, int type, int start, int end) {
return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs, type,
start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByCCNI_CCPK_T(long creatorClassNameId,
long[] creatorClassPKs, int type, int start, int end,
OrderByComparator orderByComparator) {
return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs, type,
start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ? and type = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByCCNI_CCPK_T(long creatorClassNameId,
long[] creatorClassPKs, int type, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
if (creatorClassPKs == null) {
creatorClassPKs = new long[0];
}
else if (creatorClassPKs.length > 1) {
creatorClassPKs = ArrayUtil.unique(creatorClassPKs);
Arrays.sort(creatorClassPKs);
}
if (creatorClassPKs.length == 1) {
return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs[0],
type, start, end, orderByComparator);
}
boolean pagination = true;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderArgs = new Object[] {
creatorClassNameId, StringUtil.merge(creatorClassPKs), type
};
}
else {
finderArgs = new Object[] {
creatorClassNameId, StringUtil.merge(creatorClassPKs), type,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
!ArrayUtil.contains(creatorClassPKs,
microblogsEntry.getCreatorClassPK()) ||
(type != microblogsEntry.getType())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = new StringBundler();
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
if (creatorClassPKs.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7);
query.append(StringUtil.merge(creatorClassPKs));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(type);
if (!pagination) {
list = (List)QueryUtil.list(q,
getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q,
getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T,
finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the microblogs entries where creatorClassNameId = ? and creatorClassPK = ? and type = ? from the database.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
*/
@Override
public void removeByCCNI_CCPK_T(long creatorClassNameId,
long creatorClassPK, int type) {
for (MicroblogsEntry microblogsEntry : findByCCNI_CCPK_T(
creatorClassNameId, creatorClassPK, type, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @return the number of matching microblogs entries
*/
@Override
public int countByCCNI_CCPK_T(long creatorClassNameId, long creatorClassPK,
int type) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_CCNI_CCPK_T;
Object[] finderArgs = new Object[] {
creatorClassNameId, creatorClassPK, type
};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_2);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(creatorClassNameId);
qPos.add(creatorClassPK);
qPos.add(type);
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 microblogs entries where creatorClassNameId = ? and creatorClassPK = any ? and type = ?.
*
* @param creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param type the type
* @return the number of matching microblogs entries
*/
@Override
public int countByCCNI_CCPK_T(long creatorClassNameId,
long[] creatorClassPKs, int type) {
if (creatorClassPKs == null) {
creatorClassPKs = new long[0];
}
else if (creatorClassPKs.length > 1) {
creatorClassPKs = ArrayUtil.unique(creatorClassPKs);
Arrays.sort(creatorClassPKs);
}
Object[] finderArgs = new Object[] {
creatorClassNameId, StringUtil.merge(creatorClassPKs), type
};
Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK_T,
finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler();
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
if (creatorClassPKs.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7);
query.append(StringUtil.merge(creatorClassPKs));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(creatorClassNameId);
qPos.add(type);
count = (Long)q.uniqueResult();
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK_T,
finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK_T,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2 = "microblogsEntry.creatorClassNameId = ? AND ";
private static final String _FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_2 = "microblogsEntry.creatorClassPK = ? AND ";
private static final String _FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7 = "microblogsEntry.creatorClassPK IN (";
private static final String _FINDER_COLUMN_CCNI_CCPK_T_TYPE_2 = "microblogsEntry.type = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK_T =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByC_CCNI_CCPK_T",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName(),
Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CCNI_CCPK_T =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_CCNI_CCPK_T",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName(),
Integer.class.getName()
},
MicroblogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATORCLASSNAMEID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATORCLASSPK_COLUMN_BITMASK |
MicroblogsEntryModelImpl.TYPE_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_C_CCNI_CCPK_T = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_CCNI_CCPK_T",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName(),
Integer.class.getName()
});
public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CCNI_CCPK_T =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_CCNI_CCPK_T",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName(),
Integer.class.getName()
});
/**
* Returns all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @return the matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK_T(long companyId,
long creatorClassNameId, long creatorClassPK, int type) {
return findByC_CCNI_CCPK_T(companyId, creatorClassNameId,
creatorClassPK, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK_T(long companyId,
long creatorClassNameId, long creatorClassPK, int type, int start,
int end) {
return findByC_CCNI_CCPK_T(companyId, creatorClassNameId,
creatorClassPK, type, start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK_T(long companyId,
long creatorClassNameId, long creatorClassPK, int type, int start,
int end, OrderByComparator orderByComparator) {
return findByC_CCNI_CCPK_T(companyId, creatorClassNameId,
creatorClassPK, type, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByC_CCNI_CCPK_T(long companyId,
long creatorClassNameId, long creatorClassPK, int type, int start,
int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CCNI_CCPK_T;
finderArgs = new Object[] {
companyId, creatorClassNameId, creatorClassPK, type
};
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK_T;
finderArgs = new Object[] {
companyId, creatorClassNameId, creatorClassPK, type,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((companyId != microblogsEntry.getCompanyId()) ||
(creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
(creatorClassPK != microblogsEntry.getCreatorClassPK()) ||
(type != microblogsEntry.getType())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(6);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSPK_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_TYPE_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(creatorClassPK);
qPos.add(type);
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 microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByC_CCNI_CCPK_T_First(long companyId,
long creatorClassNameId, long creatorClassPK, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByC_CCNI_CCPK_T_First(companyId,
creatorClassNameId, creatorClassPK, type, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(10);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", creatorClassPK=");
msg.append(creatorClassPK);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByC_CCNI_CCPK_T_First(long companyId,
long creatorClassNameId, long creatorClassPK, int type,
OrderByComparator orderByComparator) {
List list = findByC_CCNI_CCPK_T(companyId,
creatorClassNameId, creatorClassPK, type, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByC_CCNI_CCPK_T_Last(long companyId,
long creatorClassNameId, long creatorClassPK, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByC_CCNI_CCPK_T_Last(companyId,
creatorClassNameId, creatorClassPK, type, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(10);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", creatorClassNameId=");
msg.append(creatorClassNameId);
msg.append(", creatorClassPK=");
msg.append(creatorClassPK);
msg.append(", type=");
msg.append(type);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByC_CCNI_CCPK_T_Last(long companyId,
long creatorClassNameId, long creatorClassPK, int type,
OrderByComparator orderByComparator) {
int count = countByC_CCNI_CCPK_T(companyId, creatorClassNameId,
creatorClassPK, type);
if (count == 0) {
return null;
}
List list = findByC_CCNI_CCPK_T(companyId,
creatorClassNameId, creatorClassPK, type, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByC_CCNI_CCPK_T_PrevAndNext(
long microblogsEntryId, long companyId, long creatorClassNameId,
long creatorClassPK, int type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByC_CCNI_CCPK_T_PrevAndNext(session, microblogsEntry,
companyId, creatorClassNameId, creatorClassPK, type,
orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByC_CCNI_CCPK_T_PrevAndNext(session, microblogsEntry,
companyId, creatorClassNameId, creatorClassPK, type,
orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByC_CCNI_CCPK_T_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long companyId,
long creatorClassNameId, long creatorClassPK, int type,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(7 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(6);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSPK_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_TYPE_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(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(creatorClassPK);
qPos.add(type);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = any ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param type the type
* @return the matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK_T(long companyId,
long creatorClassNameId, long[] creatorClassPKs, int type) {
return findByC_CCNI_CCPK_T(companyId, creatorClassNameId,
creatorClassPKs, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = any ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK_T(long companyId,
long creatorClassNameId, long[] creatorClassPKs, int type, int start,
int end) {
return findByC_CCNI_CCPK_T(companyId, creatorClassNameId,
creatorClassPKs, type, start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = any ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByC_CCNI_CCPK_T(long companyId,
long creatorClassNameId, long[] creatorClassPKs, int type, int start,
int end, OrderByComparator orderByComparator) {
return findByC_CCNI_CCPK_T(companyId, creatorClassNameId,
creatorClassPKs, type, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByC_CCNI_CCPK_T(long companyId,
long creatorClassNameId, long[] creatorClassPKs, int type, int start,
int end, OrderByComparator orderByComparator,
boolean retrieveFromCache) {
if (creatorClassPKs == null) {
creatorClassPKs = new long[0];
}
else if (creatorClassPKs.length > 1) {
creatorClassPKs = ArrayUtil.unique(creatorClassPKs);
Arrays.sort(creatorClassPKs);
}
if (creatorClassPKs.length == 1) {
return findByC_CCNI_CCPK_T(companyId, creatorClassNameId,
creatorClassPKs[0], type, start, end, orderByComparator);
}
boolean pagination = true;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderArgs = new Object[] {
companyId, creatorClassNameId,
StringUtil.merge(creatorClassPKs), type
};
}
else {
finderArgs = new Object[] {
companyId, creatorClassNameId,
StringUtil.merge(creatorClassPKs), type,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK_T,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((companyId != microblogsEntry.getCompanyId()) ||
(creatorClassNameId != microblogsEntry.getCreatorClassNameId()) ||
!ArrayUtil.contains(creatorClassPKs,
microblogsEntry.getCreatorClassPK()) ||
(type != microblogsEntry.getType())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = new StringBundler();
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
if (creatorClassPKs.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSPK_7);
query.append(StringUtil.merge(creatorClassPKs));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_TYPE_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(creatorClassNameId);
qPos.add(type);
if (!pagination) {
list = (List)QueryUtil.list(q,
getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
}
else {
list = (List)QueryUtil.list(q,
getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK_T,
finderArgs, list);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CCNI_CCPK_T,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ? from the database.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
*/
@Override
public void removeByC_CCNI_CCPK_T(long companyId, long creatorClassNameId,
long creatorClassPK, int type) {
for (MicroblogsEntry microblogsEntry : findByC_CCNI_CCPK_T(companyId,
creatorClassNameId, creatorClassPK, type, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPK the creator class p k
* @param type the type
* @return the number of matching microblogs entries
*/
@Override
public int countByC_CCNI_CCPK_T(long companyId, long creatorClassNameId,
long creatorClassPK, int type) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_C_CCNI_CCPK_T;
Object[] finderArgs = new Object[] {
companyId, creatorClassNameId, creatorClassPK, type
};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(5);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSPK_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_TYPE_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(creatorClassNameId);
qPos.add(creatorClassPK);
qPos.add(type);
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 microblogs entries where companyId = ? and creatorClassNameId = ? and creatorClassPK = any ? and type = ?.
*
* @param companyId the company ID
* @param creatorClassNameId the creator class name ID
* @param creatorClassPKs the creator class p ks
* @param type the type
* @return the number of matching microblogs entries
*/
@Override
public int countByC_CCNI_CCPK_T(long companyId, long creatorClassNameId,
long[] creatorClassPKs, int type) {
if (creatorClassPKs == null) {
creatorClassPKs = new long[0];
}
else if (creatorClassPKs.length > 1) {
creatorClassPKs = ArrayUtil.unique(creatorClassPKs);
Arrays.sort(creatorClassPKs);
}
Object[] finderArgs = new Object[] {
companyId, creatorClassNameId, StringUtil.merge(creatorClassPKs),
type
};
Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CCNI_CCPK_T,
finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler();
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_COMPANYID_2);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSNAMEID_2);
if (creatorClassPKs.length > 0) {
query.append(StringPool.OPEN_PARENTHESIS);
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSPK_7);
query.append(StringUtil.merge(creatorClassPKs));
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(StringPool.CLOSE_PARENTHESIS);
query.append(WHERE_AND);
}
query.append(_FINDER_COLUMN_C_CCNI_CCPK_T_TYPE_2);
query.setStringAt(removeConjunction(query.stringAt(query.index() -
1)), query.index() - 1);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
qPos.add(creatorClassNameId);
qPos.add(type);
count = (Long)q.uniqueResult();
finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CCNI_CCPK_T,
finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CCNI_CCPK_T,
finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_CCNI_CCPK_T_COMPANYID_2 = "microblogsEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSNAMEID_2 =
"microblogsEntry.creatorClassNameId = ? AND ";
private static final String _FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSPK_2 = "microblogsEntry.creatorClassPK = ? AND ";
private static final String _FINDER_COLUMN_C_CCNI_CCPK_T_CREATORCLASSPK_7 = "microblogsEntry.creatorClassPK IN (";
private static final String _FINDER_COLUMN_C_CCNI_CCPK_T_TYPE_2 = "microblogsEntry.type = ?";
public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_T_S = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
"findByU_C_T_S",
new String[] {
Long.class.getName(), Date.class.getName(),
Integer.class.getName(), Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
});
public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_T_S =
new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED,
MicroblogsEntryImpl.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C_T_S",
new String[] {
Long.class.getName(), Date.class.getName(),
Integer.class.getName(), Integer.class.getName()
},
MicroblogsEntryModelImpl.USERID_COLUMN_BITMASK |
MicroblogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK |
MicroblogsEntryModelImpl.TYPE_COLUMN_BITMASK |
MicroblogsEntryModelImpl.SOCIALRELATIONTYPE_COLUMN_BITMASK);
public static final FinderPath FINDER_PATH_COUNT_BY_U_C_T_S = new FinderPath(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_T_S",
new String[] {
Long.class.getName(), Date.class.getName(),
Integer.class.getName(), Integer.class.getName()
});
/**
* Returns all the microblogs entries where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @return the matching microblogs entries
*/
@Override
public List findByU_C_T_S(long userId, Date createDate,
int type, int socialRelationType) {
return findByU_C_T_S(userId, createDate, type, socialRelationType,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the microblogs entries where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @return the range of matching microblogs entries
*/
@Override
public List findByU_C_T_S(long userId, Date createDate,
int type, int socialRelationType, int start, int end) {
return findByU_C_T_S(userId, createDate, type, socialRelationType,
start, end, null);
}
/**
* Returns an ordered range of all the microblogs entries where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching microblogs entries
*/
@Override
public List findByU_C_T_S(long userId, Date createDate,
int type, int socialRelationType, int start, int end,
OrderByComparator orderByComparator) {
return findByU_C_T_S(userId, createDate, type, socialRelationType,
start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the microblogs entries where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to {@link QueryUtil#ALL_POS} will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MicroblogsEntryModelImpl}. 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 userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @param start the lower bound of the range of microblogs entries
* @param end the upper bound of the range of microblogs 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 microblogs entries
*/
@Override
public List findByU_C_T_S(long userId, Date createDate,
int type, int socialRelationType, int start, int end,
OrderByComparator orderByComparator,
boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
pagination = false;
finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_T_S;
finderArgs = new Object[] {
userId, createDate, type, socialRelationType
};
}
else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_T_S;
finderArgs = new Object[] {
userId, createDate, type, socialRelationType,
start, end, orderByComparator
};
}
List list = null;
if (retrieveFromCache) {
list = (List)finderCache.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (MicroblogsEntry microblogsEntry : list) {
if ((userId != microblogsEntry.getUserId()) ||
!Objects.equals(createDate,
microblogsEntry.getCreateDate()) ||
(type != microblogsEntry.getType()) ||
(socialRelationType != microblogsEntry.getSocialRelationType())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByFields().length * 2));
}
else {
query = new StringBundler(6);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_U_C_T_S_USERID_2);
boolean bindCreateDate = false;
if (createDate == null) {
query.append(_FINDER_COLUMN_U_C_T_S_CREATEDATE_1);
}
else {
bindCreateDate = true;
query.append(_FINDER_COLUMN_U_C_T_S_CREATEDATE_2);
}
query.append(_FINDER_COLUMN_U_C_T_S_TYPE_2);
query.append(_FINDER_COLUMN_U_C_T_S_SOCIALRELATIONTYPE_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
}
else
if (pagination) {
query.append(MicroblogsEntryModelImpl.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(userId);
if (bindCreateDate) {
qPos.add(new Timestamp(createDate.getTime()));
}
qPos.add(type);
qPos.add(socialRelationType);
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 microblogs entry in the ordered set where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByU_C_T_S_First(long userId, Date createDate,
int type, int socialRelationType,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByU_C_T_S_First(userId,
createDate, type, socialRelationType, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(10);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("userId=");
msg.append(userId);
msg.append(", createDate=");
msg.append(createDate);
msg.append(", type=");
msg.append(type);
msg.append(", socialRelationType=");
msg.append(socialRelationType);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the first microblogs entry in the ordered set where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByU_C_T_S_First(long userId, Date createDate,
int type, int socialRelationType,
OrderByComparator orderByComparator) {
List list = findByU_C_T_S(userId, createDate, type,
socialRelationType, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last microblogs entry in the ordered set where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry
* @throws NoSuchEntryException if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry findByU_C_T_S_Last(long userId, Date createDate,
int type, int socialRelationType,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = fetchByU_C_T_S_Last(userId,
createDate, type, socialRelationType, orderByComparator);
if (microblogsEntry != null) {
return microblogsEntry;
}
StringBundler msg = new StringBundler(10);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("userId=");
msg.append(userId);
msg.append(", createDate=");
msg.append(createDate);
msg.append(", type=");
msg.append(type);
msg.append(", socialRelationType=");
msg.append(socialRelationType);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchEntryException(msg.toString());
}
/**
* Returns the last microblogs entry in the ordered set where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching microblogs entry, or null
if a matching microblogs entry could not be found
*/
@Override
public MicroblogsEntry fetchByU_C_T_S_Last(long userId, Date createDate,
int type, int socialRelationType,
OrderByComparator orderByComparator) {
int count = countByU_C_T_S(userId, createDate, type, socialRelationType);
if (count == 0) {
return null;
}
List list = findByU_C_T_S(userId, createDate, type,
socialRelationType, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the microblogs entries before and after the current microblogs entry in the ordered set where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
* @param microblogsEntryId the primary key of the current microblogs entry
* @param userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next microblogs entry
* @throws NoSuchEntryException if a microblogs entry with the primary key could not be found
*/
@Override
public MicroblogsEntry[] findByU_C_T_S_PrevAndNext(long microblogsEntryId,
long userId, Date createDate, int type, int socialRelationType,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
MicroblogsEntry microblogsEntry = findByPrimaryKey(microblogsEntryId);
Session session = null;
try {
session = openSession();
MicroblogsEntry[] array = new MicroblogsEntryImpl[3];
array[0] = getByU_C_T_S_PrevAndNext(session, microblogsEntry,
userId, createDate, type, socialRelationType,
orderByComparator, true);
array[1] = microblogsEntry;
array[2] = getByU_C_T_S_PrevAndNext(session, microblogsEntry,
userId, createDate, type, socialRelationType,
orderByComparator, false);
return array;
}
catch (Exception e) {
throw processException(e);
}
finally {
closeSession(session);
}
}
protected MicroblogsEntry getByU_C_T_S_PrevAndNext(Session session,
MicroblogsEntry microblogsEntry, long userId, Date createDate,
int type, int socialRelationType,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(7 +
(orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
query = new StringBundler(6);
}
query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_U_C_T_S_USERID_2);
boolean bindCreateDate = false;
if (createDate == null) {
query.append(_FINDER_COLUMN_U_C_T_S_CREATEDATE_1);
}
else {
bindCreateDate = true;
query.append(_FINDER_COLUMN_U_C_T_S_CREATEDATE_2);
}
query.append(_FINDER_COLUMN_U_C_T_S_TYPE_2);
query.append(_FINDER_COLUMN_U_C_T_S_SOCIALRELATIONTYPE_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(MicroblogsEntryModelImpl.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(userId);
if (bindCreateDate) {
qPos.add(new Timestamp(createDate.getTime()));
}
qPos.add(type);
qPos.add(socialRelationType);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(microblogsEntry);
for (Object value : values) {
qPos.add(value);
}
}
List list = q.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the microblogs entries where userId = ? and createDate = ? and type = ? and socialRelationType = ? from the database.
*
* @param userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
*/
@Override
public void removeByU_C_T_S(long userId, Date createDate, int type,
int socialRelationType) {
for (MicroblogsEntry microblogsEntry : findByU_C_T_S(userId,
createDate, type, socialRelationType, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(microblogsEntry);
}
}
/**
* Returns the number of microblogs entries where userId = ? and createDate = ? and type = ? and socialRelationType = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param type the type
* @param socialRelationType the social relation type
* @return the number of matching microblogs entries
*/
@Override
public int countByU_C_T_S(long userId, Date createDate, int type,
int socialRelationType) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_U_C_T_S;
Object[] finderArgs = new Object[] {
userId, createDate, type, socialRelationType
};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(5);
query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE);
query.append(_FINDER_COLUMN_U_C_T_S_USERID_2);
boolean bindCreateDate = false;
if (createDate == null) {
query.append(_FINDER_COLUMN_U_C_T_S_CREATEDATE_1);
}
else {
bindCreateDate = true;
query.append(_FINDER_COLUMN_U_C_T_S_CREATEDATE_2);
}
query.append(_FINDER_COLUMN_U_C_T_S_TYPE_2);
query.append(_FINDER_COLUMN_U_C_T_S_SOCIALRELATIONTYPE_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(userId);
if (bindCreateDate) {
qPos.add(new Timestamp(createDate.getTime()));
}
qPos.add(type);
qPos.add(socialRelationType);
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_U_C_T_S_USERID_2 = "microblogsEntry.userId = ? AND ";
private static final String _FINDER_COLUMN_U_C_T_S_CREATEDATE_1 = "microblogsEntry.createDate IS NULL AND ";
private static final String _FINDER_COLUMN_U_C_T_S_CREATEDATE_2 = "microblogsEntry.createDate = ? AND ";
private static final String _FINDER_COLUMN_U_C_T_S_TYPE_2 = "microblogsEntry.type = ? AND ";
private static final String _FINDER_COLUMN_U_C_T_S_SOCIALRELATIONTYPE_2 = "microblogsEntry.socialRelationType = ?";
public MicroblogsEntryPersistenceImpl() {
setModelClass(MicroblogsEntry.class);
}
/**
* Caches the microblogs entry in the entity cache if it is enabled.
*
* @param microblogsEntry the microblogs entry
*/
@Override
public void cacheResult(MicroblogsEntry microblogsEntry) {
entityCache.putResult(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED,
MicroblogsEntryImpl.class, microblogsEntry.getPrimaryKey(),
microblogsEntry);
microblogsEntry.resetOriginalValues();
}
/**
* Caches the microblogs entries in the entity cache if it is enabled.
*
* @param microblogsEntries the microblogs entries
*/
@Override
public void cacheResult(List