QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
*
remove(contest);
}
<<<<<<< HEAD
}
/**
* Returns the number of contests where contestActive = ?.
*
* @param contestActive the contest active
* @return the number of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public int countByContestActive(boolean contestActive)
throws SystemException {
FinderPath finderPath = FINDER_PATH_COUNT_BY_CONTESTACTIVE;
Object[] finderArgs = new Object[] { contestActive };
Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_CONTESTACTIVE_CONTESTACTIVE_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(contestActive);
count = (Long) q.uniqueResult();
FinderCacheUtil.putResult(finderPath, finderArgs, count);
} catch (Exception e) {
FinderCacheUtil.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns all the contests where contestActive = ? and featured = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @return the matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFeatured(boolean contestActive,
boolean featured) throws SystemException {
return findByActiveFeatured(contestActive, featured, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the contests where contestActive = ? and featured = ?.
*
*
* 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.ext.portlet.model.impl.ContestModelImpl}. 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 contestActive the contest active
* @param featured the featured
* @param start the lower bound of the range of contests
* @param end the upper bound of the range of contests (not inclusive)
* @return the range of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFeatured(boolean contestActive,
boolean featured, int start, int end) throws SystemException {
return findByActiveFeatured(contestActive, featured, start, end, null);
}
/**
* Returns an ordered range of all the contests where contestActive = ? and featured = ?.
*
* 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.ext.portlet.model.impl.ContestModelImpl}. 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 contestActive the contest active
* @param featured the featured
* @param start the lower bound of the range of contests
* @param end the upper bound of the range of contests (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
* @return the ordered range of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFeatured(boolean contestActive,
boolean featured, int start, int end,
OrderByComparator orderByComparator) throws SystemException {
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_ACTIVEFEATURED;
finderArgs = new Object[] { contestActive, featured };
} else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVEFEATURED;
finderArgs = new Object[] {
contestActive, featured,
start, end, orderByComparator
};
}
List list = (List) FinderCacheUtil.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Contest contest : list) {
if ((contestActive != contest.getContestActive()) ||
(featured != contest.getFeatured())) {
list = null;
break;
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 3));
} else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_ACTIVEFEATURED_CONTESTACTIVE_2);
query.append(_FINDER_COLUMN_ACTIVEFEATURED_FEATURED_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
} else
if (pagination) {
query.append(ContestModelImpl.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(contestActive);
qPos.add(featured);
if (!pagination) {
list = (List) QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = new UnmodifiableList(list);
} else {
list = (List) QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
FinderCacheUtil.putResult(finderPath, finderArgs, list);
} catch (Exception e) {
FinderCacheUtil.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first contest in the ordered set where contestActive = ? and featured = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the first matching contest
* @throws com.ext.portlet.NoSuchContestException if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest findByActiveFeatured_First(boolean contestActive,
boolean featured, OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = fetchByActiveFeatured_First(contestActive, featured,
orderByComparator);
if (contest != null) {
return contest;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("contestActive=");
msg.append(contestActive);
msg.append(", featured=");
msg.append(featured);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchContestException(msg.toString());
}
/**
* Returns the first contest in the ordered set where contestActive = ? and featured = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the first matching contest, or null if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest fetchByActiveFeatured_First(boolean contestActive,
boolean featured, OrderByComparator orderByComparator)
throws SystemException {
List list = findByActiveFeatured(contestActive, featured, 0,
1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last contest in the ordered set where contestActive = ? and featured = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the last matching contest
* @throws com.ext.portlet.NoSuchContestException if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
} else {
public Contest findByActiveFeatured_Last(boolean contestActive,
boolean featured, OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = fetchByActiveFeatured_Last(contestActive, featured,
orderByComparator);
if (contest != null) {
return contest;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("contestActive=");
msg.append(contestActive);
msg.append(", featured=");
msg.append(featured);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchContestException(msg.toString());
}
/**
* Returns the last contest in the ordered set where contestActive = ? and featured = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the last matching contest, or null if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest fetchByActiveFeatured_Last(boolean contestActive,
boolean featured, OrderByComparator orderByComparator)
throws SystemException {
int count = countByActiveFeatured(contestActive, featured);
if (count == 0) {
return null;
}
List list = findByActiveFeatured(contestActive, featured,
count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the contests before and after the current contest in the ordered set where contestActive = ? and featured = ?.
*
* @param ContestPK the primary key of the current contest
* @param contestActive the contest active
* @param featured the featured
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the previous, current, and next contest
* @throws com.ext.portlet.NoSuchContestException if a contest with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest[] findByActiveFeatured_PrevAndNext(long ContestPK,
boolean contestActive, boolean featured,
OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = findByPrimaryKey(ContestPK);
Session session = null;
try {
session = openSession();
Contest[] array = new ContestImpl[3];
array[0] = getByActiveFeatured_PrevAndNext(session, contest,
contestActive, featured, orderByComparator, true);
array[1] = contest;
array[2] = getByActiveFeatured_PrevAndNext(session, contest,
contestActive, featured, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
protected Contest getByActiveFeatured_PrevAndNext(Session session,
Contest contest, boolean contestActive, boolean featured,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByFields().length * 6));
} else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_ACTIVEFEATURED_CONTESTACTIVE_2);
query.append(_FINDER_COLUMN_ACTIVEFEATURED_FEATURED_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(ContestModelImpl.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(contestActive);
qPos.add(featured);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(contest);
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 contests where contestActive = ? and featured = ? from the database.
*
* @param contestActive the contest active
* @param featured the featured
* @throws SystemException if a system exception occurred
*/
@Override
public void removeByActiveFeatured(boolean contestActive, boolean featured)
throws SystemException {
for (Contest contest : findByActiveFeatured(contestActive, featured,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(contest);
}
}
/**
* Returns the number of contests where contestActive = ? and featured = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @return the number of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public int countByActiveFeatured(boolean contestActive, boolean featured)
throws SystemException {
FinderPath finderPath = FINDER_PATH_COUNT_BY_ACTIVEFEATURED;
Object[] finderArgs = new Object[] { contestActive, featured };
Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_ACTIVEFEATURED_CONTESTACTIVE_2);
query.append(_FINDER_COLUMN_ACTIVEFEATURED_FEATURED_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(contestActive);
qPos.add(featured);
count = (Long) q.uniqueResult();
FinderCacheUtil.putResult(finderPath, finderArgs, count);
} catch (Exception e) {
FinderCacheUtil.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns all the contests where contestActive = ? and featured = ? and contestPrivate = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @return the matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFeaturedcontestPrivate(
boolean contestActive, boolean featured, boolean contestPrivate)
throws SystemException {
return findByActiveFeaturedcontestPrivate(contestActive, featured,
contestPrivate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the contests where contestActive = ? and featured = ? and contestPrivate = ?.
*
*
break;
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(5 +
(orderByComparator.getOrderByFields().length * 3));
* 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.ext.portlet.model.impl.ContestModelImpl}. 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 contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @param start the lower bound of the range of contests
* @param end the upper bound of the range of contests (not inclusive)
* @return the range of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFeaturedcontestPrivate(
boolean contestActive, boolean featured, boolean contestPrivate,
int start, int end) throws SystemException {
return findByActiveFeaturedcontestPrivate(contestActive, featured,
contestPrivate, start, end, null);
}
/**
* Returns an ordered range of all the contests where contestActive = ? and featured = ? and contestPrivate = ?.
*
*
* 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.ext.portlet.model.impl.ContestModelImpl}. 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 contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @param start the lower bound of the range of contests
* @param end the upper bound of the range of contests (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
* @return the ordered range of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFeaturedcontestPrivate(
boolean contestActive, boolean featured, boolean contestPrivate,
int start, int end, OrderByComparator orderByComparator)
throws SystemException {
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_ACTIVEFEATUREDCONTESTPRIVATE;
finderArgs = new Object[] { contestActive, featured, contestPrivate };
} else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVEFEATUREDCONTESTPRIVATE;
finderArgs = new Object[] {
contestActive, featured, contestPrivate,
start, end, orderByComparator
};
}
List list = (List) FinderCacheUtil.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Contest contest : list) {
if ((contestActive != contest.getContestActive()) ||
(featured != contest.getFeatured()) ||
(contestPrivate != contest.getContestPrivate())) {
list = null;
query = new StringBundler(5);
}
query.append(_SQL_SELECT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_CONTESTACTIVE_2);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_FEATURED_2);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_CONTESTPRIVATE_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
} else
if (pagination) {
query.append(ContestModelImpl.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(contestActive);
qPos.add(featured);
qPos.add(contestPrivate);
if (!pagination) {
list = (List) QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = new UnmodifiableList(list);
} else {
list = (List) QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
FinderCacheUtil.putResult(finderPath, finderArgs, list);
} catch (Exception e) {
FinderCacheUtil.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first contest in the ordered set where contestActive = ? and featured = ? and contestPrivate = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the first matching contest
* @throws com.ext.portlet.NoSuchContestException if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest findByActiveFeaturedcontestPrivate_First(
boolean contestActive, boolean featured, boolean contestPrivate,
OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = fetchByActiveFeaturedcontestPrivate_First(contestActive,
featured, contestPrivate, orderByComparator);
if (contest != null) {
return contest;
}
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("contestActive=");
msg.append(contestActive);
msg.append(", featured=");
msg.append(featured);
msg.append(", contestPrivate=");
msg.append(contestPrivate);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchContestException(msg.toString());
}
/**
* Returns the first contest in the ordered set where contestActive = ? and featured = ? and contestPrivate = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the first matching contest, or null if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest fetchByActiveFeaturedcontestPrivate_First(
boolean contestActive, boolean featured, boolean contestPrivate,
OrderByComparator orderByComparator) throws SystemException {
List list = findByActiveFeaturedcontestPrivate(contestActive,
featured, contestPrivate, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last contest in the ordered set where contestActive = ? and featured = ? and contestPrivate = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the last matching contest
* @throws com.ext.portlet.NoSuchContestException if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest findByActiveFeaturedcontestPrivate_Last(
boolean contestActive, boolean featured, boolean contestPrivate,
OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = fetchByActiveFeaturedcontestPrivate_Last(contestActive,
featured, contestPrivate, orderByComparator);
if (contest != null) {
return contest;
}
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("contestActive=");
msg.append(contestActive);
msg.append(", featured=");
msg.append(featured);
msg.append(", contestPrivate=");
msg.append(contestPrivate);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchContestException(msg.toString());
}
/**
* Returns the last contest in the ordered set where contestActive = ? and featured = ? and contestPrivate = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the last matching contest, or null if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest fetchByActiveFeaturedcontestPrivate_Last(
boolean contestActive, boolean featured, boolean contestPrivate,
OrderByComparator orderByComparator) throws SystemException {
int count = countByActiveFeaturedcontestPrivate(contestActive,
featured, contestPrivate);
if (count == 0) {
return null;
}
List list = findByActiveFeaturedcontestPrivate(contestActive,
featured, contestPrivate, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the contests before and after the current contest in the ordered set where contestActive = ? and featured = ? and contestPrivate = ?.
*
* @param ContestPK the primary key of the current contest
* @param contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the previous, current, and next contest
* @throws com.ext.portlet.NoSuchContestException if a contest with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest[] findByActiveFeaturedcontestPrivate_PrevAndNext(
long ContestPK, boolean contestActive, boolean featured,
boolean contestPrivate, OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = findByPrimaryKey(ContestPK);
Session session = null;
try {
session = openSession();
Contest[] array = new ContestImpl[3];
array[0] = getByActiveFeaturedcontestPrivate_PrevAndNext(session,
contest, contestActive, featured, contestPrivate,
orderByComparator, true);
array[1] = contest;
array[2] = getByActiveFeaturedcontestPrivate_PrevAndNext(session,
contest, contestActive, featured, contestPrivate,
orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
protected Contest getByActiveFeaturedcontestPrivate_PrevAndNext(
Session session, Contest contest, boolean contestActive,
boolean featured, boolean contestPrivate,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByFields().length * 6));
} else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_CONTESTACTIVE_2);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_FEATURED_2);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_CONTESTPRIVATE_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(ContestModelImpl.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(contestActive);
qPos.add(featured);
qPos.add(contestPrivate);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(contest);
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 contests where contestActive = ? and featured = ? and contestPrivate = ? from the database.
*
* @param contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @throws SystemException if a system exception occurred
*/
@Override
public void removeByActiveFeaturedcontestPrivate(boolean contestActive,
boolean featured, boolean contestPrivate) throws SystemException {
for (Contest contest : findByActiveFeaturedcontestPrivate(
contestActive, featured, contestPrivate, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(contest);
}
}
/**
* Returns the number of contests where contestActive = ? and featured = ? and contestPrivate = ?.
*
* @param contestActive the contest active
* @param featured the featured
* @param contestPrivate the contest private
* @return the number of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public int countByActiveFeaturedcontestPrivate(boolean contestActive,
boolean featured, boolean contestPrivate) throws SystemException {
FinderPath finderPath = FINDER_PATH_COUNT_BY_ACTIVEFEATUREDCONTESTPRIVATE;
Object[] finderArgs = new Object[] {
contestActive, featured, contestPrivate
};
Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_CONTESTACTIVE_2);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_FEATURED_2);
query.append(_FINDER_COLUMN_ACTIVEFEATUREDCONTESTPRIVATE_CONTESTPRIVATE_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(contestActive);
qPos.add(featured);
qPos.add(contestPrivate);
count = (Long) q.uniqueResult();
FinderCacheUtil.putResult(finderPath, finderArgs, count);
} catch (Exception e) {
FinderCacheUtil.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns all the contests where contestActive = ? and flag = ?.
*
* @param contestActive the contest active
* @param flag the flag
* @return the matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFlag(boolean contestActive, int flag)
throws SystemException {
return findByActiveFlag(contestActive, flag, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the contests where contestActive = ? and flag = ?.
*
*
* 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.ext.portlet.model.impl.ContestModelImpl}. 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 contestActive the contest active
* @param flag the flag
* @param start the lower bound of the range of contests
* @param end the upper bound of the range of contests (not inclusive)
* @return the range of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFlag(boolean contestActive, int flag,
int start, int end) throws SystemException {
return findByActiveFlag(contestActive, flag, start, end, null);
}
/**
* Returns an ordered range of all the contests where contestActive = ? and flag = ?.
*
*
list = (List) QueryUtil.list(q, getDialect(),
start, end, false);
Collections.sort(list);
list = new UnmodifiableList(list);
} else {
* 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.ext.portlet.model.impl.ContestModelImpl}. 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 contestActive the contest active
* @param flag the flag
* @param start the lower bound of the range of contests
* @param end the upper bound of the range of contests (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null)
* @return the ordered range of matching contests
* @throws SystemException if a system exception occurred
*/
@Override
public List findByActiveFlag(boolean contestActive, int flag,
int start, int end, OrderByComparator orderByComparator)
throws SystemException {
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_ACTIVEFLAG;
finderArgs = new Object[] { contestActive, flag };
} else {
finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVEFLAG;
finderArgs = new Object[] {
contestActive, flag,
start, end, orderByComparator
};
}
List list = (List) FinderCacheUtil.getResult(finderPath,
finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Contest contest : list) {
if ((contestActive != contest.getContestActive()) ||
(flag != contest.getFlag())) {
list = null;
break;
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 +
(orderByComparator.getOrderByFields().length * 3));
} else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_ACTIVEFLAG_CONTESTACTIVE_2);
query.append(_FINDER_COLUMN_ACTIVEFLAG_FLAG_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
orderByComparator);
} else
if (pagination) {
query.append(ContestModelImpl.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(contestActive);
qPos.add(flag);
if (!pagination) {
list = (List) QueryUtil.list(q, getDialect(),
start, end);
}
cacheResult(list);
FinderCacheUtil.putResult(finderPath, finderArgs, list);
} catch (Exception e) {
FinderCacheUtil.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first contest in the ordered set where contestActive = ? and flag = ?.
*
* @param contestActive the contest active
* @param flag the flag
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the first matching contest
* @throws com.ext.portlet.NoSuchContestException if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest findByActiveFlag_First(boolean contestActive, int flag,
OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = fetchByActiveFlag_First(contestActive, flag,
orderByComparator);
if (contest != null) {
return contest;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("contestActive=");
msg.append(contestActive);
msg.append(", flag=");
msg.append(flag);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchContestException(msg.toString());
}
/**
* Returns the first contest in the ordered set where contestActive = ? and flag = ?.
*
* @param contestActive the contest active
* @param flag the flag
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the first matching contest, or null if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest fetchByActiveFlag_First(boolean contestActive, int flag,
OrderByComparator orderByComparator) throws SystemException {
List list = findByActiveFlag(contestActive, flag, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last contest in the ordered set where contestActive = ? and flag = ?.
*
* @param contestActive the contest active
* @param flag the flag
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the last matching contest
* @throws com.ext.portlet.NoSuchContestException if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest findByActiveFlag_Last(boolean contestActive, int flag,
OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = fetchByActiveFlag_Last(contestActive, flag,
orderByComparator);
if (contest != null) {
return contest;
}
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("contestActive=");
msg.append(contestActive);
msg.append(", flag=");
msg.append(flag);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchContestException(msg.toString());
}
/**
* Returns the last contest in the ordered set where contestActive = ? and flag = ?.
*
* @param contestActive the contest active
* @param flag the flag
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the last matching contest, or null if a matching contest could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest fetchByActiveFlag_Last(boolean contestActive, int flag,
OrderByComparator orderByComparator) throws SystemException {
int count = countByActiveFlag(contestActive, flag);
if (count == 0) {
return null;
}
List list = findByActiveFlag(contestActive, flag, count - 1,
count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the contests before and after the current contest in the ordered set where contestActive = ? and flag = ?.
*
* @param ContestPK the primary key of the current contest
* @param contestActive the contest active
* @param flag the flag
* @param orderByComparator the comparator to order the set by (optionally null)
* @return the previous, current, and next contest
* @throws com.ext.portlet.NoSuchContestException if a contest with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Contest[] findByActiveFlag_PrevAndNext(long ContestPK,
boolean contestActive, int flag, OrderByComparator orderByComparator)
throws NoSuchContestException, SystemException {
Contest contest = findByPrimaryKey(ContestPK);
Session session = null;
try {
session = openSession();
Contest[] array = new ContestImpl[3];
array[0] = getByActiveFlag_PrevAndNext(session, contest,
contestActive, flag, orderByComparator, true);
array[1] = contest;
array[2] = getByActiveFlag_PrevAndNext(session, contest,
contestActive, flag, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
protected Contest getByActiveFlag_PrevAndNext(Session session,
Contest contest, boolean contestActive, int flag,
OrderByComparator orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(6 +
(orderByComparator.getOrderByFields().length * 6));
} else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_CONTEST_WHERE);
query.append(_FINDER_COLUMN_ACTIVEFLAG_CONTESTACTIVE_2);
query.append(_FINDER_COLUMN_ACTIVEFLAG_FLAG_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(ContestModelImpl.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(contestActive);
qPos.add(flag);
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(contest);
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 contests where contestActive = ? and flag = ? from the database.
*
* @param contestActive the contest active
* @param flag the flag
* @throws SystemException if a system exception occurred
*/
@Override
public void removeByActiveFlag(boolean contestActive, int flag)
throws SystemException {
for (Contest contest : findByActiveFlag(contestActive, flag,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
/**
remove(contest);
}
=======
>>>>>>> bab262a1fc6af94ffa98bccaed7bada1bb26df8b
}
|