com.liferay.wiki.service.persistence.impl.WikiPagePersistenceImpl 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.wiki.service.persistence.impl;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.sanitizer.Sanitizer;
import com.liferay.portal.kernel.sanitizer.SanitizerException;
import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import com.liferay.portal.spring.extender.service.ServiceReference;
import com.liferay.wiki.exception.NoSuchPageException;
import com.liferay.wiki.model.WikiPage;
import com.liferay.wiki.model.impl.WikiPageImpl;
import com.liferay.wiki.model.impl.WikiPageModelImpl;
import com.liferay.wiki.service.persistence.WikiPagePersistence;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
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 wiki page service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
public class WikiPagePersistenceImpl
extends BasePersistenceImpl implements WikiPagePersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use WikiPageUtil
to access the wiki page persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
WikiPageImpl.class.getName();
public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List1";
public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List2";
private FinderPath _finderPathWithPaginationFindAll;
private FinderPath _finderPathWithoutPaginationFindAll;
private FinderPath _finderPathCountAll;
private FinderPath _finderPathWithPaginationFindByResourcePrimKey;
private FinderPath _finderPathWithoutPaginationFindByResourcePrimKey;
private FinderPath _finderPathCountByResourcePrimKey;
/**
* Returns all the wiki pages where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @return the matching wiki pages
*/
@Override
public List findByResourcePrimKey(long resourcePrimKey) {
return findByResourcePrimKey(
resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where resourcePrimKey = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByResourcePrimKey(
long resourcePrimKey, int start, int end) {
return findByResourcePrimKey(resourcePrimKey, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByResourcePrimKey(
long resourcePrimKey, int start, int end,
OrderByComparator orderByComparator) {
return findByResourcePrimKey(
resourcePrimKey, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByResourcePrimKey(
long resourcePrimKey, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByResourcePrimKey;
finderArgs = new Object[] {resourcePrimKey};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByResourcePrimKey;
finderArgs = new Object[] {
resourcePrimKey, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if (resourcePrimKey != wikiPage.getResourcePrimKey()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByResourcePrimKey_First(
long resourcePrimKey, OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByResourcePrimKey_First(
resourcePrimKey, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByResourcePrimKey_First(
long resourcePrimKey, OrderByComparator orderByComparator) {
List list = findByResourcePrimKey(
resourcePrimKey, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByResourcePrimKey_Last(
long resourcePrimKey, OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByResourcePrimKey_Last(
resourcePrimKey, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByResourcePrimKey_Last(
long resourcePrimKey, OrderByComparator orderByComparator) {
int count = countByResourcePrimKey(resourcePrimKey);
if (count == 0) {
return null;
}
List list = findByResourcePrimKey(
resourcePrimKey, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = ?.
*
* @param pageId the primary key of the current wiki page
* @param resourcePrimKey the resource prim key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByResourcePrimKey_PrevAndNext(
long pageId, long resourcePrimKey,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByResourcePrimKey_PrevAndNext(
session, wikiPage, resourcePrimKey, orderByComparator, true);
array[1] = wikiPage;
array[2] = getByResourcePrimKey_PrevAndNext(
session, wikiPage, resourcePrimKey, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByResourcePrimKey_PrevAndNext(
Session session, WikiPage wikiPage, long resourcePrimKey,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where resourcePrimKey = ? from the database.
*
* @param resourcePrimKey the resource prim key
*/
@Override
public void removeByResourcePrimKey(long resourcePrimKey) {
for (WikiPage wikiPage :
findByResourcePrimKey(
resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where resourcePrimKey = ?.
*
* @param resourcePrimKey the resource prim key
* @return the number of matching wiki pages
*/
@Override
public int countByResourcePrimKey(long resourcePrimKey) {
FinderPath finderPath = _finderPathCountByResourcePrimKey;
Object[] finderArgs = new Object[] {resourcePrimKey};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String
_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
"wikiPage.resourcePrimKey = ?";
private FinderPath _finderPathWithPaginationFindByUuid;
private FinderPath _finderPathWithoutPaginationFindByUuid;
private FinderPath _finderPathCountByUuid;
/**
* Returns all the wiki pages where uuid = ?.
*
* @param uuid the uuid
* @return the matching wiki pages
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid(uuid, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] {uuid};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] {uuid, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if (!uuid.equals(wikiPage.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByUuid_First(uuid, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByUuid_First(
String uuid, OrderByComparator orderByComparator) {
List list = findByUuid(uuid, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByUuid_Last(uuid, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByUuid_Last(
String uuid, OrderByComparator orderByComparator) {
int count = countByUuid(uuid);
if (count == 0) {
return null;
}
List list = findByUuid(
uuid, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where uuid = ?.
*
* @param pageId the primary key of the current wiki page
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByUuid_PrevAndNext(
long pageId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchPageException {
uuid = Objects.toString(uuid, "");
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByUuid_PrevAndNext(
session, wikiPage, uuid, orderByComparator, true);
array[1] = wikiPage;
array[2] = getByUuid_PrevAndNext(
session, wikiPage, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByUuid_PrevAndNext(
Session session, WikiPage wikiPage, String uuid,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (WikiPage wikiPage :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching wiki pages
*/
@Override
public int countByUuid(String uuid) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid;
Object[] finderArgs = new Object[] {uuid};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"wikiPage.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(wikiPage.uuid IS NULL OR wikiPage.uuid = '')";
private FinderPath _finderPathFetchByUUID_G;
private FinderPath _finderPathCountByUUID_G;
/**
* Returns the wiki page where uuid = ? and groupId = ? or throws a NoSuchPageException
if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByUUID_G(String uuid, long groupId)
throws NoSuchPageException {
WikiPage wikiPage = fetchByUUID_G(uuid, groupId);
if (wikiPage == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", groupId=");
sb.append(groupId);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchPageException(sb.toString());
}
return wikiPage;
}
/**
* Returns the wiki page where uuid = ? and groupId = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
}
/**
* Returns the wiki page where uuid = ? and groupId = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param useFinderCache whether to use the finder cache
* @return the matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByUUID_G(
String uuid, long groupId, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {uuid, groupId};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof WikiPage) {
WikiPage wikiPage = (WikiPage)result;
if (!Objects.equals(uuid, wikiPage.getUuid()) ||
(groupId != wikiPage.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByUUID_G, finderArgs, list);
}
}
else {
WikiPage wikiPage = list.get(0);
result = wikiPage;
cacheResult(wikiPage);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(
_finderPathFetchByUUID_G, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (WikiPage)result;
}
}
/**
* Removes the wiki page where uuid = ? and groupId = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the wiki page that was removed
*/
@Override
public WikiPage removeByUUID_G(String uuid, long groupId)
throws NoSuchPageException {
WikiPage wikiPage = findByUUID_G(uuid, groupId);
return remove(wikiPage);
}
/**
* Returns the number of wiki pages where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching wiki pages
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUUID_G;
Object[] finderArgs = new Object[] {uuid, groupId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_G_UUID_2 =
"wikiPage.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_3 =
"(wikiPage.uuid IS NULL OR wikiPage.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 =
"wikiPage.groupId = ?";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the wiki pages where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching wiki pages
*/
@Override
public List findByUuid_C(String uuid, long companyId) {
return findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end) {
return findByUuid_C(uuid, companyId, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid_C(
uuid, companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] {uuid, companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] {
uuid, companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if (!uuid.equals(wikiPage.getUuid()) ||
(companyId != wikiPage.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator) {
List list = findByUuid_C(
uuid, companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator) {
int count = countByUuid_C(uuid, companyId);
if (count == 0) {
return null;
}
List list = findByUuid_C(
uuid, companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where uuid = ? and companyId = ?.
*
* @param pageId the primary key of the current wiki page
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByUuid_C_PrevAndNext(
long pageId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchPageException {
uuid = Objects.toString(uuid, "");
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, wikiPage, uuid, companyId, orderByComparator, true);
array[1] = wikiPage;
array[2] = getByUuid_C_PrevAndNext(
session, wikiPage, uuid, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByUuid_C_PrevAndNext(
Session session, WikiPage wikiPage, String uuid, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where uuid = ? and companyId = ? from the database.
*
* @param uuid the uuid
* @param companyId the company ID
*/
@Override
public void removeByUuid_C(String uuid, long companyId) {
for (WikiPage wikiPage :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching wiki pages
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid_C;
Object[] finderArgs = new Object[] {uuid, companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"wikiPage.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(wikiPage.uuid IS NULL OR wikiPage.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"wikiPage.companyId = ?";
private FinderPath _finderPathWithPaginationFindByNodeId;
private FinderPath _finderPathWithoutPaginationFindByNodeId;
private FinderPath _finderPathCountByNodeId;
/**
* Returns all the wiki pages where nodeId = ?.
*
* @param nodeId the node ID
* @return the matching wiki pages
*/
@Override
public List findByNodeId(long nodeId) {
return findByNodeId(nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where nodeId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByNodeId(long nodeId, int start, int end) {
return findByNodeId(nodeId, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByNodeId(
long nodeId, int start, int end,
OrderByComparator orderByComparator) {
return findByNodeId(nodeId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByNodeId(
long nodeId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByNodeId;
finderArgs = new Object[] {nodeId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByNodeId;
finderArgs = new Object[] {nodeId, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if (nodeId != wikiPage.getNodeId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_NODEID_NODEID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where nodeId = ?.
*
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByNodeId_First(
long nodeId, OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByNodeId_First(nodeId, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where nodeId = ?.
*
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByNodeId_First(
long nodeId, OrderByComparator orderByComparator) {
List list = findByNodeId(nodeId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where nodeId = ?.
*
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByNodeId_Last(
long nodeId, OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByNodeId_Last(nodeId, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where nodeId = ?.
*
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByNodeId_Last(
long nodeId, OrderByComparator orderByComparator) {
int count = countByNodeId(nodeId);
if (count == 0) {
return null;
}
List list = findByNodeId(
nodeId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = ?.
*
* @param pageId the primary key of the current wiki page
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByNodeId_PrevAndNext(
long pageId, long nodeId,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByNodeId_PrevAndNext(
session, wikiPage, nodeId, orderByComparator, true);
array[1] = wikiPage;
array[2] = getByNodeId_PrevAndNext(
session, wikiPage, nodeId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByNodeId_PrevAndNext(
Session session, WikiPage wikiPage, long nodeId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_NODEID_NODEID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where nodeId = ? from the database.
*
* @param nodeId the node ID
*/
@Override
public void removeByNodeId(long nodeId) {
for (WikiPage wikiPage :
findByNodeId(
nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where nodeId = ?.
*
* @param nodeId the node ID
* @return the number of matching wiki pages
*/
@Override
public int countByNodeId(long nodeId) {
FinderPath finderPath = _finderPathCountByNodeId;
Object[] finderArgs = new Object[] {nodeId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_NODEID_NODEID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_NODEID_NODEID_2 =
"wikiPage.nodeId = ?";
private FinderPath _finderPathWithPaginationFindByFormat;
private FinderPath _finderPathWithoutPaginationFindByFormat;
private FinderPath _finderPathCountByFormat;
/**
* Returns all the wiki pages where format = ?.
*
* @param format the format
* @return the matching wiki pages
*/
@Override
public List findByFormat(String format) {
return findByFormat(format, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where format = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param format the format
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByFormat(String format, int start, int end) {
return findByFormat(format, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where format = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param format the format
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByFormat(
String format, int start, int end,
OrderByComparator orderByComparator) {
return findByFormat(format, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where format = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param format the format
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByFormat(
String format, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
format = Objects.toString(format, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByFormat;
finderArgs = new Object[] {format};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByFormat;
finderArgs = new Object[] {format, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if (!format.equals(wikiPage.getFormat())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
boolean bindFormat = false;
if (format.isEmpty()) {
sb.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
}
else {
bindFormat = true;
sb.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindFormat) {
queryPos.add(format);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where format = ?.
*
* @param format the format
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByFormat_First(
String format, OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByFormat_First(format, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("format=");
sb.append(format);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where format = ?.
*
* @param format the format
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByFormat_First(
String format, OrderByComparator orderByComparator) {
List list = findByFormat(format, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where format = ?.
*
* @param format the format
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByFormat_Last(
String format, OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByFormat_Last(format, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("format=");
sb.append(format);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where format = ?.
*
* @param format the format
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByFormat_Last(
String format, OrderByComparator orderByComparator) {
int count = countByFormat(format);
if (count == 0) {
return null;
}
List list = findByFormat(
format, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where format = ?.
*
* @param pageId the primary key of the current wiki page
* @param format the format
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByFormat_PrevAndNext(
long pageId, String format,
OrderByComparator orderByComparator)
throws NoSuchPageException {
format = Objects.toString(format, "");
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByFormat_PrevAndNext(
session, wikiPage, format, orderByComparator, true);
array[1] = wikiPage;
array[2] = getByFormat_PrevAndNext(
session, wikiPage, format, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByFormat_PrevAndNext(
Session session, WikiPage wikiPage, String format,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
boolean bindFormat = false;
if (format.isEmpty()) {
sb.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
}
else {
bindFormat = true;
sb.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindFormat) {
queryPos.add(format);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where format = ? from the database.
*
* @param format the format
*/
@Override
public void removeByFormat(String format) {
for (WikiPage wikiPage :
findByFormat(
format, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where format = ?.
*
* @param format the format
* @return the number of matching wiki pages
*/
@Override
public int countByFormat(String format) {
format = Objects.toString(format, "");
FinderPath finderPath = _finderPathCountByFormat;
Object[] finderArgs = new Object[] {format};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
boolean bindFormat = false;
if (format.isEmpty()) {
sb.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
}
else {
bindFormat = true;
sb.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindFormat) {
queryPos.add(format);
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_FORMAT_FORMAT_2 =
"wikiPage.format = ?";
private static final String _FINDER_COLUMN_FORMAT_FORMAT_3 =
"(wikiPage.format IS NULL OR wikiPage.format = '')";
private FinderPath _finderPathWithPaginationFindByR_N;
private FinderPath _finderPathWithoutPaginationFindByR_N;
private FinderPath _finderPathCountByR_N;
/**
* Returns all the wiki pages where resourcePrimKey = ? and nodeId = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @return the matching wiki pages
*/
@Override
public List findByR_N(long resourcePrimKey, long nodeId) {
return findByR_N(
resourcePrimKey, nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the wiki pages where resourcePrimKey = ? and nodeId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByR_N(
long resourcePrimKey, long nodeId, int start, int end) {
return findByR_N(resourcePrimKey, nodeId, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ? and nodeId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByR_N(
long resourcePrimKey, long nodeId, int start, int end,
OrderByComparator orderByComparator) {
return findByR_N(
resourcePrimKey, nodeId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ? and nodeId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByR_N(
long resourcePrimKey, long nodeId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByR_N;
finderArgs = new Object[] {resourcePrimKey, nodeId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByR_N;
finderArgs = new Object[] {
resourcePrimKey, nodeId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
(nodeId != wikiPage.getNodeId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_NODEID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ? and nodeId = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_N_First(
long resourcePrimKey, long nodeId,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_N_First(
resourcePrimKey, nodeId, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", nodeId=");
sb.append(nodeId);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ? and nodeId = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_N_First(
long resourcePrimKey, long nodeId,
OrderByComparator orderByComparator) {
List list = findByR_N(
resourcePrimKey, nodeId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ? and nodeId = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_N_Last(
long resourcePrimKey, long nodeId,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_N_Last(
resourcePrimKey, nodeId, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", nodeId=");
sb.append(nodeId);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ? and nodeId = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_N_Last(
long resourcePrimKey, long nodeId,
OrderByComparator orderByComparator) {
int count = countByR_N(resourcePrimKey, nodeId);
if (count == 0) {
return null;
}
List list = findByR_N(
resourcePrimKey, nodeId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = ? and nodeId = ?.
*
* @param pageId the primary key of the current wiki page
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByR_N_PrevAndNext(
long pageId, long resourcePrimKey, long nodeId,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByR_N_PrevAndNext(
session, wikiPage, resourcePrimKey, nodeId, orderByComparator,
true);
array[1] = wikiPage;
array[2] = getByR_N_PrevAndNext(
session, wikiPage, resourcePrimKey, nodeId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByR_N_PrevAndNext(
Session session, WikiPage wikiPage, long resourcePrimKey, long nodeId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_NODEID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where resourcePrimKey = ? and nodeId = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
*/
@Override
public void removeByR_N(long resourcePrimKey, long nodeId) {
for (WikiPage wikiPage :
findByR_N(
resourcePrimKey, nodeId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where resourcePrimKey = ? and nodeId = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @return the number of matching wiki pages
*/
@Override
public int countByR_N(long resourcePrimKey, long nodeId) {
FinderPath finderPath = _finderPathCountByR_N;
Object[] finderArgs = new Object[] {resourcePrimKey, nodeId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_NODEID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_R_N_RESOURCEPRIMKEY_2 =
"wikiPage.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_N_NODEID_2 =
"wikiPage.nodeId = ?";
private FinderPath _finderPathWithPaginationFindByR_S;
private FinderPath _finderPathWithoutPaginationFindByR_S;
private FinderPath _finderPathCountByR_S;
/**
* Returns all the wiki pages where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @return the matching wiki pages
*/
@Override
public List findByR_S(long resourcePrimKey, int status) {
return findByR_S(
resourcePrimKey, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the wiki pages where resourcePrimKey = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByR_S(
long resourcePrimKey, int status, int start, int end) {
return findByR_S(resourcePrimKey, status, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByR_S(
long resourcePrimKey, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByR_S(
resourcePrimKey, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByR_S(
long resourcePrimKey, int status, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByR_S;
finderArgs = new Object[] {resourcePrimKey, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByR_S;
finderArgs = new Object[] {
resourcePrimKey, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
(status != wikiPage.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_S_First(
long resourcePrimKey, int status,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_S_First(
resourcePrimKey, status, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_S_First(
long resourcePrimKey, int status,
OrderByComparator orderByComparator) {
List list = findByR_S(
resourcePrimKey, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_S_Last(
long resourcePrimKey, int status,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_S_Last(
resourcePrimKey, status, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_S_Last(
long resourcePrimKey, int status,
OrderByComparator orderByComparator) {
int count = countByR_S(resourcePrimKey, status);
if (count == 0) {
return null;
}
List list = findByR_S(
resourcePrimKey, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = ? and status = ?.
*
* @param pageId the primary key of the current wiki page
* @param resourcePrimKey the resource prim key
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByR_S_PrevAndNext(
long pageId, long resourcePrimKey, int status,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByR_S_PrevAndNext(
session, wikiPage, resourcePrimKey, status, orderByComparator,
true);
array[1] = wikiPage;
array[2] = getByR_S_PrevAndNext(
session, wikiPage, resourcePrimKey, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByR_S_PrevAndNext(
Session session, WikiPage wikiPage, long resourcePrimKey, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where resourcePrimKey = ? and status = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param status the status
*/
@Override
public void removeByR_S(long resourcePrimKey, int status) {
for (WikiPage wikiPage :
findByR_S(
resourcePrimKey, status, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where resourcePrimKey = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param status the status
* @return the number of matching wiki pages
*/
@Override
public int countByR_S(long resourcePrimKey, int status) {
FinderPath finderPath = _finderPathCountByR_S;
Object[] finderArgs = new Object[] {resourcePrimKey, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_S_STATUS_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_R_S_RESOURCEPRIMKEY_2 =
"wikiPage.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_S_STATUS_2 =
"wikiPage.status = ?";
private FinderPath _finderPathWithPaginationFindByN_T;
private FinderPath _finderPathWithoutPaginationFindByN_T;
private FinderPath _finderPathCountByN_T;
/**
* Returns all the wiki pages where nodeId = ? and title = ?.
*
* @param nodeId the node ID
* @param title the title
* @return the matching wiki pages
*/
@Override
public List findByN_T(long nodeId, String title) {
return findByN_T(
nodeId, title, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where nodeId = ? and title = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param title the title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByN_T(
long nodeId, String title, int start, int end) {
return findByN_T(nodeId, title, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and title = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param title the title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_T(
long nodeId, String title, int start, int end,
OrderByComparator orderByComparator) {
return findByN_T(nodeId, title, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and title = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param title the title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_T(
long nodeId, String title, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
title = Objects.toString(title, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByN_T;
finderArgs = new Object[] {nodeId, title};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByN_T;
finderArgs = new Object[] {
nodeId, title, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((nodeId != wikiPage.getNodeId()) ||
!title.equals(wikiPage.getTitle())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_T_NODEID_2);
boolean bindTitle = false;
if (title.isEmpty()) {
sb.append(_FINDER_COLUMN_N_T_TITLE_3);
}
else {
bindTitle = true;
sb.append(_FINDER_COLUMN_N_T_TITLE_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindTitle) {
queryPos.add(StringUtil.toLowerCase(title));
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and title = ?.
*
* @param nodeId the node ID
* @param title the title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_T_First(
long nodeId, String title,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_T_First(nodeId, title, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", title=");
sb.append(title);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and title = ?.
*
* @param nodeId the node ID
* @param title the title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_T_First(
long nodeId, String title,
OrderByComparator orderByComparator) {
List list = findByN_T(nodeId, title, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and title = ?.
*
* @param nodeId the node ID
* @param title the title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_T_Last(
long nodeId, String title,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_T_Last(nodeId, title, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", title=");
sb.append(title);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and title = ?.
*
* @param nodeId the node ID
* @param title the title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_T_Last(
long nodeId, String title,
OrderByComparator orderByComparator) {
int count = countByN_T(nodeId, title);
if (count == 0) {
return null;
}
List list = findByN_T(
nodeId, title, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = ? and title = ?.
*
* @param pageId the primary key of the current wiki page
* @param nodeId the node ID
* @param title the title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByN_T_PrevAndNext(
long pageId, long nodeId, String title,
OrderByComparator orderByComparator)
throws NoSuchPageException {
title = Objects.toString(title, "");
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByN_T_PrevAndNext(
session, wikiPage, nodeId, title, orderByComparator, true);
array[1] = wikiPage;
array[2] = getByN_T_PrevAndNext(
session, wikiPage, nodeId, title, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByN_T_PrevAndNext(
Session session, WikiPage wikiPage, long nodeId, String title,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_T_NODEID_2);
boolean bindTitle = false;
if (title.isEmpty()) {
sb.append(_FINDER_COLUMN_N_T_TITLE_3);
}
else {
bindTitle = true;
sb.append(_FINDER_COLUMN_N_T_TITLE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindTitle) {
queryPos.add(StringUtil.toLowerCase(title));
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where nodeId = ? and title = ? from the database.
*
* @param nodeId the node ID
* @param title the title
*/
@Override
public void removeByN_T(long nodeId, String title) {
for (WikiPage wikiPage :
findByN_T(
nodeId, title, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where nodeId = ? and title = ?.
*
* @param nodeId the node ID
* @param title the title
* @return the number of matching wiki pages
*/
@Override
public int countByN_T(long nodeId, String title) {
title = Objects.toString(title, "");
FinderPath finderPath = _finderPathCountByN_T;
Object[] finderArgs = new Object[] {nodeId, title};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_T_NODEID_2);
boolean bindTitle = false;
if (title.isEmpty()) {
sb.append(_FINDER_COLUMN_N_T_TITLE_3);
}
else {
bindTitle = true;
sb.append(_FINDER_COLUMN_N_T_TITLE_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindTitle) {
queryPos.add(StringUtil.toLowerCase(title));
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_N_T_NODEID_2 =
"wikiPage.nodeId = ? AND ";
private static final String _FINDER_COLUMN_N_T_TITLE_2 =
"lower(wikiPage.title) = ?";
private static final String _FINDER_COLUMN_N_T_TITLE_3 =
"(wikiPage.title IS NULL OR wikiPage.title = '')";
private FinderPath _finderPathWithPaginationFindByN_H;
private FinderPath _finderPathWithoutPaginationFindByN_H;
private FinderPath _finderPathCountByN_H;
/**
* Returns all the wiki pages where nodeId = ? and head = ?.
*
* @param nodeId the node ID
* @param head the head
* @return the matching wiki pages
*/
@Override
public List findByN_H(long nodeId, boolean head) {
return findByN_H(
nodeId, head, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where nodeId = ? and head = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param head the head
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByN_H(
long nodeId, boolean head, int start, int end) {
return findByN_H(nodeId, head, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and head = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param head the head
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_H(
long nodeId, boolean head, int start, int end,
OrderByComparator orderByComparator) {
return findByN_H(nodeId, head, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and head = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param head the head
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_H(
long nodeId, boolean head, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByN_H;
finderArgs = new Object[] {nodeId, head};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByN_H;
finderArgs = new Object[] {
nodeId, head, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((nodeId != wikiPage.getNodeId()) ||
(head != wikiPage.isHead())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_H_NODEID_2);
sb.append(_FINDER_COLUMN_N_H_HEAD_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
queryPos.add(head);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and head = ?.
*
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_H_First(
long nodeId, boolean head,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_H_First(nodeId, head, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", head=");
sb.append(head);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and head = ?.
*
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_H_First(
long nodeId, boolean head,
OrderByComparator orderByComparator) {
List list = findByN_H(nodeId, head, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and head = ?.
*
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_H_Last(
long nodeId, boolean head,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_H_Last(nodeId, head, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", head=");
sb.append(head);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and head = ?.
*
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_H_Last(
long nodeId, boolean head,
OrderByComparator orderByComparator) {
int count = countByN_H(nodeId, head);
if (count == 0) {
return null;
}
List list = findByN_H(
nodeId, head, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = ? and head = ?.
*
* @param pageId the primary key of the current wiki page
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByN_H_PrevAndNext(
long pageId, long nodeId, boolean head,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByN_H_PrevAndNext(
session, wikiPage, nodeId, head, orderByComparator, true);
array[1] = wikiPage;
array[2] = getByN_H_PrevAndNext(
session, wikiPage, nodeId, head, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByN_H_PrevAndNext(
Session session, WikiPage wikiPage, long nodeId, boolean head,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_H_NODEID_2);
sb.append(_FINDER_COLUMN_N_H_HEAD_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
queryPos.add(head);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where nodeId = ? and head = ? from the database.
*
* @param nodeId the node ID
* @param head the head
*/
@Override
public void removeByN_H(long nodeId, boolean head) {
for (WikiPage wikiPage :
findByN_H(
nodeId, head, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where nodeId = ? and head = ?.
*
* @param nodeId the node ID
* @param head the head
* @return the number of matching wiki pages
*/
@Override
public int countByN_H(long nodeId, boolean head) {
FinderPath finderPath = _finderPathCountByN_H;
Object[] finderArgs = new Object[] {nodeId, head};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_H_NODEID_2);
sb.append(_FINDER_COLUMN_N_H_HEAD_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
queryPos.add(head);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_N_H_NODEID_2 =
"wikiPage.nodeId = ? AND ";
private static final String _FINDER_COLUMN_N_H_HEAD_2 = "wikiPage.head = ?";
private FinderPath _finderPathWithPaginationFindByN_P;
private FinderPath _finderPathWithoutPaginationFindByN_P;
private FinderPath _finderPathCountByN_P;
/**
* Returns all the wiki pages where nodeId = ? and parentTitle = ?.
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @return the matching wiki pages
*/
@Override
public List findByN_P(long nodeId, String parentTitle) {
return findByN_P(
nodeId, parentTitle, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where nodeId = ? and parentTitle = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByN_P(
long nodeId, String parentTitle, int start, int end) {
return findByN_P(nodeId, parentTitle, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and parentTitle = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_P(
long nodeId, String parentTitle, int start, int end,
OrderByComparator orderByComparator) {
return findByN_P(
nodeId, parentTitle, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and parentTitle = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_P(
long nodeId, String parentTitle, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
parentTitle = Objects.toString(parentTitle, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByN_P;
finderArgs = new Object[] {nodeId, parentTitle};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByN_P;
finderArgs = new Object[] {
nodeId, parentTitle, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((nodeId != wikiPage.getNodeId()) ||
!parentTitle.equals(wikiPage.getParentTitle())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_P_NODEID_2);
boolean bindParentTitle = false;
if (parentTitle.isEmpty()) {
sb.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
}
else {
bindParentTitle = true;
sb.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindParentTitle) {
queryPos.add(StringUtil.toLowerCase(parentTitle));
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and parentTitle = ?.
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_P_First(
long nodeId, String parentTitle,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_P_First(
nodeId, parentTitle, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", parentTitle=");
sb.append(parentTitle);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and parentTitle = ?.
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_P_First(
long nodeId, String parentTitle,
OrderByComparator orderByComparator) {
List list = findByN_P(
nodeId, parentTitle, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and parentTitle = ?.
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_P_Last(
long nodeId, String parentTitle,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_P_Last(
nodeId, parentTitle, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", parentTitle=");
sb.append(parentTitle);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and parentTitle = ?.
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_P_Last(
long nodeId, String parentTitle,
OrderByComparator orderByComparator) {
int count = countByN_P(nodeId, parentTitle);
if (count == 0) {
return null;
}
List list = findByN_P(
nodeId, parentTitle, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = ? and parentTitle = ?.
*
* @param pageId the primary key of the current wiki page
* @param nodeId the node ID
* @param parentTitle the parent title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByN_P_PrevAndNext(
long pageId, long nodeId, String parentTitle,
OrderByComparator orderByComparator)
throws NoSuchPageException {
parentTitle = Objects.toString(parentTitle, "");
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByN_P_PrevAndNext(
session, wikiPage, nodeId, parentTitle, orderByComparator,
true);
array[1] = wikiPage;
array[2] = getByN_P_PrevAndNext(
session, wikiPage, nodeId, parentTitle, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByN_P_PrevAndNext(
Session session, WikiPage wikiPage, long nodeId, String parentTitle,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_P_NODEID_2);
boolean bindParentTitle = false;
if (parentTitle.isEmpty()) {
sb.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
}
else {
bindParentTitle = true;
sb.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindParentTitle) {
queryPos.add(StringUtil.toLowerCase(parentTitle));
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where nodeId = ? and parentTitle = ? from the database.
*
* @param nodeId the node ID
* @param parentTitle the parent title
*/
@Override
public void removeByN_P(long nodeId, String parentTitle) {
for (WikiPage wikiPage :
findByN_P(
nodeId, parentTitle, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where nodeId = ? and parentTitle = ?.
*
* @param nodeId the node ID
* @param parentTitle the parent title
* @return the number of matching wiki pages
*/
@Override
public int countByN_P(long nodeId, String parentTitle) {
parentTitle = Objects.toString(parentTitle, "");
FinderPath finderPath = _finderPathCountByN_P;
Object[] finderArgs = new Object[] {nodeId, parentTitle};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_P_NODEID_2);
boolean bindParentTitle = false;
if (parentTitle.isEmpty()) {
sb.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
}
else {
bindParentTitle = true;
sb.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindParentTitle) {
queryPos.add(StringUtil.toLowerCase(parentTitle));
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_N_P_NODEID_2 =
"wikiPage.nodeId = ? AND ";
private static final String _FINDER_COLUMN_N_P_PARENTTITLE_2 =
"lower(wikiPage.parentTitle) = ?";
private static final String _FINDER_COLUMN_N_P_PARENTTITLE_3 =
"(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = '')";
private FinderPath _finderPathWithPaginationFindByN_R;
private FinderPath _finderPathWithoutPaginationFindByN_R;
private FinderPath _finderPathCountByN_R;
/**
* Returns all the wiki pages where nodeId = ? and redirectTitle = ?.
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @return the matching wiki pages
*/
@Override
public List findByN_R(long nodeId, String redirectTitle) {
return findByN_R(
nodeId, redirectTitle, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where nodeId = ? and redirectTitle = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByN_R(
long nodeId, String redirectTitle, int start, int end) {
return findByN_R(nodeId, redirectTitle, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and redirectTitle = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_R(
long nodeId, String redirectTitle, int start, int end,
OrderByComparator orderByComparator) {
return findByN_R(
nodeId, redirectTitle, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and redirectTitle = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_R(
long nodeId, String redirectTitle, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
redirectTitle = Objects.toString(redirectTitle, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByN_R;
finderArgs = new Object[] {nodeId, redirectTitle};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByN_R;
finderArgs = new Object[] {
nodeId, redirectTitle, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((nodeId != wikiPage.getNodeId()) ||
!redirectTitle.equals(wikiPage.getRedirectTitle())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_R_NODEID_2);
boolean bindRedirectTitle = false;
if (redirectTitle.isEmpty()) {
sb.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
}
else {
bindRedirectTitle = true;
sb.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindRedirectTitle) {
queryPos.add(StringUtil.toLowerCase(redirectTitle));
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and redirectTitle = ?.
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_R_First(
long nodeId, String redirectTitle,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_R_First(
nodeId, redirectTitle, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", redirectTitle=");
sb.append(redirectTitle);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and redirectTitle = ?.
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_R_First(
long nodeId, String redirectTitle,
OrderByComparator orderByComparator) {
List list = findByN_R(
nodeId, redirectTitle, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and redirectTitle = ?.
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_R_Last(
long nodeId, String redirectTitle,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_R_Last(
nodeId, redirectTitle, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", redirectTitle=");
sb.append(redirectTitle);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and redirectTitle = ?.
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_R_Last(
long nodeId, String redirectTitle,
OrderByComparator orderByComparator) {
int count = countByN_R(nodeId, redirectTitle);
if (count == 0) {
return null;
}
List list = findByN_R(
nodeId, redirectTitle, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = ? and redirectTitle = ?.
*
* @param pageId the primary key of the current wiki page
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByN_R_PrevAndNext(
long pageId, long nodeId, String redirectTitle,
OrderByComparator orderByComparator)
throws NoSuchPageException {
redirectTitle = Objects.toString(redirectTitle, "");
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByN_R_PrevAndNext(
session, wikiPage, nodeId, redirectTitle, orderByComparator,
true);
array[1] = wikiPage;
array[2] = getByN_R_PrevAndNext(
session, wikiPage, nodeId, redirectTitle, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByN_R_PrevAndNext(
Session session, WikiPage wikiPage, long nodeId, String redirectTitle,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_R_NODEID_2);
boolean bindRedirectTitle = false;
if (redirectTitle.isEmpty()) {
sb.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
}
else {
bindRedirectTitle = true;
sb.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindRedirectTitle) {
queryPos.add(StringUtil.toLowerCase(redirectTitle));
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where nodeId = ? and redirectTitle = ? from the database.
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
*/
@Override
public void removeByN_R(long nodeId, String redirectTitle) {
for (WikiPage wikiPage :
findByN_R(
nodeId, redirectTitle, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where nodeId = ? and redirectTitle = ?.
*
* @param nodeId the node ID
* @param redirectTitle the redirect title
* @return the number of matching wiki pages
*/
@Override
public int countByN_R(long nodeId, String redirectTitle) {
redirectTitle = Objects.toString(redirectTitle, "");
FinderPath finderPath = _finderPathCountByN_R;
Object[] finderArgs = new Object[] {nodeId, redirectTitle};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_R_NODEID_2);
boolean bindRedirectTitle = false;
if (redirectTitle.isEmpty()) {
sb.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
}
else {
bindRedirectTitle = true;
sb.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
if (bindRedirectTitle) {
queryPos.add(StringUtil.toLowerCase(redirectTitle));
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_N_R_NODEID_2 =
"wikiPage.nodeId = ? AND ";
private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_2 =
"lower(wikiPage.redirectTitle) = ?";
private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_3 =
"(wikiPage.redirectTitle IS NULL OR wikiPage.redirectTitle = '')";
private FinderPath _finderPathWithPaginationFindByN_S;
private FinderPath _finderPathWithoutPaginationFindByN_S;
private FinderPath _finderPathCountByN_S;
/**
* Returns all the wiki pages where nodeId = ? and status = ?.
*
* @param nodeId the node ID
* @param status the status
* @return the matching wiki pages
*/
@Override
public List findByN_S(long nodeId, int status) {
return findByN_S(
nodeId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where nodeId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByN_S(
long nodeId, int status, int start, int end) {
return findByN_S(nodeId, status, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_S(
long nodeId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByN_S(nodeId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where nodeId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param nodeId the node ID
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByN_S(
long nodeId, int status, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByN_S;
finderArgs = new Object[] {nodeId, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByN_S;
finderArgs = new Object[] {
nodeId, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((nodeId != wikiPage.getNodeId()) ||
(status != wikiPage.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_S_NODEID_2);
sb.append(_FINDER_COLUMN_N_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and status = ?.
*
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_S_First(
long nodeId, int status,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_S_First(nodeId, status, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where nodeId = ? and status = ?.
*
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_S_First(
long nodeId, int status,
OrderByComparator orderByComparator) {
List list = findByN_S(
nodeId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and status = ?.
*
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByN_S_Last(
long nodeId, int status,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByN_S_Last(nodeId, status, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("nodeId=");
sb.append(nodeId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where nodeId = ? and status = ?.
*
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByN_S_Last(
long nodeId, int status,
OrderByComparator orderByComparator) {
int count = countByN_S(nodeId, status);
if (count == 0) {
return null;
}
List list = findByN_S(
nodeId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where nodeId = ? and status = ?.
*
* @param pageId the primary key of the current wiki page
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByN_S_PrevAndNext(
long pageId, long nodeId, int status,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByN_S_PrevAndNext(
session, wikiPage, nodeId, status, orderByComparator, true);
array[1] = wikiPage;
array[2] = getByN_S_PrevAndNext(
session, wikiPage, nodeId, status, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByN_S_PrevAndNext(
Session session, WikiPage wikiPage, long nodeId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_S_NODEID_2);
sb.append(_FINDER_COLUMN_N_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where nodeId = ? and status = ? from the database.
*
* @param nodeId the node ID
* @param status the status
*/
@Override
public void removeByN_S(long nodeId, int status) {
for (WikiPage wikiPage :
findByN_S(
nodeId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where nodeId = ? and status = ?.
*
* @param nodeId the node ID
* @param status the status
* @return the number of matching wiki pages
*/
@Override
public int countByN_S(long nodeId, int status) {
FinderPath finderPath = _finderPathCountByN_S;
Object[] finderArgs = new Object[] {nodeId, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_N_S_NODEID_2);
sb.append(_FINDER_COLUMN_N_S_STATUS_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(nodeId);
queryPos.add(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_N_S_NODEID_2 =
"wikiPage.nodeId = ? AND ";
private static final String _FINDER_COLUMN_N_S_STATUS_2 =
"wikiPage.status = ?";
private FinderPath _finderPathFetchByR_N_V;
private FinderPath _finderPathCountByR_N_V;
/**
* Returns the wiki page where resourcePrimKey = ? and nodeId = ? and version = ? or throws a NoSuchPageException
if it could not be found.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param version the version
* @return the matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_N_V(
long resourcePrimKey, long nodeId, double version)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_N_V(resourcePrimKey, nodeId, version);
if (wikiPage == null) {
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", nodeId=");
sb.append(nodeId);
sb.append(", version=");
sb.append(version);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchPageException(sb.toString());
}
return wikiPage;
}
/**
* Returns the wiki page where resourcePrimKey = ? and nodeId = ? and version = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param version the version
* @return the matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_N_V(
long resourcePrimKey, long nodeId, double version) {
return fetchByR_N_V(resourcePrimKey, nodeId, version, true);
}
/**
* Returns the wiki page where resourcePrimKey = ? and nodeId = ? and version = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param version the version
* @param useFinderCache whether to use the finder cache
* @return the matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_N_V(
long resourcePrimKey, long nodeId, double version,
boolean useFinderCache) {
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {resourcePrimKey, nodeId, version};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByR_N_V, finderArgs, this);
}
if (result instanceof WikiPage) {
WikiPage wikiPage = (WikiPage)result;
if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
(nodeId != wikiPage.getNodeId()) ||
(version != wikiPage.getVersion())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(5);
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_V_NODEID_2);
sb.append(_FINDER_COLUMN_R_N_V_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
queryPos.add(version);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByR_N_V, finderArgs, list);
}
}
else {
WikiPage wikiPage = list.get(0);
result = wikiPage;
cacheResult(wikiPage);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(
_finderPathFetchByR_N_V, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (WikiPage)result;
}
}
/**
* Removes the wiki page where resourcePrimKey = ? and nodeId = ? and version = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param version the version
* @return the wiki page that was removed
*/
@Override
public WikiPage removeByR_N_V(
long resourcePrimKey, long nodeId, double version)
throws NoSuchPageException {
WikiPage wikiPage = findByR_N_V(resourcePrimKey, nodeId, version);
return remove(wikiPage);
}
/**
* Returns the number of wiki pages where resourcePrimKey = ? and nodeId = ? and version = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param version the version
* @return the number of matching wiki pages
*/
@Override
public int countByR_N_V(long resourcePrimKey, long nodeId, double version) {
FinderPath finderPath = _finderPathCountByR_N_V;
Object[] finderArgs = new Object[] {resourcePrimKey, nodeId, version};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_V_NODEID_2);
sb.append(_FINDER_COLUMN_R_N_V_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
queryPos.add(version);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_R_N_V_RESOURCEPRIMKEY_2 =
"wikiPage.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_N_V_NODEID_2 =
"wikiPage.nodeId = ? AND ";
private static final String _FINDER_COLUMN_R_N_V_VERSION_2 =
"wikiPage.version = ?";
private FinderPath _finderPathWithPaginationFindByR_N_H;
private FinderPath _finderPathWithoutPaginationFindByR_N_H;
private FinderPath _finderPathCountByR_N_H;
/**
* Returns all the wiki pages where resourcePrimKey = ? and nodeId = ? and head = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @return the matching wiki pages
*/
@Override
public List findByR_N_H(
long resourcePrimKey, long nodeId, boolean head) {
return findByR_N_H(
resourcePrimKey, nodeId, head, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the wiki pages where resourcePrimKey = ? and nodeId = ? and head = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByR_N_H(
long resourcePrimKey, long nodeId, boolean head, int start, int end) {
return findByR_N_H(resourcePrimKey, nodeId, head, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ? and nodeId = ? and head = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByR_N_H(
long resourcePrimKey, long nodeId, boolean head, int start, int end,
OrderByComparator orderByComparator) {
return findByR_N_H(
resourcePrimKey, nodeId, head, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ? and nodeId = ? and head = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByR_N_H(
long resourcePrimKey, long nodeId, boolean head, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByR_N_H;
finderArgs = new Object[] {resourcePrimKey, nodeId, head};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByR_N_H;
finderArgs = new Object[] {
resourcePrimKey, nodeId, head, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
(nodeId != wikiPage.getNodeId()) ||
(head != wikiPage.isHead())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_H_NODEID_2);
sb.append(_FINDER_COLUMN_R_N_H_HEAD_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
queryPos.add(head);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and head = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_N_H_First(
long resourcePrimKey, long nodeId, boolean head,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_N_H_First(
resourcePrimKey, nodeId, head, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", nodeId=");
sb.append(nodeId);
sb.append(", head=");
sb.append(head);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and head = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_N_H_First(
long resourcePrimKey, long nodeId, boolean head,
OrderByComparator orderByComparator) {
List list = findByR_N_H(
resourcePrimKey, nodeId, head, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and head = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_N_H_Last(
long resourcePrimKey, long nodeId, boolean head,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_N_H_Last(
resourcePrimKey, nodeId, head, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", nodeId=");
sb.append(nodeId);
sb.append(", head=");
sb.append(head);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and head = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_N_H_Last(
long resourcePrimKey, long nodeId, boolean head,
OrderByComparator orderByComparator) {
int count = countByR_N_H(resourcePrimKey, nodeId, head);
if (count == 0) {
return null;
}
List list = findByR_N_H(
resourcePrimKey, nodeId, head, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the wiki pages before and after the current wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and head = ?.
*
* @param pageId the primary key of the current wiki page
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next wiki page
* @throws NoSuchPageException if a wiki page with the primary key could not be found
*/
@Override
public WikiPage[] findByR_N_H_PrevAndNext(
long pageId, long resourcePrimKey, long nodeId, boolean head,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = findByPrimaryKey(pageId);
Session session = null;
try {
session = openSession();
WikiPage[] array = new WikiPageImpl[3];
array[0] = getByR_N_H_PrevAndNext(
session, wikiPage, resourcePrimKey, nodeId, head,
orderByComparator, true);
array[1] = wikiPage;
array[2] = getByR_N_H_PrevAndNext(
session, wikiPage, resourcePrimKey, nodeId, head,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected WikiPage getByR_N_H_PrevAndNext(
Session session, WikiPage wikiPage, long resourcePrimKey, long nodeId,
boolean head, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_H_NODEID_2);
sb.append(_FINDER_COLUMN_R_N_H_HEAD_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
queryPos.add(head);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(wikiPage)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the wiki pages where resourcePrimKey = ? and nodeId = ? and head = ? from the database.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
*/
@Override
public void removeByR_N_H(long resourcePrimKey, long nodeId, boolean head) {
for (WikiPage wikiPage :
findByR_N_H(
resourcePrimKey, nodeId, head, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(wikiPage);
}
}
/**
* Returns the number of wiki pages where resourcePrimKey = ? and nodeId = ? and head = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param head the head
* @return the number of matching wiki pages
*/
@Override
public int countByR_N_H(long resourcePrimKey, long nodeId, boolean head) {
FinderPath finderPath = _finderPathCountByR_N_H;
Object[] finderArgs = new Object[] {resourcePrimKey, nodeId, head};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_H_NODEID_2);
sb.append(_FINDER_COLUMN_R_N_H_HEAD_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
queryPos.add(head);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_R_N_H_RESOURCEPRIMKEY_2 =
"wikiPage.resourcePrimKey = ? AND ";
private static final String _FINDER_COLUMN_R_N_H_NODEID_2 =
"wikiPage.nodeId = ? AND ";
private static final String _FINDER_COLUMN_R_N_H_HEAD_2 =
"wikiPage.head = ?";
private FinderPath _finderPathWithPaginationFindByR_N_S;
private FinderPath _finderPathWithoutPaginationFindByR_N_S;
private FinderPath _finderPathCountByR_N_S;
/**
* Returns all the wiki pages where resourcePrimKey = ? and nodeId = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param status the status
* @return the matching wiki pages
*/
@Override
public List findByR_N_S(
long resourcePrimKey, long nodeId, int status) {
return findByR_N_S(
resourcePrimKey, nodeId, status, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the wiki pages where resourcePrimKey = ? and nodeId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @return the range of matching wiki pages
*/
@Override
public List findByR_N_S(
long resourcePrimKey, long nodeId, int status, int start, int end) {
return findByR_N_S(resourcePrimKey, nodeId, status, start, end, null);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ? and nodeId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching wiki pages
*/
@Override
public List findByR_N_S(
long resourcePrimKey, long nodeId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByR_N_S(
resourcePrimKey, nodeId, status, start, end, orderByComparator,
true);
}
/**
* Returns an ordered range of all the wiki pages where resourcePrimKey = ? and nodeId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from WikiPageModelImpl
.
*
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param status the status
* @param start the lower bound of the range of wiki pages
* @param end the upper bound of the range of wiki pages (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching wiki pages
*/
@Override
public List findByR_N_S(
long resourcePrimKey, long nodeId, int status, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByR_N_S;
finderArgs = new Object[] {resourcePrimKey, nodeId, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByR_N_S;
finderArgs = new Object[] {
resourcePrimKey, nodeId, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (WikiPage wikiPage : list) {
if ((resourcePrimKey != wikiPage.getResourcePrimKey()) ||
(nodeId != wikiPage.getNodeId()) ||
(status != wikiPage.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_WIKIPAGE_WHERE);
sb.append(_FINDER_COLUMN_R_N_S_RESOURCEPRIMKEY_2);
sb.append(_FINDER_COLUMN_R_N_S_NODEID_2);
sb.append(_FINDER_COLUMN_R_N_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(WikiPageModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(resourcePrimKey);
queryPos.add(nodeId);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_N_S_First(
long resourcePrimKey, long nodeId, int status,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_N_S_First(
resourcePrimKey, nodeId, status, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", nodeId=");
sb.append(nodeId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the first wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_N_S_First(
long resourcePrimKey, long nodeId, int status,
OrderByComparator orderByComparator) {
List list = findByR_N_S(
resourcePrimKey, nodeId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page
* @throws NoSuchPageException if a matching wiki page could not be found
*/
@Override
public WikiPage findByR_N_S_Last(
long resourcePrimKey, long nodeId, int status,
OrderByComparator orderByComparator)
throws NoSuchPageException {
WikiPage wikiPage = fetchByR_N_S_Last(
resourcePrimKey, nodeId, status, orderByComparator);
if (wikiPage != null) {
return wikiPage;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("resourcePrimKey=");
sb.append(resourcePrimKey);
sb.append(", nodeId=");
sb.append(nodeId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchPageException(sb.toString());
}
/**
* Returns the last wiki page in the ordered set where resourcePrimKey = ? and nodeId = ? and status = ?.
*
* @param resourcePrimKey the resource prim key
* @param nodeId the node ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching wiki page, or null
if a matching wiki page could not be found
*/
@Override
public WikiPage fetchByR_N_S_Last(
long resourcePrimKey, long nodeId, int status,
OrderByComparator orderByComparator) {
int count = countByR_N_S(resourcePrimKey, nodeId, status);
if (count == 0) {
return null;
}
List