All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.oauth2.provider.service.persistence.impl.OAuth2ApplicationPersistenceImpl Maven / Gradle / Ivy

There is a newer version: 4.0.94
Show newest version
/**
 * 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.oauth2.provider.service.persistence.impl;

import com.liferay.oauth2.provider.exception.DuplicateOAuth2ApplicationExternalReferenceCodeException;
import com.liferay.oauth2.provider.exception.NoSuchOAuth2ApplicationException;
import com.liferay.oauth2.provider.model.OAuth2Application;
import com.liferay.oauth2.provider.model.OAuth2ApplicationTable;
import com.liferay.oauth2.provider.model.impl.OAuth2ApplicationImpl;
import com.liferay.oauth2.provider.model.impl.OAuth2ApplicationModelImpl;
import com.liferay.oauth2.provider.service.persistence.OAuth2ApplicationPersistence;
import com.liferay.oauth2.provider.service.persistence.OAuth2ApplicationUtil;
import com.liferay.oauth2.provider.service.persistence.impl.constants.OAuthTwoPersistenceConstants;
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.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;

import java.io.Serializable;

import java.lang.reflect.InvocationHandler;

import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import javax.sql.DataSource;

import org.osgi.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 o auth2 application service.
 *
 * 

* Caching information and settings can be found in portal.properties *

* * @author Brian Wing Shun Chan * @generated */ @Component(service = OAuth2ApplicationPersistence.class) public class OAuth2ApplicationPersistenceImpl extends BasePersistenceImpl implements OAuth2ApplicationPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use OAuth2ApplicationUtil to access the o auth2 application persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = OAuth2ApplicationImpl.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 o auth2 applications where uuid = ?. * * @param uuid the uuid * @return the matching o auth2 applications */ @Override public List findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of matching o auth2 applications */ @Override public List findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching o auth2 applications */ @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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (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 o auth2 applications */ @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 (OAuth2Application oAuth2Application : list) { if (!uuid.equals(oAuth2Application.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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.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 o auth2 application 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 o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByUuid_First( String uuid, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByUuid_First( uuid, orderByComparator); if (oAuth2Application != null) { return oAuth2Application; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchOAuth2ApplicationException(sb.toString()); } /** * Returns the first o auth2 application 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 o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application 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 o auth2 application 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 o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByUuid_Last( String uuid, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByUuid_Last( uuid, orderByComparator); if (oAuth2Application != null) { return oAuth2Application; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchOAuth2ApplicationException(sb.toString()); } /** * Returns the last o auth2 application 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 o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application 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 o auth2 applications before and after the current o auth2 application in the ordered set where uuid = ?. * * @param oAuth2ApplicationId the primary key of the current o auth2 application * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application[] findByUuid_PrevAndNext( long oAuth2ApplicationId, String uuid, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { uuid = Objects.toString(uuid, ""); OAuth2Application oAuth2Application = findByPrimaryKey( oAuth2ApplicationId); Session session = null; try { session = openSession(); OAuth2Application[] array = new OAuth2ApplicationImpl[3]; array[0] = getByUuid_PrevAndNext( session, oAuth2Application, uuid, orderByComparator, true); array[1] = oAuth2Application; array[2] = getByUuid_PrevAndNext( session, oAuth2Application, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected OAuth2Application getByUuid_PrevAndNext( Session session, OAuth2Application oAuth2Application, 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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.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( oAuth2Application)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the o auth2 applications that the user has permission to view where uuid = ?. * * @param uuid the uuid * @return the matching o auth2 applications 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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of matching o auth2 applications 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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching o auth2 applications 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_OAUTH2APPLICATION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.ORDER_BY_JPQL); } else { sb.append(OAuth2ApplicationModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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, OAuth2ApplicationImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, OAuth2ApplicationImpl.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 o auth2 applications before and after the current o auth2 application in the ordered set of o auth2 applications that the user has permission to view where uuid = ?. * * @param oAuth2ApplicationId the primary key of the current o auth2 application * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application[] filterFindByUuid_PrevAndNext( long oAuth2ApplicationId, String uuid, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { if (!InlineSQLHelperUtil.isEnabled()) { return findByUuid_PrevAndNext( oAuth2ApplicationId, uuid, orderByComparator); } uuid = Objects.toString(uuid, ""); OAuth2Application oAuth2Application = findByPrimaryKey( oAuth2ApplicationId); Session session = null; try { session = openSession(); OAuth2Application[] array = new OAuth2ApplicationImpl[3]; array[0] = filterGetByUuid_PrevAndNext( session, oAuth2Application, uuid, orderByComparator, true); array[1] = oAuth2Application; array[2] = filterGetByUuid_PrevAndNext( session, oAuth2Application, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected OAuth2Application filterGetByUuid_PrevAndNext( Session session, OAuth2Application oAuth2Application, 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_OAUTH2APPLICATION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.ORDER_BY_JPQL); } else { sb.append(OAuth2ApplicationModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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, OAuth2ApplicationImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, OAuth2ApplicationImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( oAuth2Application)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the o auth2 applications where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (OAuth2Application oAuth2Application : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(oAuth2Application); } } /** * Returns the number of o auth2 applications where uuid = ?. * * @param uuid the uuid * @return the number of matching o auth2 applications */ @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_OAUTH2APPLICATION_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 o auth2 applications that the user has permission to view where uuid = ?. * * @param uuid the uuid * @return the number of matching o auth2 applications 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_OAUTH2APPLICATION_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(), OAuth2Application.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 = "oAuth2Application.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(oAuth2Application.uuid IS NULL OR oAuth2Application.uuid = '')"; private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "oAuth2Application.uuid_ = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(oAuth2Application.uuid_ IS NULL OR oAuth2Application.uuid_ = '')"; private FinderPath _finderPathWithPaginationFindByUuid_C; private FinderPath _finderPathWithoutPaginationFindByUuid_C; private FinderPath _finderPathCountByUuid_C; /** * Returns all the o auth2 applications where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching o auth2 applications */ @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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of matching o auth2 applications */ @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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching o auth2 applications */ @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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (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 o auth2 applications */ @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 (OAuth2Application oAuth2Application : list) { if (!uuid.equals(oAuth2Application.getUuid()) || (companyId != oAuth2Application.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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.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 o auth2 application 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 o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByUuid_C_First( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByUuid_C_First( uuid, companyId, orderByComparator); if (oAuth2Application != null) { return oAuth2Application; } 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 NoSuchOAuth2ApplicationException(sb.toString()); } /** * Returns the first o auth2 application 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 o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application 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 o auth2 application 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 o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByUuid_C_Last( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByUuid_C_Last( uuid, companyId, orderByComparator); if (oAuth2Application != null) { return oAuth2Application; } 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 NoSuchOAuth2ApplicationException(sb.toString()); } /** * Returns the last o auth2 application 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 o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application 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 o auth2 applications before and after the current o auth2 application in the ordered set where uuid = ? and companyId = ?. * * @param oAuth2ApplicationId the primary key of the current o auth2 application * @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 o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application[] findByUuid_C_PrevAndNext( long oAuth2ApplicationId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { uuid = Objects.toString(uuid, ""); OAuth2Application oAuth2Application = findByPrimaryKey( oAuth2ApplicationId); Session session = null; try { session = openSession(); OAuth2Application[] array = new OAuth2ApplicationImpl[3]; array[0] = getByUuid_C_PrevAndNext( session, oAuth2Application, uuid, companyId, orderByComparator, true); array[1] = oAuth2Application; array[2] = getByUuid_C_PrevAndNext( session, oAuth2Application, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected OAuth2Application getByUuid_C_PrevAndNext( Session session, OAuth2Application oAuth2Application, 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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.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( oAuth2Application)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the o auth2 applications that the user has permission to view where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching o auth2 applications 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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of matching o auth2 applications 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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching o auth2 applications 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_OAUTH2APPLICATION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.ORDER_BY_JPQL); } else { sb.append(OAuth2ApplicationModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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, OAuth2ApplicationImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, OAuth2ApplicationImpl.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 o auth2 applications before and after the current o auth2 application in the ordered set of o auth2 applications that the user has permission to view where uuid = ? and companyId = ?. * * @param oAuth2ApplicationId the primary key of the current o auth2 application * @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 o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application[] filterFindByUuid_C_PrevAndNext( long oAuth2ApplicationId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByUuid_C_PrevAndNext( oAuth2ApplicationId, uuid, companyId, orderByComparator); } uuid = Objects.toString(uuid, ""); OAuth2Application oAuth2Application = findByPrimaryKey( oAuth2ApplicationId); Session session = null; try { session = openSession(); OAuth2Application[] array = new OAuth2ApplicationImpl[3]; array[0] = filterGetByUuid_C_PrevAndNext( session, oAuth2Application, uuid, companyId, orderByComparator, true); array[1] = oAuth2Application; array[2] = filterGetByUuid_C_PrevAndNext( session, oAuth2Application, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected OAuth2Application filterGetByUuid_C_PrevAndNext( Session session, OAuth2Application oAuth2Application, 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_OAUTH2APPLICATION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.ORDER_BY_JPQL); } else { sb.append(OAuth2ApplicationModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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, OAuth2ApplicationImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, OAuth2ApplicationImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( oAuth2Application)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the o auth2 applications 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 (OAuth2Application oAuth2Application : findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(oAuth2Application); } } /** * Returns the number of o auth2 applications where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching o auth2 applications */ @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_OAUTH2APPLICATION_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 o auth2 applications 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 o auth2 applications 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_OAUTH2APPLICATION_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(), OAuth2Application.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 = "oAuth2Application.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(oAuth2Application.uuid IS NULL OR oAuth2Application.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "oAuth2Application.uuid_ = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(oAuth2Application.uuid_ IS NULL OR oAuth2Application.uuid_ = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "oAuth2Application.companyId = ?"; private FinderPath _finderPathWithPaginationFindByCompanyId; private FinderPath _finderPathWithoutPaginationFindByCompanyId; private FinderPath _finderPathCountByCompanyId; /** * Returns all the o auth2 applications where companyId = ?. * * @param companyId the company ID * @return the matching o auth2 applications */ @Override public List findByCompanyId(long companyId) { return findByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of matching o auth2 applications */ @Override public List findByCompanyId( long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching o auth2 applications */ @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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (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 o auth2 applications */ @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 (OAuth2Application oAuth2Application : list) { if (companyId != oAuth2Application.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_OAUTH2APPLICATION_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(OAuth2ApplicationModelImpl.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 o auth2 application 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 o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByCompanyId_First( long companyId, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByCompanyId_First( companyId, orderByComparator); if (oAuth2Application != null) { return oAuth2Application; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchOAuth2ApplicationException(sb.toString()); } /** * Returns the first o auth2 application 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 o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application 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 o auth2 application 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 o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByCompanyId_Last( long companyId, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByCompanyId_Last( companyId, orderByComparator); if (oAuth2Application != null) { return oAuth2Application; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchOAuth2ApplicationException(sb.toString()); } /** * Returns the last o auth2 application 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 o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application 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 o auth2 applications before and after the current o auth2 application in the ordered set where companyId = ?. * * @param oAuth2ApplicationId the primary key of the current o auth2 application * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application[] findByCompanyId_PrevAndNext( long oAuth2ApplicationId, long companyId, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = findByPrimaryKey( oAuth2ApplicationId); Session session = null; try { session = openSession(); OAuth2Application[] array = new OAuth2ApplicationImpl[3]; array[0] = getByCompanyId_PrevAndNext( session, oAuth2Application, companyId, orderByComparator, true); array[1] = oAuth2Application; array[2] = getByCompanyId_PrevAndNext( session, oAuth2Application, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected OAuth2Application getByCompanyId_PrevAndNext( Session session, OAuth2Application oAuth2Application, 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_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.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( oAuth2Application)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the o auth2 applications that the user has permission to view where companyId = ?. * * @param companyId the company ID * @return the matching o auth2 applications 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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of matching o auth2 applications 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 o auth2 applications 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching o auth2 applications 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_OAUTH2APPLICATION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.ORDER_BY_JPQL); } else { sb.append(OAuth2ApplicationModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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, OAuth2ApplicationImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, OAuth2ApplicationImpl.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 o auth2 applications before and after the current o auth2 application in the ordered set of o auth2 applications that the user has permission to view where companyId = ?. * * @param oAuth2ApplicationId the primary key of the current o auth2 application * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application[] filterFindByCompanyId_PrevAndNext( long oAuth2ApplicationId, long companyId, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByCompanyId_PrevAndNext( oAuth2ApplicationId, companyId, orderByComparator); } OAuth2Application oAuth2Application = findByPrimaryKey( oAuth2ApplicationId); Session session = null; try { session = openSession(); OAuth2Application[] array = new OAuth2ApplicationImpl[3]; array[0] = filterGetByCompanyId_PrevAndNext( session, oAuth2Application, companyId, orderByComparator, true); array[1] = oAuth2Application; array[2] = filterGetByCompanyId_PrevAndNext( session, oAuth2Application, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected OAuth2Application filterGetByCompanyId_PrevAndNext( Session session, OAuth2Application oAuth2Application, 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_OAUTH2APPLICATION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.ORDER_BY_JPQL); } else { sb.append(OAuth2ApplicationModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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, OAuth2ApplicationImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, OAuth2ApplicationImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( oAuth2Application)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the o auth2 applications where companyId = ? from the database. * * @param companyId the company ID */ @Override public void removeByCompanyId(long companyId) { for (OAuth2Application oAuth2Application : findByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(oAuth2Application); } } /** * Returns the number of o auth2 applications where companyId = ?. * * @param companyId the company ID * @return the number of matching o auth2 applications */ @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_OAUTH2APPLICATION_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 o auth2 applications that the user has permission to view where companyId = ?. * * @param companyId the company ID * @return the number of matching o auth2 applications 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_OAUTH2APPLICATION_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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 = "oAuth2Application.companyId = ?"; private FinderPath _finderPathFetchByC_C; private FinderPath _finderPathCountByC_C; /** * Returns the o auth2 application where companyId = ? and clientId = ? or throws a NoSuchOAuth2ApplicationException if it could not be found. * * @param companyId the company ID * @param clientId the client ID * @return the matching o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByC_C(long companyId, String clientId) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByC_C(companyId, clientId); if (oAuth2Application == null) { StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append(", clientId="); sb.append(clientId); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchOAuth2ApplicationException(sb.toString()); } return oAuth2Application; } /** * Returns the o auth2 application where companyId = ? and clientId = ? or returns null if it could not be found. Uses the finder cache. * * @param companyId the company ID * @param clientId the client ID * @return the matching o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application fetchByC_C(long companyId, String clientId) { return fetchByC_C(companyId, clientId, true); } /** * Returns the o auth2 application where companyId = ? and clientId = ? or returns null if it could not be found, optionally using the finder cache. * * @param companyId the company ID * @param clientId the client ID * @param useFinderCache whether to use the finder cache * @return the matching o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application fetchByC_C( long companyId, String clientId, boolean useFinderCache) { clientId = Objects.toString(clientId, ""); Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {companyId, clientId}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByC_C, finderArgs, this); } if (result instanceof OAuth2Application) { OAuth2Application oAuth2Application = (OAuth2Application)result; if ((companyId != oAuth2Application.getCompanyId()) || !Objects.equals(clientId, oAuth2Application.getClientId())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_OAUTH2APPLICATION_WHERE); sb.append(_FINDER_COLUMN_C_C_COMPANYID_2); boolean bindClientId = false; if (clientId.isEmpty()) { sb.append(_FINDER_COLUMN_C_C_CLIENTID_3); } else { bindClientId = true; sb.append(_FINDER_COLUMN_C_C_CLIENTID_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(companyId); if (bindClientId) { queryPos.add(clientId); } List list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByC_C, finderArgs, list); } } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { if (!useFinderCache) { finderArgs = new Object[] {companyId, clientId}; } _log.warn( "OAuth2ApplicationPersistenceImpl.fetchByC_C(long, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } } OAuth2Application oAuth2Application = list.get(0); result = oAuth2Application; cacheResult(oAuth2Application); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (OAuth2Application)result; } } /** * Removes the o auth2 application where companyId = ? and clientId = ? from the database. * * @param companyId the company ID * @param clientId the client ID * @return the o auth2 application that was removed */ @Override public OAuth2Application removeByC_C(long companyId, String clientId) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = findByC_C(companyId, clientId); return remove(oAuth2Application); } /** * Returns the number of o auth2 applications where companyId = ? and clientId = ?. * * @param companyId the company ID * @param clientId the client ID * @return the number of matching o auth2 applications */ @Override public int countByC_C(long companyId, String clientId) { clientId = Objects.toString(clientId, ""); FinderPath finderPath = _finderPathCountByC_C; Object[] finderArgs = new Object[] {companyId, clientId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_OAUTH2APPLICATION_WHERE); sb.append(_FINDER_COLUMN_C_C_COMPANYID_2); boolean bindClientId = false; if (clientId.isEmpty()) { sb.append(_FINDER_COLUMN_C_C_CLIENTID_3); } else { bindClientId = true; sb.append(_FINDER_COLUMN_C_C_CLIENTID_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(companyId); if (bindClientId) { queryPos.add(clientId); } count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "oAuth2Application.companyId = ? AND "; private static final String _FINDER_COLUMN_C_C_CLIENTID_2 = "oAuth2Application.clientId = ?"; private static final String _FINDER_COLUMN_C_C_CLIENTID_3 = "(oAuth2Application.clientId IS NULL OR oAuth2Application.clientId = '')"; private FinderPath _finderPathWithPaginationFindByC_CP; private FinderPath _finderPathWithoutPaginationFindByC_CP; private FinderPath _finderPathCountByC_CP; /** * Returns all the o auth2 applications where companyId = ? and clientProfile = ?. * * @param companyId the company ID * @param clientProfile the client profile * @return the matching o auth2 applications */ @Override public List findByC_CP( long companyId, int clientProfile) { return findByC_CP( companyId, clientProfile, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the o auth2 applications where companyId = ? and clientProfile = ?. * *

* 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param clientProfile the client profile * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of matching o auth2 applications */ @Override public List findByC_CP( long companyId, int clientProfile, int start, int end) { return findByC_CP(companyId, clientProfile, start, end, null); } /** * Returns an ordered range of all the o auth2 applications where companyId = ? and clientProfile = ?. * *

* 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param clientProfile the client profile * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching o auth2 applications */ @Override public List findByC_CP( long companyId, int clientProfile, int start, int end, OrderByComparator orderByComparator) { return findByC_CP( companyId, clientProfile, start, end, orderByComparator, true); } /** * Returns an ordered range of all the o auth2 applications where companyId = ? and clientProfile = ?. * *

* 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param clientProfile the client profile * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (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 o auth2 applications */ @Override public List findByC_CP( long companyId, int clientProfile, 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_CP; finderArgs = new Object[] {companyId, clientProfile}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByC_CP; finderArgs = new Object[] { companyId, clientProfile, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (OAuth2Application oAuth2Application : list) { if ((companyId != oAuth2Application.getCompanyId()) || (clientProfile != oAuth2Application.getClientProfile())) { 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_OAUTH2APPLICATION_WHERE); sb.append(_FINDER_COLUMN_C_CP_COMPANYID_2); sb.append(_FINDER_COLUMN_C_CP_CLIENTPROFILE_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(OAuth2ApplicationModelImpl.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(clientProfile); 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 o auth2 application in the ordered set where companyId = ? and clientProfile = ?. * * @param companyId the company ID * @param clientProfile the client profile * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByC_CP_First( long companyId, int clientProfile, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByC_CP_First( companyId, clientProfile, orderByComparator); if (oAuth2Application != null) { return oAuth2Application; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append(", clientProfile="); sb.append(clientProfile); sb.append("}"); throw new NoSuchOAuth2ApplicationException(sb.toString()); } /** * Returns the first o auth2 application in the ordered set where companyId = ? and clientProfile = ?. * * @param companyId the company ID * @param clientProfile the client profile * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application fetchByC_CP_First( long companyId, int clientProfile, OrderByComparator orderByComparator) { List list = findByC_CP( companyId, clientProfile, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last o auth2 application in the ordered set where companyId = ? and clientProfile = ?. * * @param companyId the company ID * @param clientProfile the client profile * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByC_CP_Last( long companyId, int clientProfile, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByC_CP_Last( companyId, clientProfile, orderByComparator); if (oAuth2Application != null) { return oAuth2Application; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append(", clientProfile="); sb.append(clientProfile); sb.append("}"); throw new NoSuchOAuth2ApplicationException(sb.toString()); } /** * Returns the last o auth2 application in the ordered set where companyId = ? and clientProfile = ?. * * @param companyId the company ID * @param clientProfile the client profile * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application fetchByC_CP_Last( long companyId, int clientProfile, OrderByComparator orderByComparator) { int count = countByC_CP(companyId, clientProfile); if (count == 0) { return null; } List list = findByC_CP( companyId, clientProfile, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the o auth2 applications before and after the current o auth2 application in the ordered set where companyId = ? and clientProfile = ?. * * @param oAuth2ApplicationId the primary key of the current o auth2 application * @param companyId the company ID * @param clientProfile the client profile * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application[] findByC_CP_PrevAndNext( long oAuth2ApplicationId, long companyId, int clientProfile, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = findByPrimaryKey( oAuth2ApplicationId); Session session = null; try { session = openSession(); OAuth2Application[] array = new OAuth2ApplicationImpl[3]; array[0] = getByC_CP_PrevAndNext( session, oAuth2Application, companyId, clientProfile, orderByComparator, true); array[1] = oAuth2Application; array[2] = getByC_CP_PrevAndNext( session, oAuth2Application, companyId, clientProfile, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected OAuth2Application getByC_CP_PrevAndNext( Session session, OAuth2Application oAuth2Application, long companyId, int clientProfile, 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_OAUTH2APPLICATION_WHERE); sb.append(_FINDER_COLUMN_C_CP_COMPANYID_2); sb.append(_FINDER_COLUMN_C_CP_CLIENTPROFILE_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(OAuth2ApplicationModelImpl.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(clientProfile); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( oAuth2Application)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the o auth2 applications that the user has permission to view where companyId = ? and clientProfile = ?. * * @param companyId the company ID * @param clientProfile the client profile * @return the matching o auth2 applications that the user has permission to view */ @Override public List filterFindByC_CP( long companyId, int clientProfile) { return filterFindByC_CP( companyId, clientProfile, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the o auth2 applications that the user has permission to view where companyId = ? and clientProfile = ?. * *

* 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param clientProfile the client profile * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of matching o auth2 applications that the user has permission to view */ @Override public List filterFindByC_CP( long companyId, int clientProfile, int start, int end) { return filterFindByC_CP(companyId, clientProfile, start, end, null); } /** * Returns an ordered range of all the o auth2 applications that the user has permissions to view where companyId = ? and clientProfile = ?. * *

* 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 OAuth2ApplicationModelImpl. *

* * @param companyId the company ID * @param clientProfile the client profile * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching o auth2 applications that the user has permission to view */ @Override public List filterFindByC_CP( long companyId, int clientProfile, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByC_CP( companyId, clientProfile, 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_OAUTH2APPLICATION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_C_CP_COMPANYID_2); sb.append(_FINDER_COLUMN_C_CP_CLIENTPROFILE_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.ORDER_BY_JPQL); } else { sb.append(OAuth2ApplicationModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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, OAuth2ApplicationImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, OAuth2ApplicationImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); queryPos.add(clientProfile); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the o auth2 applications before and after the current o auth2 application in the ordered set of o auth2 applications that the user has permission to view where companyId = ? and clientProfile = ?. * * @param oAuth2ApplicationId the primary key of the current o auth2 application * @param companyId the company ID * @param clientProfile the client profile * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application[] filterFindByC_CP_PrevAndNext( long oAuth2ApplicationId, long companyId, int clientProfile, OrderByComparator orderByComparator) throws NoSuchOAuth2ApplicationException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByC_CP_PrevAndNext( oAuth2ApplicationId, companyId, clientProfile, orderByComparator); } OAuth2Application oAuth2Application = findByPrimaryKey( oAuth2ApplicationId); Session session = null; try { session = openSession(); OAuth2Application[] array = new OAuth2ApplicationImpl[3]; array[0] = filterGetByC_CP_PrevAndNext( session, oAuth2Application, companyId, clientProfile, orderByComparator, true); array[1] = oAuth2Application; array[2] = filterGetByC_CP_PrevAndNext( session, oAuth2Application, companyId, clientProfile, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected OAuth2Application filterGetByC_CP_PrevAndNext( Session session, OAuth2Application oAuth2Application, long companyId, int clientProfile, 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_OAUTH2APPLICATION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_C_CP_COMPANYID_2); sb.append(_FINDER_COLUMN_C_CP_CLIENTPROFILE_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_OAUTH2APPLICATION_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(OAuth2ApplicationModelImpl.ORDER_BY_JPQL); } else { sb.append(OAuth2ApplicationModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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, OAuth2ApplicationImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, OAuth2ApplicationImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); queryPos.add(clientProfile); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( oAuth2Application)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the o auth2 applications where companyId = ? and clientProfile = ? from the database. * * @param companyId the company ID * @param clientProfile the client profile */ @Override public void removeByC_CP(long companyId, int clientProfile) { for (OAuth2Application oAuth2Application : findByC_CP( companyId, clientProfile, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(oAuth2Application); } } /** * Returns the number of o auth2 applications where companyId = ? and clientProfile = ?. * * @param companyId the company ID * @param clientProfile the client profile * @return the number of matching o auth2 applications */ @Override public int countByC_CP(long companyId, int clientProfile) { FinderPath finderPath = _finderPathCountByC_CP; Object[] finderArgs = new Object[] {companyId, clientProfile}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_OAUTH2APPLICATION_WHERE); sb.append(_FINDER_COLUMN_C_CP_COMPANYID_2); sb.append(_FINDER_COLUMN_C_CP_CLIENTPROFILE_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(clientProfile); 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 o auth2 applications that the user has permission to view where companyId = ? and clientProfile = ?. * * @param companyId the company ID * @param clientProfile the client profile * @return the number of matching o auth2 applications that the user has permission to view */ @Override public int filterCountByC_CP(long companyId, int clientProfile) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByC_CP(companyId, clientProfile); } StringBundler sb = new StringBundler(3); sb.append(_FILTER_SQL_COUNT_OAUTH2APPLICATION_WHERE); sb.append(_FINDER_COLUMN_C_CP_COMPANYID_2); sb.append(_FINDER_COLUMN_C_CP_CLIENTPROFILE_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), OAuth2Application.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(clientProfile); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_C_CP_COMPANYID_2 = "oAuth2Application.companyId = ? AND "; private static final String _FINDER_COLUMN_C_CP_CLIENTPROFILE_2 = "oAuth2Application.clientProfile = ?"; private FinderPath _finderPathFetchByERC_C; private FinderPath _finderPathCountByERC_C; /** * Returns the o auth2 application where externalReferenceCode = ? and companyId = ? or throws a NoSuchOAuth2ApplicationException if it could not be found. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the matching o auth2 application * @throws NoSuchOAuth2ApplicationException if a matching o auth2 application could not be found */ @Override public OAuth2Application findByERC_C( String externalReferenceCode, long companyId) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByERC_C( externalReferenceCode, companyId); if (oAuth2Application == 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 NoSuchOAuth2ApplicationException(sb.toString()); } return oAuth2Application; } /** * Returns the o auth2 application 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 o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application fetchByERC_C( String externalReferenceCode, long companyId) { return fetchByERC_C(externalReferenceCode, companyId, true); } /** * Returns the o auth2 application 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 o auth2 application, or null if a matching o auth2 application could not be found */ @Override public OAuth2Application 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 OAuth2Application) { OAuth2Application oAuth2Application = (OAuth2Application)result; if (!Objects.equals( externalReferenceCode, oAuth2Application.getExternalReferenceCode()) || (companyId != oAuth2Application.getCompanyId())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_OAUTH2APPLICATION_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 { OAuth2Application oAuth2Application = list.get(0); result = oAuth2Application; cacheResult(oAuth2Application); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (OAuth2Application)result; } } /** * Removes the o auth2 application where externalReferenceCode = ? and companyId = ? from the database. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the o auth2 application that was removed */ @Override public OAuth2Application removeByERC_C( String externalReferenceCode, long companyId) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = findByERC_C( externalReferenceCode, companyId); return remove(oAuth2Application); } /** * Returns the number of o auth2 applications where externalReferenceCode = ? and companyId = ?. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the number of matching o auth2 applications */ @Override public int countByERC_C(String externalReferenceCode, long companyId) { externalReferenceCode = Objects.toString(externalReferenceCode, ""); FinderPath finderPath = _finderPathCountByERC_C; Object[] finderArgs = new Object[] {externalReferenceCode, companyId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_OAUTH2APPLICATION_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); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2 = "oAuth2Application.externalReferenceCode = ? AND "; private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3 = "(oAuth2Application.externalReferenceCode IS NULL OR oAuth2Application.externalReferenceCode = '') AND "; private static final String _FINDER_COLUMN_ERC_C_COMPANYID_2 = "oAuth2Application.companyId = ?"; public OAuth2ApplicationPersistenceImpl() { Map dbColumnNames = new HashMap(); dbColumnNames.put("uuid", "uuid_"); dbColumnNames.put( "oAuth2ApplicationScopeAliasesId", "oA2AScopeAliasesId"); setDBColumnNames(dbColumnNames); setModelClass(OAuth2Application.class); setModelImplClass(OAuth2ApplicationImpl.class); setModelPKClass(long.class); setTable(OAuth2ApplicationTable.INSTANCE); } /** * Caches the o auth2 application in the entity cache if it is enabled. * * @param oAuth2Application the o auth2 application */ @Override public void cacheResult(OAuth2Application oAuth2Application) { entityCache.putResult( OAuth2ApplicationImpl.class, oAuth2Application.getPrimaryKey(), oAuth2Application); finderCache.putResult( _finderPathFetchByC_C, new Object[] { oAuth2Application.getCompanyId(), oAuth2Application.getClientId() }, oAuth2Application); finderCache.putResult( _finderPathFetchByERC_C, new Object[] { oAuth2Application.getExternalReferenceCode(), oAuth2Application.getCompanyId() }, oAuth2Application); } private int _valueObjectFinderCacheListThreshold; /** * Caches the o auth2 applications in the entity cache if it is enabled. * * @param oAuth2Applications the o auth2 applications */ @Override public void cacheResult(List oAuth2Applications) { if ((_valueObjectFinderCacheListThreshold == 0) || ((_valueObjectFinderCacheListThreshold > 0) && (oAuth2Applications.size() > _valueObjectFinderCacheListThreshold))) { return; } for (OAuth2Application oAuth2Application : oAuth2Applications) { if (entityCache.getResult( OAuth2ApplicationImpl.class, oAuth2Application.getPrimaryKey()) == null) { cacheResult(oAuth2Application); } } } /** * Clears the cache for all o auth2 applications. * *

* The EntityCache and FinderCache are both cleared by this method. *

*/ @Override public void clearCache() { entityCache.clearCache(OAuth2ApplicationImpl.class); finderCache.clearCache(OAuth2ApplicationImpl.class); } /** * Clears the cache for the o auth2 application. * *

* The EntityCache and FinderCache are both cleared by this method. *

*/ @Override public void clearCache(OAuth2Application oAuth2Application) { entityCache.removeResult( OAuth2ApplicationImpl.class, oAuth2Application); } @Override public void clearCache(List oAuth2Applications) { for (OAuth2Application oAuth2Application : oAuth2Applications) { entityCache.removeResult( OAuth2ApplicationImpl.class, oAuth2Application); } } @Override public void clearCache(Set primaryKeys) { finderCache.clearCache(OAuth2ApplicationImpl.class); for (Serializable primaryKey : primaryKeys) { entityCache.removeResult(OAuth2ApplicationImpl.class, primaryKey); } } protected void cacheUniqueFindersCache( OAuth2ApplicationModelImpl oAuth2ApplicationModelImpl) { Object[] args = new Object[] { oAuth2ApplicationModelImpl.getCompanyId(), oAuth2ApplicationModelImpl.getClientId() }; finderCache.putResult(_finderPathCountByC_C, args, Long.valueOf(1)); finderCache.putResult( _finderPathFetchByC_C, args, oAuth2ApplicationModelImpl); args = new Object[] { oAuth2ApplicationModelImpl.getExternalReferenceCode(), oAuth2ApplicationModelImpl.getCompanyId() }; finderCache.putResult(_finderPathCountByERC_C, args, Long.valueOf(1)); finderCache.putResult( _finderPathFetchByERC_C, args, oAuth2ApplicationModelImpl); } /** * Creates a new o auth2 application with the primary key. Does not add the o auth2 application to the database. * * @param oAuth2ApplicationId the primary key for the new o auth2 application * @return the new o auth2 application */ @Override public OAuth2Application create(long oAuth2ApplicationId) { OAuth2Application oAuth2Application = new OAuth2ApplicationImpl(); oAuth2Application.setNew(true); oAuth2Application.setPrimaryKey(oAuth2ApplicationId); String uuid = PortalUUIDUtil.generate(); oAuth2Application.setUuid(uuid); oAuth2Application.setCompanyId(CompanyThreadLocal.getCompanyId()); return oAuth2Application; } /** * Removes the o auth2 application with the primary key from the database. Also notifies the appropriate model listeners. * * @param oAuth2ApplicationId the primary key of the o auth2 application * @return the o auth2 application that was removed * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application remove(long oAuth2ApplicationId) throws NoSuchOAuth2ApplicationException { return remove((Serializable)oAuth2ApplicationId); } /** * Removes the o auth2 application with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the o auth2 application * @return the o auth2 application that was removed * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application remove(Serializable primaryKey) throws NoSuchOAuth2ApplicationException { Session session = null; try { session = openSession(); OAuth2Application oAuth2Application = (OAuth2Application)session.get( OAuth2ApplicationImpl.class, primaryKey); if (oAuth2Application == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchOAuth2ApplicationException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(oAuth2Application); } catch (NoSuchOAuth2ApplicationException noSuchEntityException) { throw noSuchEntityException; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } @Override protected OAuth2Application removeImpl( OAuth2Application oAuth2Application) { Session session = null; try { session = openSession(); if (!session.contains(oAuth2Application)) { oAuth2Application = (OAuth2Application)session.get( OAuth2ApplicationImpl.class, oAuth2Application.getPrimaryKeyObj()); } if (oAuth2Application != null) { session.delete(oAuth2Application); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } if (oAuth2Application != null) { clearCache(oAuth2Application); } return oAuth2Application; } @Override public OAuth2Application updateImpl(OAuth2Application oAuth2Application) { boolean isNew = oAuth2Application.isNew(); if (!(oAuth2Application instanceof OAuth2ApplicationModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(oAuth2Application.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( oAuth2Application); throw new IllegalArgumentException( "Implement ModelWrapper in oAuth2Application proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom OAuth2Application implementation " + oAuth2Application.getClass()); } OAuth2ApplicationModelImpl oAuth2ApplicationModelImpl = (OAuth2ApplicationModelImpl)oAuth2Application; if (Validator.isNull(oAuth2Application.getUuid())) { String uuid = PortalUUIDUtil.generate(); oAuth2Application.setUuid(uuid); } if (Validator.isNull(oAuth2Application.getExternalReferenceCode())) { oAuth2Application.setExternalReferenceCode( oAuth2Application.getUuid()); } else { if (!Objects.equals( oAuth2ApplicationModelImpl.getColumnOriginalValue( "externalReferenceCode"), oAuth2Application.getExternalReferenceCode())) { long userId = GetterUtil.getLong( PrincipalThreadLocal.getName()); if (userId > 0) { long companyId = oAuth2Application.getCompanyId(); long groupId = 0; long classPK = 0; if (!isNew) { classPK = oAuth2Application.getPrimaryKey(); } try { oAuth2Application.setExternalReferenceCode( SanitizerUtil.sanitize( companyId, groupId, userId, OAuth2Application.class.getName(), classPK, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL, oAuth2Application.getExternalReferenceCode(), null)); } catch (SanitizerException sanitizerException) { throw new SystemException(sanitizerException); } } } OAuth2Application ercOAuth2Application = fetchByERC_C( oAuth2Application.getExternalReferenceCode(), oAuth2Application.getCompanyId()); if (isNew) { if (ercOAuth2Application != null) { throw new DuplicateOAuth2ApplicationExternalReferenceCodeException( "Duplicate o auth2 application with external reference code " + oAuth2Application.getExternalReferenceCode() + " and company " + oAuth2Application.getCompanyId()); } } else { if ((ercOAuth2Application != null) && (oAuth2Application.getOAuth2ApplicationId() != ercOAuth2Application.getOAuth2ApplicationId())) { throw new DuplicateOAuth2ApplicationExternalReferenceCodeException( "Duplicate o auth2 application with external reference code " + oAuth2Application.getExternalReferenceCode() + " and company " + oAuth2Application.getCompanyId()); } } } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date date = new Date(); if (isNew && (oAuth2Application.getCreateDate() == null)) { if (serviceContext == null) { oAuth2Application.setCreateDate(date); } else { oAuth2Application.setCreateDate( serviceContext.getCreateDate(date)); } } if (!oAuth2ApplicationModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { oAuth2Application.setModifiedDate(date); } else { oAuth2Application.setModifiedDate( serviceContext.getModifiedDate(date)); } } Session session = null; try { session = openSession(); if (isNew) { session.save(oAuth2Application); } else { oAuth2Application = (OAuth2Application)session.merge( oAuth2Application); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } entityCache.putResult( OAuth2ApplicationImpl.class, oAuth2ApplicationModelImpl, false, true); cacheUniqueFindersCache(oAuth2ApplicationModelImpl); if (isNew) { oAuth2Application.setNew(false); } oAuth2Application.resetOriginalValues(); return oAuth2Application; } /** * Returns the o auth2 application 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 o auth2 application * @return the o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application findByPrimaryKey(Serializable primaryKey) throws NoSuchOAuth2ApplicationException { OAuth2Application oAuth2Application = fetchByPrimaryKey(primaryKey); if (oAuth2Application == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchOAuth2ApplicationException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return oAuth2Application; } /** * Returns the o auth2 application with the primary key or throws a NoSuchOAuth2ApplicationException if it could not be found. * * @param oAuth2ApplicationId the primary key of the o auth2 application * @return the o auth2 application * @throws NoSuchOAuth2ApplicationException if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application findByPrimaryKey(long oAuth2ApplicationId) throws NoSuchOAuth2ApplicationException { return findByPrimaryKey((Serializable)oAuth2ApplicationId); } /** * Returns the o auth2 application with the primary key or returns null if it could not be found. * * @param oAuth2ApplicationId the primary key of the o auth2 application * @return the o auth2 application, or null if a o auth2 application with the primary key could not be found */ @Override public OAuth2Application fetchByPrimaryKey(long oAuth2ApplicationId) { return fetchByPrimaryKey((Serializable)oAuth2ApplicationId); } /** * Returns all the o auth2 applications. * * @return the o auth2 applications */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the o auth2 applications. * *

* 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 OAuth2ApplicationModelImpl. *

* * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @return the range of o auth2 applications */ @Override public List findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the o auth2 applications. * *

* 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 OAuth2ApplicationModelImpl. *

* * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of o auth2 applications */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the o auth2 applications. * *

* 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 OAuth2ApplicationModelImpl. *

* * @param start the lower bound of the range of o auth2 applications * @param end the upper bound of the range of o auth2 applications (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 o auth2 applications */ @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_OAUTH2APPLICATION); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_OAUTH2APPLICATION; sql = sql.concat(OAuth2ApplicationModelImpl.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 o auth2 applications from the database. * */ @Override public void removeAll() { for (OAuth2Application oAuth2Application : findAll()) { remove(oAuth2Application); } } /** * Returns the number of o auth2 applications. * * @return the number of o auth2 applications */ @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_OAUTH2APPLICATION); 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 "oAuth2ApplicationId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_OAUTH2APPLICATION; } @Override protected Map getTableColumnsMap() { return OAuth2ApplicationModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the o auth2 application 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); _finderPathFetchByC_C = new FinderPath( FINDER_CLASS_NAME_ENTITY, "fetchByC_C", new String[] {Long.class.getName(), String.class.getName()}, new String[] {"companyId", "clientId"}, true); _finderPathCountByC_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C", new String[] {Long.class.getName(), String.class.getName()}, new String[] {"companyId", "clientId"}, false); _finderPathWithPaginationFindByC_CP = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_CP", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"companyId", "clientProfile"}, true); _finderPathWithoutPaginationFindByC_CP = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_CP", new String[] {Long.class.getName(), Integer.class.getName()}, new String[] {"companyId", "clientProfile"}, true); _finderPathCountByC_CP = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_CP", new String[] {Long.class.getName(), Integer.class.getName()}, new String[] {"companyId", "clientProfile"}, false); _finderPathFetchByERC_C = new FinderPath( FINDER_CLASS_NAME_ENTITY, "fetchByERC_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"externalReferenceCode", "companyId"}, true); _finderPathCountByERC_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByERC_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"externalReferenceCode", "companyId"}, false); OAuth2ApplicationUtil.setPersistence(this); } @Deactivate public void deactivate() { OAuth2ApplicationUtil.setPersistence(null); entityCache.removeCache(OAuth2ApplicationImpl.class.getName()); } @Override @Reference( target = OAuthTwoPersistenceConstants.SERVICE_CONFIGURATION_FILTER, unbind = "-" ) public void setConfiguration(Configuration configuration) { } @Override @Reference( target = OAuthTwoPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setDataSource(DataSource dataSource) { super.setDataSource(dataSource); } @Override @Reference( target = OAuthTwoPersistenceConstants.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_OAUTH2APPLICATION = "SELECT oAuth2Application FROM OAuth2Application oAuth2Application"; private static final String _SQL_SELECT_OAUTH2APPLICATION_WHERE = "SELECT oAuth2Application FROM OAuth2Application oAuth2Application WHERE "; private static final String _SQL_COUNT_OAUTH2APPLICATION = "SELECT COUNT(oAuth2Application) FROM OAuth2Application oAuth2Application"; private static final String _SQL_COUNT_OAUTH2APPLICATION_WHERE = "SELECT COUNT(oAuth2Application) FROM OAuth2Application oAuth2Application WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "oAuth2Application.oAuth2ApplicationId"; private static final String _FILTER_SQL_SELECT_OAUTH2APPLICATION_WHERE = "SELECT DISTINCT {oAuth2Application.*} FROM OAuth2Application oAuth2Application WHERE "; private static final String _FILTER_SQL_SELECT_OAUTH2APPLICATION_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {OAuth2Application.*} FROM (SELECT DISTINCT oAuth2Application.oAuth2ApplicationId FROM OAuth2Application oAuth2Application WHERE "; private static final String _FILTER_SQL_SELECT_OAUTH2APPLICATION_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN OAuth2Application ON TEMP_TABLE.oAuth2ApplicationId = OAuth2Application.oAuth2ApplicationId"; private static final String _FILTER_SQL_COUNT_OAUTH2APPLICATION_WHERE = "SELECT COUNT(DISTINCT oAuth2Application.oAuth2ApplicationId) AS COUNT_VALUE FROM OAuth2Application oAuth2Application WHERE "; private static final String _FILTER_ENTITY_ALIAS = "oAuth2Application"; private static final String _FILTER_ENTITY_TABLE = "OAuth2Application"; private static final String _ORDER_BY_ENTITY_ALIAS = "oAuth2Application."; private static final String _ORDER_BY_ENTITY_TABLE = "OAuth2Application."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No OAuth2Application exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No OAuth2Application exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( OAuth2ApplicationPersistenceImpl.class); private static final Set _badColumnNames = SetUtil.fromArray( new String[] {"uuid", "oAuth2ApplicationScopeAliasesId"}); @Override protected FinderCache getFinderCache() { return finderCache; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy