
com.liferay.search.experiences.service.persistence.impl.SXPElementPersistenceImpl Maven / Gradle / Ivy
Show all versions of com.liferay.search.experiences.service
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.search.experiences.service.persistence.impl;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.sanitizer.Sanitizer;
import com.liferay.portal.kernel.sanitizer.SanitizerException;
import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import com.liferay.search.experiences.exception.DuplicateSXPElementExternalReferenceCodeException;
import com.liferay.search.experiences.exception.NoSuchSXPElementException;
import com.liferay.search.experiences.model.SXPElement;
import com.liferay.search.experiences.model.SXPElementTable;
import com.liferay.search.experiences.model.impl.SXPElementImpl;
import com.liferay.search.experiences.model.impl.SXPElementModelImpl;
import com.liferay.search.experiences.service.persistence.SXPElementPersistence;
import com.liferay.search.experiences.service.persistence.SXPElementUtil;
import com.liferay.search.experiences.service.persistence.impl.constants.SXPPersistenceConstants;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.sql.DataSource;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* The persistence implementation for the sxp element service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
@Component(service = SXPElementPersistence.class)
public class SXPElementPersistenceImpl
extends BasePersistenceImpl implements SXPElementPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use SXPElementUtil
to access the sxp element persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
SXPElementImpl.class.getName();
public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List1";
public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List2";
private FinderPath _finderPathWithPaginationFindAll;
private FinderPath _finderPathWithoutPaginationFindAll;
private FinderPath _finderPathCountAll;
private FinderPath _finderPathWithPaginationFindByUuid;
private FinderPath _finderPathWithoutPaginationFindByUuid;
private FinderPath _finderPathCountByUuid;
/**
* Returns all the sxp elements where uuid = ?.
*
* @param uuid the uuid
* @return the matching sxp elements
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements
*/
@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 sxp elements 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (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 sxp elements
*/
@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 (SXPElement sxpElement : list) {
if (!uuid.equals(sxpElement.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_SXPELEMENT_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(SXPElementModelImpl.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) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first sxp element 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 sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByUuid_First(uuid, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the first sxp element 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 sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement 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 sxp element 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 sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByUuid_Last(uuid, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the last sxp element 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 sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement 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 sxp elements before and after the current sxp element in the ordered set where uuid = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] findByUuid_PrevAndNext(
long sxpElementId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
uuid = Objects.toString(uuid, "");
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = getByUuid_PrevAndNext(
session, sxpElement, uuid, orderByComparator, true);
array[1] = sxpElement;
array[2] = getByUuid_PrevAndNext(
session, sxpElement, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement getByUuid_PrevAndNext(
Session session, SXPElement sxpElement, 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_SXPELEMENT_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(SXPElementModelImpl.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(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the sxp elements that the user has permission to view where uuid = ?.
*
* @param uuid the uuid
* @return the matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByUuid(String uuid) {
return filterFindByUuid(
uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements that the user has permission to view 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByUuid(String uuid, int start, int end) {
return filterFindByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements that the user has permissions to view 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled()) {
return findByUuid(uuid, start, end, orderByComparator);
}
uuid = Objects.toString(uuid, "");
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
}
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set of sxp elements that the user has permission to view where uuid = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] filterFindByUuid_PrevAndNext(
long sxpElementId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
if (!InlineSQLHelperUtil.isEnabled()) {
return findByUuid_PrevAndNext(
sxpElementId, uuid, orderByComparator);
}
uuid = Objects.toString(uuid, "");
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = filterGetByUuid_PrevAndNext(
session, sxpElement, uuid, orderByComparator, true);
array[1] = sxpElement;
array[2] = filterGetByUuid_PrevAndNext(
session, sxpElement, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement filterGetByUuid_PrevAndNext(
Session session, SXPElement sxpElement, String uuid,
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);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
}
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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 {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the sxp elements where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (SXPElement sxpElement :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(sxpElement);
}
}
/**
* Returns the number of sxp elements where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching sxp elements
*/
@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_SXPELEMENT_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) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of sxp elements that the user has permission to view where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching sxp elements that the user has permission to view
*/
@Override
public int filterCountByUuid(String uuid) {
if (!InlineSQLHelperUtil.isEnabled()) {
return countByUuid(uuid);
}
uuid = Objects.toString(uuid, "");
StringBundler sb = new StringBundler(2);
sb.append(_FILTER_SQL_COUNT_SXPELEMENT_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"sxpElement.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(sxpElement.uuid IS NULL OR sxpElement.uuid = '')";
private static final String _FINDER_COLUMN_UUID_UUID_2_SQL =
"sxpElement.uuid_ = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3_SQL =
"(sxpElement.uuid_ IS NULL OR sxpElement.uuid_ = '')";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the sxp elements where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching sxp elements
*/
@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 sxp elements 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements
*/
@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 sxp elements 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements
*/
@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 sxp elements 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (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 sxp elements
*/
@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 (SXPElement sxpElement : list) {
if (!uuid.equals(sxpElement.getUuid()) ||
(companyId != sxpElement.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_SXPELEMENT_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(SXPElementModelImpl.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) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first sxp element 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 sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
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 NoSuchSXPElementException(sb.toString());
}
/**
* Returns the first sxp element 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 sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement 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 sxp element 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 sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
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 NoSuchSXPElementException(sb.toString());
}
/**
* Returns the last sxp element 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 sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement 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 sxp elements before and after the current sxp element in the ordered set where uuid = ? and companyId = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @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 sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] findByUuid_C_PrevAndNext(
long sxpElementId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
uuid = Objects.toString(uuid, "");
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, sxpElement, uuid, companyId, orderByComparator, true);
array[1] = sxpElement;
array[2] = getByUuid_C_PrevAndNext(
session, sxpElement, uuid, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement getByUuid_C_PrevAndNext(
Session session, SXPElement sxpElement, 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_SXPELEMENT_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(SXPElementModelImpl.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(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the sxp elements that the user has permission to view where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByUuid_C(String uuid, long companyId) {
return filterFindByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements that the user has permission to view 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByUuid_C(
String uuid, long companyId, int start, int end) {
return filterFindByUuid_C(uuid, companyId, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements that the user has permissions to view 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 SXPElementModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByUuid_C(uuid, companyId, start, end, orderByComparator);
}
uuid = Objects.toString(uuid, "");
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set of sxp elements that the user has permission to view where uuid = ? and companyId = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @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 sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] filterFindByUuid_C_PrevAndNext(
long sxpElementId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByUuid_C_PrevAndNext(
sxpElementId, uuid, companyId, orderByComparator);
}
uuid = Objects.toString(uuid, "");
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = filterGetByUuid_C_PrevAndNext(
session, sxpElement, uuid, companyId, orderByComparator, true);
array[1] = sxpElement;
array[2] = filterGetByUuid_C_PrevAndNext(
session, sxpElement, uuid, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement filterGetByUuid_C_PrevAndNext(
Session session, SXPElement sxpElement, String uuid, long companyId,
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);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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 {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the sxp elements 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 (SXPElement sxpElement :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(sxpElement);
}
}
/**
* Returns the number of sxp elements where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching sxp elements
*/
@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_SXPELEMENT_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) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of sxp elements that the user has permission to view where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching sxp elements that the user has permission to view
*/
@Override
public int filterCountByUuid_C(String uuid, long companyId) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByUuid_C(uuid, companyId);
}
uuid = Objects.toString(uuid, "");
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_SXPELEMENT_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"sxpElement.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(sxpElement.uuid IS NULL OR sxpElement.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL =
"sxpElement.uuid_ = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL =
"(sxpElement.uuid_ IS NULL OR sxpElement.uuid_ = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"sxpElement.companyId = ?";
private FinderPath _finderPathWithPaginationFindByCompanyId;
private FinderPath _finderPathWithoutPaginationFindByCompanyId;
private FinderPath _finderPathCountByCompanyId;
/**
* Returns all the sxp elements where companyId = ?.
*
* @param companyId the company ID
* @return the matching sxp elements
*/
@Override
public List findByCompanyId(long companyId) {
return findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements
*/
@Override
public List findByCompanyId(
long companyId, int start, int end) {
return findByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements
*/
@Override
public List findByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByCompanyId(companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the sxp elements where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (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 sxp elements
*/
@Override
public List findByCompanyId(
long companyId, 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 = _finderPathWithoutPaginationFindByCompanyId;
finderArgs = new Object[] {companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByCompanyId;
finderArgs = new Object[] {
companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (SXPElement sxpElement : list) {
if (companyId != sxpElement.getCompanyId()) {
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_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(SXPElementModelImpl.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(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first sxp element in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByCompanyId_First(
long companyId, OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByCompanyId_First(
companyId, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the first sxp element in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByCompanyId_First(
long companyId, OrderByComparator orderByComparator) {
List list = findByCompanyId(
companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last sxp element in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByCompanyId_Last(
long companyId, OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByCompanyId_Last(
companyId, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the last sxp element in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByCompanyId_Last(
long companyId, OrderByComparator orderByComparator) {
int count = countByCompanyId(companyId);
if (count == 0) {
return null;
}
List list = findByCompanyId(
companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set where companyId = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] findByCompanyId_PrevAndNext(
long sxpElementId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = getByCompanyId_PrevAndNext(
session, sxpElement, companyId, orderByComparator, true);
array[1] = sxpElement;
array[2] = getByCompanyId_PrevAndNext(
session, sxpElement, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement getByCompanyId_PrevAndNext(
Session session, SXPElement sxpElement, long companyId,
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_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_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(SXPElementModelImpl.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(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the sxp elements that the user has permission to view where companyId = ?.
*
* @param companyId the company ID
* @return the matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByCompanyId(long companyId) {
return filterFindByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements that the user has permission to view where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByCompanyId(
long companyId, int start, int end) {
return filterFindByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements that the user has permissions to view where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByCompanyId(companyId, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set of sxp elements that the user has permission to view where companyId = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] filterFindByCompanyId_PrevAndNext(
long sxpElementId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByCompanyId_PrevAndNext(
sxpElementId, companyId, orderByComparator);
}
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = filterGetByCompanyId_PrevAndNext(
session, sxpElement, companyId, orderByComparator, true);
array[1] = sxpElement;
array[2] = filterGetByCompanyId_PrevAndNext(
session, sxpElement, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement filterGetByCompanyId_PrevAndNext(
Session session, SXPElement sxpElement, 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);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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 {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the sxp elements where companyId = ? from the database.
*
* @param companyId the company ID
*/
@Override
public void removeByCompanyId(long companyId) {
for (SXPElement sxpElement :
findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(sxpElement);
}
}
/**
* Returns the number of sxp elements where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching sxp elements
*/
@Override
public int countByCompanyId(long companyId) {
FinderPath finderPath = _finderPathCountByCompanyId;
Object[] finderArgs = new Object[] {companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of sxp elements that the user has permission to view where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching sxp elements that the user has permission to view
*/
@Override
public int filterCountByCompanyId(long companyId) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByCompanyId(companyId);
}
StringBundler sb = new StringBundler(2);
sb.append(_FILTER_SQL_COUNT_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 =
"sxpElement.companyId = ?";
private FinderPath _finderPathWithPaginationFindByC_R;
private FinderPath _finderPathWithoutPaginationFindByC_R;
private FinderPath _finderPathCountByC_R;
/**
* Returns all the sxp elements where companyId = ? and readOnly = ?.
*
* @param companyId the company ID
* @param readOnly the read only
* @return the matching sxp elements
*/
@Override
public List findByC_R(long companyId, boolean readOnly) {
return findByC_R(
companyId, readOnly, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements where companyId = ? and readOnly = ?.
*
*
* 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param readOnly the read only
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements
*/
@Override
public List findByC_R(
long companyId, boolean readOnly, int start, int end) {
return findByC_R(companyId, readOnly, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements where companyId = ? and readOnly = ?.
*
*
* 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param readOnly the read only
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements
*/
@Override
public List findByC_R(
long companyId, boolean readOnly, int start, int end,
OrderByComparator orderByComparator) {
return findByC_R(
companyId, readOnly, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the sxp elements where companyId = ? and readOnly = ?.
*
*
* 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param readOnly the read only
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (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 sxp elements
*/
@Override
public List findByC_R(
long companyId, boolean readOnly, 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 = _finderPathWithoutPaginationFindByC_R;
finderArgs = new Object[] {companyId, readOnly};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByC_R;
finderArgs = new Object[] {
companyId, readOnly, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (SXPElement sxpElement : list) {
if ((companyId != sxpElement.getCompanyId()) ||
(readOnly != sxpElement.isReadOnly())) {
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_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_R_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_R_READONLY_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(SXPElementModelImpl.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(companyId);
queryPos.add(readOnly);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first sxp element in the ordered set where companyId = ? and readOnly = ?.
*
* @param companyId the company ID
* @param readOnly the read only
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByC_R_First(
long companyId, boolean readOnly,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByC_R_First(
companyId, readOnly, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", readOnly=");
sb.append(readOnly);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the first sxp element in the ordered set where companyId = ? and readOnly = ?.
*
* @param companyId the company ID
* @param readOnly the read only
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByC_R_First(
long companyId, boolean readOnly,
OrderByComparator orderByComparator) {
List list = findByC_R(
companyId, readOnly, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last sxp element in the ordered set where companyId = ? and readOnly = ?.
*
* @param companyId the company ID
* @param readOnly the read only
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByC_R_Last(
long companyId, boolean readOnly,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByC_R_Last(
companyId, readOnly, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", readOnly=");
sb.append(readOnly);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the last sxp element in the ordered set where companyId = ? and readOnly = ?.
*
* @param companyId the company ID
* @param readOnly the read only
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByC_R_Last(
long companyId, boolean readOnly,
OrderByComparator orderByComparator) {
int count = countByC_R(companyId, readOnly);
if (count == 0) {
return null;
}
List list = findByC_R(
companyId, readOnly, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set where companyId = ? and readOnly = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param companyId the company ID
* @param readOnly the read only
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] findByC_R_PrevAndNext(
long sxpElementId, long companyId, boolean readOnly,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = getByC_R_PrevAndNext(
session, sxpElement, companyId, readOnly, orderByComparator,
true);
array[1] = sxpElement;
array[2] = getByC_R_PrevAndNext(
session, sxpElement, companyId, readOnly, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement getByC_R_PrevAndNext(
Session session, SXPElement sxpElement, long companyId,
boolean readOnly, 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_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_R_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_R_READONLY_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(SXPElementModelImpl.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(companyId);
queryPos.add(readOnly);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the sxp elements that the user has permission to view where companyId = ? and readOnly = ?.
*
* @param companyId the company ID
* @param readOnly the read only
* @return the matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_R(long companyId, boolean readOnly) {
return filterFindByC_R(
companyId, readOnly, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements that the user has permission to view where companyId = ? and readOnly = ?.
*
*
* 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param readOnly the read only
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_R(
long companyId, boolean readOnly, int start, int end) {
return filterFindByC_R(companyId, readOnly, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements that the user has permissions to view where companyId = ? and readOnly = ?.
*
*
* 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param readOnly the read only
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_R(
long companyId, boolean readOnly, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByC_R(
companyId, readOnly, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_C_R_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_R_READONLY_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(readOnly);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set of sxp elements that the user has permission to view where companyId = ? and readOnly = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param companyId the company ID
* @param readOnly the read only
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] filterFindByC_R_PrevAndNext(
long sxpElementId, long companyId, boolean readOnly,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByC_R_PrevAndNext(
sxpElementId, companyId, readOnly, orderByComparator);
}
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = filterGetByC_R_PrevAndNext(
session, sxpElement, companyId, readOnly, orderByComparator,
true);
array[1] = sxpElement;
array[2] = filterGetByC_R_PrevAndNext(
session, sxpElement, companyId, readOnly, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement filterGetByC_R_PrevAndNext(
Session session, SXPElement sxpElement, long companyId,
boolean readOnly, 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);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_C_R_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_R_READONLY_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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 {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(readOnly);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the sxp elements where companyId = ? and readOnly = ? from the database.
*
* @param companyId the company ID
* @param readOnly the read only
*/
@Override
public void removeByC_R(long companyId, boolean readOnly) {
for (SXPElement sxpElement :
findByC_R(
companyId, readOnly, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(sxpElement);
}
}
/**
* Returns the number of sxp elements where companyId = ? and readOnly = ?.
*
* @param companyId the company ID
* @param readOnly the read only
* @return the number of matching sxp elements
*/
@Override
public int countByC_R(long companyId, boolean readOnly) {
FinderPath finderPath = _finderPathCountByC_R;
Object[] finderArgs = new Object[] {companyId, readOnly};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_R_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_R_READONLY_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
queryPos.add(readOnly);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of sxp elements that the user has permission to view where companyId = ? and readOnly = ?.
*
* @param companyId the company ID
* @param readOnly the read only
* @return the number of matching sxp elements that the user has permission to view
*/
@Override
public int filterCountByC_R(long companyId, boolean readOnly) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByC_R(companyId, readOnly);
}
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_R_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_R_READONLY_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(readOnly);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_C_R_COMPANYID_2 =
"sxpElement.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_R_READONLY_2 =
"sxpElement.readOnly = ?";
private FinderPath _finderPathWithPaginationFindByC_T;
private FinderPath _finderPathWithoutPaginationFindByC_T;
private FinderPath _finderPathCountByC_T;
/**
* Returns all the sxp elements where companyId = ? and type = ?.
*
* @param companyId the company ID
* @param type the type
* @return the matching sxp elements
*/
@Override
public List findByC_T(long companyId, int type) {
return findByC_T(
companyId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements where companyId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements
*/
@Override
public List findByC_T(
long companyId, int type, int start, int end) {
return findByC_T(companyId, type, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements where companyId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements
*/
@Override
public List findByC_T(
long companyId, int type, int start, int end,
OrderByComparator orderByComparator) {
return findByC_T(companyId, type, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the sxp elements where companyId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (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 sxp elements
*/
@Override
public List findByC_T(
long companyId, int type, 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 = _finderPathWithoutPaginationFindByC_T;
finderArgs = new Object[] {companyId, type};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByC_T;
finderArgs = new Object[] {
companyId, type, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (SXPElement sxpElement : list) {
if ((companyId != sxpElement.getCompanyId()) ||
(type != sxpElement.getType())) {
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_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_T_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_TYPE_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(SXPElementModelImpl.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(companyId);
queryPos.add(type);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first sxp element in the ordered set where companyId = ? and type = ?.
*
* @param companyId the company ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByC_T_First(
long companyId, int type,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByC_T_First(
companyId, type, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", type=");
sb.append(type);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the first sxp element in the ordered set where companyId = ? and type = ?.
*
* @param companyId the company ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByC_T_First(
long companyId, int type,
OrderByComparator orderByComparator) {
List list = findByC_T(
companyId, type, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last sxp element in the ordered set where companyId = ? and type = ?.
*
* @param companyId the company ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByC_T_Last(
long companyId, int type,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByC_T_Last(
companyId, type, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", type=");
sb.append(type);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the last sxp element in the ordered set where companyId = ? and type = ?.
*
* @param companyId the company ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByC_T_Last(
long companyId, int type,
OrderByComparator orderByComparator) {
int count = countByC_T(companyId, type);
if (count == 0) {
return null;
}
List list = findByC_T(
companyId, type, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set where companyId = ? and type = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param companyId the company ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] findByC_T_PrevAndNext(
long sxpElementId, long companyId, int type,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = getByC_T_PrevAndNext(
session, sxpElement, companyId, type, orderByComparator, true);
array[1] = sxpElement;
array[2] = getByC_T_PrevAndNext(
session, sxpElement, companyId, type, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement getByC_T_PrevAndNext(
Session session, SXPElement sxpElement, long companyId, int type,
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_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_T_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_TYPE_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(SXPElementModelImpl.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(companyId);
queryPos.add(type);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the sxp elements that the user has permission to view where companyId = ? and type = ?.
*
* @param companyId the company ID
* @param type the type
* @return the matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_T(long companyId, int type) {
return filterFindByC_T(
companyId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements that the user has permission to view where companyId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_T(
long companyId, int type, int start, int end) {
return filterFindByC_T(companyId, type, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements that the user has permissions to view where companyId = ? and type = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_T(
long companyId, int type, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByC_T(companyId, type, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_C_T_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_TYPE_2_SQL);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(type);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set of sxp elements that the user has permission to view where companyId = ? and type = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param companyId the company ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] filterFindByC_T_PrevAndNext(
long sxpElementId, long companyId, int type,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByC_T_PrevAndNext(
sxpElementId, companyId, type, orderByComparator);
}
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = filterGetByC_T_PrevAndNext(
session, sxpElement, companyId, type, orderByComparator, true);
array[1] = sxpElement;
array[2] = filterGetByC_T_PrevAndNext(
session, sxpElement, companyId, type, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement filterGetByC_T_PrevAndNext(
Session session, SXPElement sxpElement, long companyId, int type,
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);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_C_T_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_TYPE_2_SQL);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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 {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(type);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the sxp elements where companyId = ? and type = ? from the database.
*
* @param companyId the company ID
* @param type the type
*/
@Override
public void removeByC_T(long companyId, int type) {
for (SXPElement sxpElement :
findByC_T(
companyId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(sxpElement);
}
}
/**
* Returns the number of sxp elements where companyId = ? and type = ?.
*
* @param companyId the company ID
* @param type the type
* @return the number of matching sxp elements
*/
@Override
public int countByC_T(long companyId, int type) {
FinderPath finderPath = _finderPathCountByC_T;
Object[] finderArgs = new Object[] {companyId, type};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_T_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_TYPE_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
queryPos.add(type);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of sxp elements that the user has permission to view where companyId = ? and type = ?.
*
* @param companyId the company ID
* @param type the type
* @return the number of matching sxp elements that the user has permission to view
*/
@Override
public int filterCountByC_T(long companyId, int type) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByC_T(companyId, type);
}
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_T_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_TYPE_2_SQL);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(type);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_C_T_COMPANYID_2 =
"sxpElement.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_T_TYPE_2 =
"sxpElement.type = ?";
private static final String _FINDER_COLUMN_C_T_TYPE_2_SQL =
"sxpElement.type_ = ?";
private FinderPath _finderPathWithPaginationFindByC_T_S;
private FinderPath _finderPathWithoutPaginationFindByC_T_S;
private FinderPath _finderPathCountByC_T_S;
/**
* Returns all the sxp elements where companyId = ? and type = ? and status = ?.
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @return the matching sxp elements
*/
@Override
public List findByC_T_S(long companyId, int type, int status) {
return findByC_T_S(
companyId, type, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the sxp elements where companyId = ? and type = ? 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements
*/
@Override
public List findByC_T_S(
long companyId, int type, int status, int start, int end) {
return findByC_T_S(companyId, type, status, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements where companyId = ? and type = ? 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements
*/
@Override
public List findByC_T_S(
long companyId, int type, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByC_T_S(
companyId, type, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the sxp elements where companyId = ? and type = ? 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (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 sxp elements
*/
@Override
public List findByC_T_S(
long companyId, int type, 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 = _finderPathWithoutPaginationFindByC_T_S;
finderArgs = new Object[] {companyId, type, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByC_T_S;
finderArgs = new Object[] {
companyId, type, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (SXPElement sxpElement : list) {
if ((companyId != sxpElement.getCompanyId()) ||
(type != sxpElement.getType()) ||
(status != sxpElement.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_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_T_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_S_TYPE_2);
sb.append(_FINDER_COLUMN_C_T_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(SXPElementModelImpl.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(companyId);
queryPos.add(type);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first sxp element in the ordered set where companyId = ? and type = ? and status = ?.
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByC_T_S_First(
long companyId, int type, int status,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByC_T_S_First(
companyId, type, status, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", type=");
sb.append(type);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the first sxp element in the ordered set where companyId = ? and type = ? and status = ?.
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByC_T_S_First(
long companyId, int type, int status,
OrderByComparator orderByComparator) {
List list = findByC_T_S(
companyId, type, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last sxp element in the ordered set where companyId = ? and type = ? and status = ?.
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByC_T_S_Last(
long companyId, int type, int status,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByC_T_S_Last(
companyId, type, status, orderByComparator);
if (sxpElement != null) {
return sxpElement;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", type=");
sb.append(type);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchSXPElementException(sb.toString());
}
/**
* Returns the last sxp element in the ordered set where companyId = ? and type = ? and status = ?.
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByC_T_S_Last(
long companyId, int type, int status,
OrderByComparator orderByComparator) {
int count = countByC_T_S(companyId, type, status);
if (count == 0) {
return null;
}
List list = findByC_T_S(
companyId, type, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set where companyId = ? and type = ? and status = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param companyId the company ID
* @param type the type
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] findByC_T_S_PrevAndNext(
long sxpElementId, long companyId, int type, int status,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = getByC_T_S_PrevAndNext(
session, sxpElement, companyId, type, status, orderByComparator,
true);
array[1] = sxpElement;
array[2] = getByC_T_S_PrevAndNext(
session, sxpElement, companyId, type, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement getByC_T_S_PrevAndNext(
Session session, SXPElement sxpElement, long companyId, int type,
int status, 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_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_T_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_S_TYPE_2);
sb.append(_FINDER_COLUMN_C_T_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(SXPElementModelImpl.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(companyId);
queryPos.add(type);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the sxp elements that the user has permission to view where companyId = ? and type = ? and status = ?.
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @return the matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_T_S(
long companyId, int type, int status) {
return filterFindByC_T_S(
companyId, type, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the sxp elements that the user has permission to view where companyId = ? and type = ? 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_T_S(
long companyId, int type, int status, int start, int end) {
return filterFindByC_T_S(companyId, type, status, start, end, null);
}
/**
* Returns an ordered range of all the sxp elements that the user has permissions to view where companyId = ? and type = ? 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 SXPElementModelImpl
.
*
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching sxp elements that the user has permission to view
*/
@Override
public List filterFindByC_T_S(
long companyId, int type, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByC_T_S(
companyId, type, status, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_C_T_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_S_TYPE_2_SQL);
sb.append(_FINDER_COLUMN_C_T_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(type);
queryPos.add(status);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the sxp elements before and after the current sxp element in the ordered set of sxp elements that the user has permission to view where companyId = ? and type = ? and status = ?.
*
* @param sxpElementId the primary key of the current sxp element
* @param companyId the company ID
* @param type the type
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement[] filterFindByC_T_S_PrevAndNext(
long sxpElementId, long companyId, int type, int status,
OrderByComparator orderByComparator)
throws NoSuchSXPElementException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByC_T_S_PrevAndNext(
sxpElementId, companyId, type, status, orderByComparator);
}
SXPElement sxpElement = findByPrimaryKey(sxpElementId);
Session session = null;
try {
session = openSession();
SXPElement[] array = new SXPElementImpl[3];
array[0] = filterGetByC_T_S_PrevAndNext(
session, sxpElement, companyId, type, status, orderByComparator,
true);
array[1] = sxpElement;
array[2] = filterGetByC_T_S_PrevAndNext(
session, sxpElement, companyId, type, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected SXPElement filterGetByC_T_S_PrevAndNext(
Session session, SXPElement sxpElement, long companyId, int type,
int status, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
7 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_WHERE);
}
else {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_C_T_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_S_TYPE_2_SQL);
sb.append(_FINDER_COLUMN_C_T_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
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++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
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 {
if (getDB().isSupportsInlineDistinct()) {
sb.append(SXPElementModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(SXPElementModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, SXPElementImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, SXPElementImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(type);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(sxpElement)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the sxp elements where companyId = ? and type = ? and status = ? from the database.
*
* @param companyId the company ID
* @param type the type
* @param status the status
*/
@Override
public void removeByC_T_S(long companyId, int type, int status) {
for (SXPElement sxpElement :
findByC_T_S(
companyId, type, status, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(sxpElement);
}
}
/**
* Returns the number of sxp elements where companyId = ? and type = ? and status = ?.
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @return the number of matching sxp elements
*/
@Override
public int countByC_T_S(long companyId, int type, int status) {
FinderPath finderPath = _finderPathCountByC_T_S;
Object[] finderArgs = new Object[] {companyId, type, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_T_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_S_TYPE_2);
sb.append(_FINDER_COLUMN_C_T_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(companyId);
queryPos.add(type);
queryPos.add(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of sxp elements that the user has permission to view where companyId = ? and type = ? and status = ?.
*
* @param companyId the company ID
* @param type the type
* @param status the status
* @return the number of matching sxp elements that the user has permission to view
*/
@Override
public int filterCountByC_T_S(long companyId, int type, int status) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByC_T_S(companyId, type, status);
}
StringBundler sb = new StringBundler(4);
sb.append(_FILTER_SQL_COUNT_SXPELEMENT_WHERE);
sb.append(_FINDER_COLUMN_C_T_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_T_S_TYPE_2_SQL);
sb.append(_FINDER_COLUMN_C_T_S_STATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), SXPElement.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(type);
queryPos.add(status);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_C_T_S_COMPANYID_2 =
"sxpElement.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_T_S_TYPE_2 =
"sxpElement.type = ? AND ";
private static final String _FINDER_COLUMN_C_T_S_TYPE_2_SQL =
"sxpElement.type_ = ? AND ";
private static final String _FINDER_COLUMN_C_T_S_STATUS_2 =
"sxpElement.status = ?";
private FinderPath _finderPathFetchByERC_C;
/**
* Returns the sxp element where externalReferenceCode = ? and companyId = ? or throws a NoSuchSXPElementException
if it could not be found.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @return the matching sxp element
* @throws NoSuchSXPElementException if a matching sxp element could not be found
*/
@Override
public SXPElement findByERC_C(String externalReferenceCode, long companyId)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByERC_C(externalReferenceCode, companyId);
if (sxpElement == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("externalReferenceCode=");
sb.append(externalReferenceCode);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchSXPElementException(sb.toString());
}
return sxpElement;
}
/**
* Returns the sxp element where externalReferenceCode = ? and companyId = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @return the matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByERC_C(
String externalReferenceCode, long companyId) {
return fetchByERC_C(externalReferenceCode, companyId, true);
}
/**
* Returns the sxp element where externalReferenceCode = ? and companyId = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @param useFinderCache whether to use the finder cache
* @return the matching sxp element, or null
if a matching sxp element could not be found
*/
@Override
public SXPElement fetchByERC_C(
String externalReferenceCode, long companyId, boolean useFinderCache) {
externalReferenceCode = Objects.toString(externalReferenceCode, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {externalReferenceCode, companyId};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByERC_C, finderArgs, this);
}
if (result instanceof SXPElement) {
SXPElement sxpElement = (SXPElement)result;
if (!Objects.equals(
externalReferenceCode,
sxpElement.getExternalReferenceCode()) ||
(companyId != sxpElement.getCompanyId())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_SXPELEMENT_WHERE);
boolean bindExternalReferenceCode = false;
if (externalReferenceCode.isEmpty()) {
sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3);
}
else {
bindExternalReferenceCode = true;
sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2);
}
sb.append(_FINDER_COLUMN_ERC_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindExternalReferenceCode) {
queryPos.add(externalReferenceCode);
}
queryPos.add(companyId);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByERC_C, finderArgs, list);
}
}
else {
SXPElement sxpElement = list.get(0);
result = sxpElement;
cacheResult(sxpElement);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (SXPElement)result;
}
}
/**
* Removes the sxp element where externalReferenceCode = ? and companyId = ? from the database.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @return the sxp element that was removed
*/
@Override
public SXPElement removeByERC_C(
String externalReferenceCode, long companyId)
throws NoSuchSXPElementException {
SXPElement sxpElement = findByERC_C(externalReferenceCode, companyId);
return remove(sxpElement);
}
/**
* Returns the number of sxp elements where externalReferenceCode = ? and companyId = ?.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @return the number of matching sxp elements
*/
@Override
public int countByERC_C(String externalReferenceCode, long companyId) {
SXPElement sxpElement = fetchByERC_C(externalReferenceCode, companyId);
if (sxpElement == null) {
return 0;
}
return 1;
}
private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2 =
"sxpElement.externalReferenceCode = ? AND ";
private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3 =
"(sxpElement.externalReferenceCode IS NULL OR sxpElement.externalReferenceCode = '') AND ";
private static final String _FINDER_COLUMN_ERC_C_COMPANYID_2 =
"sxpElement.companyId = ?";
public SXPElementPersistenceImpl() {
Map dbColumnNames = new HashMap();
dbColumnNames.put("uuid", "uuid_");
dbColumnNames.put("hidden", "hidden_");
dbColumnNames.put("type", "type_");
setDBColumnNames(dbColumnNames);
setModelClass(SXPElement.class);
setModelImplClass(SXPElementImpl.class);
setModelPKClass(long.class);
setTable(SXPElementTable.INSTANCE);
}
/**
* Caches the sxp element in the entity cache if it is enabled.
*
* @param sxpElement the sxp element
*/
@Override
public void cacheResult(SXPElement sxpElement) {
entityCache.putResult(
SXPElementImpl.class, sxpElement.getPrimaryKey(), sxpElement);
finderCache.putResult(
_finderPathFetchByERC_C,
new Object[] {
sxpElement.getExternalReferenceCode(), sxpElement.getCompanyId()
},
sxpElement);
}
private int _valueObjectFinderCacheListThreshold;
/**
* Caches the sxp elements in the entity cache if it is enabled.
*
* @param sxpElements the sxp elements
*/
@Override
public void cacheResult(List sxpElements) {
if ((_valueObjectFinderCacheListThreshold == 0) ||
((_valueObjectFinderCacheListThreshold > 0) &&
(sxpElements.size() > _valueObjectFinderCacheListThreshold))) {
return;
}
for (SXPElement sxpElement : sxpElements) {
if (entityCache.getResult(
SXPElementImpl.class, sxpElement.getPrimaryKey()) == null) {
cacheResult(sxpElement);
}
}
}
/**
* Clears the cache for all sxp elements.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache() {
entityCache.clearCache(SXPElementImpl.class);
finderCache.clearCache(SXPElementImpl.class);
}
/**
* Clears the cache for the sxp element.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache(SXPElement sxpElement) {
entityCache.removeResult(SXPElementImpl.class, sxpElement);
}
@Override
public void clearCache(List sxpElements) {
for (SXPElement sxpElement : sxpElements) {
entityCache.removeResult(SXPElementImpl.class, sxpElement);
}
}
@Override
public void clearCache(Set primaryKeys) {
finderCache.clearCache(SXPElementImpl.class);
for (Serializable primaryKey : primaryKeys) {
entityCache.removeResult(SXPElementImpl.class, primaryKey);
}
}
protected void cacheUniqueFindersCache(
SXPElementModelImpl sxpElementModelImpl) {
Object[] args = new Object[] {
sxpElementModelImpl.getExternalReferenceCode(),
sxpElementModelImpl.getCompanyId()
};
finderCache.putResult(
_finderPathFetchByERC_C, args, sxpElementModelImpl);
}
/**
* Creates a new sxp element with the primary key. Does not add the sxp element to the database.
*
* @param sxpElementId the primary key for the new sxp element
* @return the new sxp element
*/
@Override
public SXPElement create(long sxpElementId) {
SXPElement sxpElement = new SXPElementImpl();
sxpElement.setNew(true);
sxpElement.setPrimaryKey(sxpElementId);
String uuid = PortalUUIDUtil.generate();
sxpElement.setUuid(uuid);
sxpElement.setCompanyId(CompanyThreadLocal.getCompanyId());
return sxpElement;
}
/**
* Removes the sxp element with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param sxpElementId the primary key of the sxp element
* @return the sxp element that was removed
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement remove(long sxpElementId)
throws NoSuchSXPElementException {
return remove((Serializable)sxpElementId);
}
/**
* Removes the sxp element with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the sxp element
* @return the sxp element that was removed
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement remove(Serializable primaryKey)
throws NoSuchSXPElementException {
Session session = null;
try {
session = openSession();
SXPElement sxpElement = (SXPElement)session.get(
SXPElementImpl.class, primaryKey);
if (sxpElement == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchSXPElementException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(sxpElement);
}
catch (NoSuchSXPElementException noSuchEntityException) {
throw noSuchEntityException;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
@Override
protected SXPElement removeImpl(SXPElement sxpElement) {
Session session = null;
try {
session = openSession();
if (!session.contains(sxpElement)) {
sxpElement = (SXPElement)session.get(
SXPElementImpl.class, sxpElement.getPrimaryKeyObj());
}
if (sxpElement != null) {
session.delete(sxpElement);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
if (sxpElement != null) {
clearCache(sxpElement);
}
return sxpElement;
}
@Override
public SXPElement updateImpl(SXPElement sxpElement) {
boolean isNew = sxpElement.isNew();
if (!(sxpElement instanceof SXPElementModelImpl)) {
InvocationHandler invocationHandler = null;
if (ProxyUtil.isProxyClass(sxpElement.getClass())) {
invocationHandler = ProxyUtil.getInvocationHandler(sxpElement);
throw new IllegalArgumentException(
"Implement ModelWrapper in sxpElement proxy " +
invocationHandler.getClass());
}
throw new IllegalArgumentException(
"Implement ModelWrapper in custom SXPElement implementation " +
sxpElement.getClass());
}
SXPElementModelImpl sxpElementModelImpl =
(SXPElementModelImpl)sxpElement;
if (Validator.isNull(sxpElement.getUuid())) {
String uuid = PortalUUIDUtil.generate();
sxpElement.setUuid(uuid);
}
if (Validator.isNull(sxpElement.getExternalReferenceCode())) {
sxpElement.setExternalReferenceCode(sxpElement.getUuid());
}
else {
if (!Objects.equals(
sxpElementModelImpl.getColumnOriginalValue(
"externalReferenceCode"),
sxpElement.getExternalReferenceCode())) {
long userId = GetterUtil.getLong(
PrincipalThreadLocal.getName());
if (userId > 0) {
long companyId = sxpElement.getCompanyId();
long groupId = 0;
long classPK = 0;
if (!isNew) {
classPK = sxpElement.getPrimaryKey();
}
try {
sxpElement.setExternalReferenceCode(
SanitizerUtil.sanitize(
companyId, groupId, userId,
SXPElement.class.getName(), classPK,
ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
sxpElement.getExternalReferenceCode(), null));
}
catch (SanitizerException sanitizerException) {
throw new SystemException(sanitizerException);
}
}
}
SXPElement ercSXPElement = fetchByERC_C(
sxpElement.getExternalReferenceCode(),
sxpElement.getCompanyId());
if (isNew) {
if (ercSXPElement != null) {
throw new DuplicateSXPElementExternalReferenceCodeException(
"Duplicate sxp element with external reference code " +
sxpElement.getExternalReferenceCode() +
" and company " + sxpElement.getCompanyId());
}
}
else {
if ((ercSXPElement != null) &&
(sxpElement.getSXPElementId() !=
ercSXPElement.getSXPElementId())) {
throw new DuplicateSXPElementExternalReferenceCodeException(
"Duplicate sxp element with external reference code " +
sxpElement.getExternalReferenceCode() +
" and company " + sxpElement.getCompanyId());
}
}
}
ServiceContext serviceContext =
ServiceContextThreadLocal.getServiceContext();
Date date = new Date();
if (isNew && (sxpElement.getCreateDate() == null)) {
if (serviceContext == null) {
sxpElement.setCreateDate(date);
}
else {
sxpElement.setCreateDate(serviceContext.getCreateDate(date));
}
}
if (!sxpElementModelImpl.hasSetModifiedDate()) {
if (serviceContext == null) {
sxpElement.setModifiedDate(date);
}
else {
sxpElement.setModifiedDate(
serviceContext.getModifiedDate(date));
}
}
long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
if (userId > 0) {
long companyId = sxpElement.getCompanyId();
long groupId = 0;
long sxpElementId = 0;
if (!isNew) {
sxpElementId = sxpElement.getPrimaryKey();
}
try {
sxpElement.setTitle(
SanitizerUtil.sanitize(
companyId, groupId, userId, SXPElement.class.getName(),
sxpElementId, ContentTypes.TEXT_PLAIN,
Sanitizer.MODE_ALL, sxpElement.getTitle(), null));
}
catch (SanitizerException sanitizerException) {
throw new SystemException(sanitizerException);
}
}
Session session = null;
try {
session = openSession();
if (isNew) {
session.save(sxpElement);
}
else {
sxpElement = (SXPElement)session.merge(sxpElement);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
entityCache.putResult(
SXPElementImpl.class, sxpElementModelImpl, false, true);
cacheUniqueFindersCache(sxpElementModelImpl);
if (isNew) {
sxpElement.setNew(false);
}
sxpElement.resetOriginalValues();
return sxpElement;
}
/**
* Returns the sxp element with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException
if it could not be found.
*
* @param primaryKey the primary key of the sxp element
* @return the sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement findByPrimaryKey(Serializable primaryKey)
throws NoSuchSXPElementException {
SXPElement sxpElement = fetchByPrimaryKey(primaryKey);
if (sxpElement == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchSXPElementException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return sxpElement;
}
/**
* Returns the sxp element with the primary key or throws a NoSuchSXPElementException
if it could not be found.
*
* @param sxpElementId the primary key of the sxp element
* @return the sxp element
* @throws NoSuchSXPElementException if a sxp element with the primary key could not be found
*/
@Override
public SXPElement findByPrimaryKey(long sxpElementId)
throws NoSuchSXPElementException {
return findByPrimaryKey((Serializable)sxpElementId);
}
/**
* Returns the sxp element with the primary key or returns null
if it could not be found.
*
* @param sxpElementId the primary key of the sxp element
* @return the sxp element, or null
if a sxp element with the primary key could not be found
*/
@Override
public SXPElement fetchByPrimaryKey(long sxpElementId) {
return fetchByPrimaryKey((Serializable)sxpElementId);
}
/**
* Returns all the sxp elements.
*
* @return the sxp elements
*/
@Override
public List findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the sxp elements.
*
*
* 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 SXPElementModelImpl
.
*
*
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @return the range of sxp elements
*/
@Override
public List findAll(int start, int end) {
return findAll(start, end, null);
}
/**
* Returns an ordered range of all the sxp elements.
*
*
* 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 SXPElementModelImpl
.
*
*
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of sxp elements
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator) {
return findAll(start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the sxp elements.
*
*
* 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 SXPElementModelImpl
.
*
*
* @param start the lower bound of the range of sxp elements
* @param end the upper bound of the range of sxp elements (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 sxp elements
*/
@Override
public List findAll(
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 = _finderPathWithoutPaginationFindAll;
finderArgs = FINDER_ARGS_EMPTY;
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindAll;
finderArgs = new Object[] {start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
}
if (list == null) {
StringBundler sb = null;
String sql = null;
if (orderByComparator != null) {
sb = new StringBundler(
2 + (orderByComparator.getOrderByFields().length * 2));
sb.append(_SQL_SELECT_SXPELEMENT);
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = sb.toString();
}
else {
sql = _SQL_SELECT_SXPELEMENT;
sql = sql.concat(SXPElementModelImpl.ORDER_BY_JPQL);
}
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the sxp elements from the database.
*
*/
@Override
public void removeAll() {
for (SXPElement sxpElement : findAll()) {
remove(sxpElement);
}
}
/**
* Returns the number of sxp elements.
*
* @return the number of sxp elements
*/
@Override
public int countAll() {
Long count = (Long)finderCache.getResult(
_finderPathCountAll, FINDER_ARGS_EMPTY, this);
if (count == null) {
Session session = null;
try {
session = openSession();
Query query = session.createQuery(_SQL_COUNT_SXPELEMENT);
count = (Long)query.uniqueResult();
finderCache.putResult(
_finderPathCountAll, FINDER_ARGS_EMPTY, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
@Override
public Set getBadColumnNames() {
return _badColumnNames;
}
@Override
protected EntityCache getEntityCache() {
return entityCache;
}
@Override
protected String getPKDBName() {
return "sxpElementId";
}
@Override
protected String getSelectSQL() {
return _SQL_SELECT_SXPELEMENT;
}
@Override
protected Map getTableColumnsMap() {
return SXPElementModelImpl.TABLE_COLUMNS_MAP;
}
/**
* Initializes the sxp element persistence.
*/
@Activate
public void activate() {
_valueObjectFinderCacheListThreshold = GetterUtil.getInteger(
PropsUtil.get(PropsKeys.VALUE_OBJECT_FINDER_CACHE_LIST_THRESHOLD));
_finderPathWithPaginationFindAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0],
new String[0], true);
_finderPathWithoutPaginationFindAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0],
new String[0], true);
_finderPathCountAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll",
new String[0], new String[0], false);
_finderPathWithPaginationFindByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
new String[] {
String.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"uuid_"}, true);
_finderPathWithoutPaginationFindByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
new String[] {String.class.getName()}, new String[] {"uuid_"},
true);
_finderPathCountByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
new String[] {String.class.getName()}, new String[] {"uuid_"},
false);
_finderPathWithPaginationFindByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
new String[] {
String.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
},
new String[] {"uuid_", "companyId"}, true);
_finderPathWithoutPaginationFindByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"uuid_", "companyId"}, true);
_finderPathCountByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"uuid_", "companyId"}, false);
_finderPathWithPaginationFindByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"companyId"}, true);
_finderPathWithoutPaginationFindByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
new String[] {Long.class.getName()}, new String[] {"companyId"},
true);
_finderPathCountByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
new String[] {Long.class.getName()}, new String[] {"companyId"},
false);
_finderPathWithPaginationFindByC_R = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_R",
new String[] {
Long.class.getName(), Boolean.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
},
new String[] {"companyId", "readOnly"}, true);
_finderPathWithoutPaginationFindByC_R = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_R",
new String[] {Long.class.getName(), Boolean.class.getName()},
new String[] {"companyId", "readOnly"}, true);
_finderPathCountByC_R = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_R",
new String[] {Long.class.getName(), Boolean.class.getName()},
new String[] {"companyId", "readOnly"}, false);
_finderPathWithPaginationFindByC_T = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_T",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
},
new String[] {"companyId", "type_"}, true);
_finderPathWithoutPaginationFindByC_T = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T",
new String[] {Long.class.getName(), Integer.class.getName()},
new String[] {"companyId", "type_"}, true);
_finderPathCountByC_T = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T",
new String[] {Long.class.getName(), Integer.class.getName()},
new String[] {"companyId", "type_"}, false);
_finderPathWithPaginationFindByC_T_S = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_T_S",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"companyId", "type_", "status"}, true);
_finderPathWithoutPaginationFindByC_T_S = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T_S",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName()
},
new String[] {"companyId", "type_", "status"}, true);
_finderPathCountByC_T_S = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T_S",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName()
},
new String[] {"companyId", "type_", "status"}, false);
_finderPathFetchByERC_C = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByERC_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"externalReferenceCode", "companyId"}, true);
SXPElementUtil.setPersistence(this);
}
@Deactivate
public void deactivate() {
SXPElementUtil.setPersistence(null);
entityCache.removeCache(SXPElementImpl.class.getName());
}
@Override
@Reference(
target = SXPPersistenceConstants.SERVICE_CONFIGURATION_FILTER,
unbind = "-"
)
public void setConfiguration(Configuration configuration) {
}
@Override
@Reference(
target = SXPPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
unbind = "-"
)
public void setDataSource(DataSource dataSource) {
super.setDataSource(dataSource);
}
@Override
@Reference(
target = SXPPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
unbind = "-"
)
public void setSessionFactory(SessionFactory sessionFactory) {
super.setSessionFactory(sessionFactory);
}
@Reference
protected EntityCache entityCache;
@Reference
protected FinderCache finderCache;
private static final String _SQL_SELECT_SXPELEMENT =
"SELECT sxpElement FROM SXPElement sxpElement";
private static final String _SQL_SELECT_SXPELEMENT_WHERE =
"SELECT sxpElement FROM SXPElement sxpElement WHERE ";
private static final String _SQL_COUNT_SXPELEMENT =
"SELECT COUNT(sxpElement) FROM SXPElement sxpElement";
private static final String _SQL_COUNT_SXPELEMENT_WHERE =
"SELECT COUNT(sxpElement) FROM SXPElement sxpElement WHERE ";
private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN =
"sxpElement.sxpElementId";
private static final String _FILTER_SQL_SELECT_SXPELEMENT_WHERE =
"SELECT DISTINCT {sxpElement.*} FROM SXPElement sxpElement WHERE ";
private static final String
_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_1 =
"SELECT {SXPElement.*} FROM (SELECT DISTINCT sxpElement.sxpElementId FROM SXPElement sxpElement WHERE ";
private static final String
_FILTER_SQL_SELECT_SXPELEMENT_NO_INLINE_DISTINCT_WHERE_2 =
") TEMP_TABLE INNER JOIN SXPElement ON TEMP_TABLE.sxpElementId = SXPElement.sxpElementId";
private static final String _FILTER_SQL_COUNT_SXPELEMENT_WHERE =
"SELECT COUNT(DISTINCT sxpElement.sxpElementId) AS COUNT_VALUE FROM SXPElement sxpElement WHERE ";
private static final String _FILTER_ENTITY_ALIAS = "sxpElement";
private static final String _FILTER_ENTITY_TABLE = "SXPElement";
private static final String _ORDER_BY_ENTITY_ALIAS = "sxpElement.";
private static final String _ORDER_BY_ENTITY_TABLE = "SXPElement.";
private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
"No SXPElement exists with the primary key ";
private static final String _NO_SUCH_ENTITY_WITH_KEY =
"No SXPElement exists with the key {";
private static final Log _log = LogFactoryUtil.getLog(
SXPElementPersistenceImpl.class);
private static final Set _badColumnNames = SetUtil.fromArray(
new String[] {"uuid", "hidden", "type"});
@Override
protected FinderCache getFinderCache() {
return finderCache;
}
}