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

com.liferay.invitation.invite.members.service.persistence.impl.MemberRequestPersistenceImpl Maven / Gradle / Ivy

There is a newer version: 7.0.41
Show newest version
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.invitation.invite.members.service.persistence.impl;

import com.liferay.invitation.invite.members.exception.NoSuchMemberRequestException;
import com.liferay.invitation.invite.members.model.MemberRequest;
import com.liferay.invitation.invite.members.model.MemberRequestTable;
import com.liferay.invitation.invite.members.model.impl.MemberRequestImpl;
import com.liferay.invitation.invite.members.model.impl.MemberRequestModelImpl;
import com.liferay.invitation.invite.members.service.persistence.MemberRequestPersistence;
import com.liferay.invitation.invite.members.service.persistence.impl.constants.IMPersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.dao.orm.ArgumentsResolver;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.BaseModel;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
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.MapUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringUtil;

import java.io.Serializable;

import java.lang.reflect.InvocationHandler;

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

import javax.sql.DataSource;

import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
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 member request service.
 *
 * 

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

* * @author Brian Wing Shun Chan * @generated */ @Component(service = MemberRequestPersistence.class) public class MemberRequestPersistenceImpl extends BasePersistenceImpl implements MemberRequestPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use MemberRequestUtil to access the member request persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = MemberRequestImpl.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 _finderPathFetchByKey; private FinderPath _finderPathCountByKey; /** * Returns the member request where key = ? or throws a NoSuchMemberRequestException if it could not be found. * * @param key the key * @return the matching member request * @throws NoSuchMemberRequestException if a matching member request could not be found */ @Override public MemberRequest findByKey(String key) throws NoSuchMemberRequestException { MemberRequest memberRequest = fetchByKey(key); if (memberRequest == null) { StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("key="); sb.append(key); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchMemberRequestException(sb.toString()); } return memberRequest; } /** * Returns the member request where key = ? or returns null if it could not be found. Uses the finder cache. * * @param key the key * @return the matching member request, or null if a matching member request could not be found */ @Override public MemberRequest fetchByKey(String key) { return fetchByKey(key, true); } /** * Returns the member request where key = ? or returns null if it could not be found, optionally using the finder cache. * * @param key the key * @param useFinderCache whether to use the finder cache * @return the matching member request, or null if a matching member request could not be found */ @Override public MemberRequest fetchByKey(String key, boolean useFinderCache) { key = Objects.toString(key, ""); Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {key}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByKey, finderArgs, this); } if (result instanceof MemberRequest) { MemberRequest memberRequest = (MemberRequest)result; if (!Objects.equals(key, memberRequest.getKey())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_SELECT_MEMBERREQUEST_WHERE); boolean bindKey = false; if (key.isEmpty()) { sb.append(_FINDER_COLUMN_KEY_KEY_3); } else { bindKey = true; sb.append(_FINDER_COLUMN_KEY_KEY_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindKey) { queryPos.add(key); } List list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByKey, finderArgs, list); } } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { if (!useFinderCache) { finderArgs = new Object[] {key}; } _log.warn( "MemberRequestPersistenceImpl.fetchByKey(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."); } } MemberRequest memberRequest = list.get(0); result = memberRequest; cacheResult(memberRequest); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (MemberRequest)result; } } /** * Removes the member request where key = ? from the database. * * @param key the key * @return the member request that was removed */ @Override public MemberRequest removeByKey(String key) throws NoSuchMemberRequestException { MemberRequest memberRequest = findByKey(key); return remove(memberRequest); } /** * Returns the number of member requests where key = ?. * * @param key the key * @return the number of matching member requests */ @Override public int countByKey(String key) { key = Objects.toString(key, ""); FinderPath finderPath = _finderPathCountByKey; Object[] finderArgs = new Object[] {key}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_MEMBERREQUEST_WHERE); boolean bindKey = false; if (key.isEmpty()) { sb.append(_FINDER_COLUMN_KEY_KEY_3); } else { bindKey = true; sb.append(_FINDER_COLUMN_KEY_KEY_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindKey) { queryPos.add(key); } 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_KEY_KEY_2 = "memberRequest.key = ?"; private static final String _FINDER_COLUMN_KEY_KEY_3 = "(memberRequest.key IS NULL OR memberRequest.key = '')"; private FinderPath _finderPathWithPaginationFindByReceiverUserId; private FinderPath _finderPathWithoutPaginationFindByReceiverUserId; private FinderPath _finderPathCountByReceiverUserId; /** * Returns all the member requests where receiverUserId = ?. * * @param receiverUserId the receiver user ID * @return the matching member requests */ @Override public List findByReceiverUserId(long receiverUserId) { return findByReceiverUserId( receiverUserId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the member requests where receiverUserId = ?. * *

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

* * @param receiverUserId the receiver user ID * @param start the lower bound of the range of member requests * @param end the upper bound of the range of member requests (not inclusive) * @return the range of matching member requests */ @Override public List findByReceiverUserId( long receiverUserId, int start, int end) { return findByReceiverUserId(receiverUserId, start, end, null); } /** * Returns an ordered range of all the member requests where receiverUserId = ?. * *

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

* * @param receiverUserId the receiver user ID * @param start the lower bound of the range of member requests * @param end the upper bound of the range of member requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching member requests */ @Override public List findByReceiverUserId( long receiverUserId, int start, int end, OrderByComparator orderByComparator) { return findByReceiverUserId( receiverUserId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the member requests where receiverUserId = ?. * *

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

* * @param receiverUserId the receiver user ID * @param start the lower bound of the range of member requests * @param end the upper bound of the range of member requests (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 member requests */ @Override public List findByReceiverUserId( long receiverUserId, 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 = _finderPathWithoutPaginationFindByReceiverUserId; finderArgs = new Object[] {receiverUserId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByReceiverUserId; finderArgs = new Object[] { receiverUserId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MemberRequest memberRequest : list) { if (receiverUserId != memberRequest.getReceiverUserId()) { 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_MEMBERREQUEST_WHERE); sb.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(MemberRequestModelImpl.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(receiverUserId); 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 member request in the ordered set where receiverUserId = ?. * * @param receiverUserId the receiver user ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching member request * @throws NoSuchMemberRequestException if a matching member request could not be found */ @Override public MemberRequest findByReceiverUserId_First( long receiverUserId, OrderByComparator orderByComparator) throws NoSuchMemberRequestException { MemberRequest memberRequest = fetchByReceiverUserId_First( receiverUserId, orderByComparator); if (memberRequest != null) { return memberRequest; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("receiverUserId="); sb.append(receiverUserId); sb.append("}"); throw new NoSuchMemberRequestException(sb.toString()); } /** * Returns the first member request in the ordered set where receiverUserId = ?. * * @param receiverUserId the receiver user ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching member request, or null if a matching member request could not be found */ @Override public MemberRequest fetchByReceiverUserId_First( long receiverUserId, OrderByComparator orderByComparator) { List list = findByReceiverUserId( receiverUserId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last member request in the ordered set where receiverUserId = ?. * * @param receiverUserId the receiver user ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching member request * @throws NoSuchMemberRequestException if a matching member request could not be found */ @Override public MemberRequest findByReceiverUserId_Last( long receiverUserId, OrderByComparator orderByComparator) throws NoSuchMemberRequestException { MemberRequest memberRequest = fetchByReceiverUserId_Last( receiverUserId, orderByComparator); if (memberRequest != null) { return memberRequest; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("receiverUserId="); sb.append(receiverUserId); sb.append("}"); throw new NoSuchMemberRequestException(sb.toString()); } /** * Returns the last member request in the ordered set where receiverUserId = ?. * * @param receiverUserId the receiver user ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching member request, or null if a matching member request could not be found */ @Override public MemberRequest fetchByReceiverUserId_Last( long receiverUserId, OrderByComparator orderByComparator) { int count = countByReceiverUserId(receiverUserId); if (count == 0) { return null; } List list = findByReceiverUserId( receiverUserId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the member requests before and after the current member request in the ordered set where receiverUserId = ?. * * @param memberRequestId the primary key of the current member request * @param receiverUserId the receiver user ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next member request * @throws NoSuchMemberRequestException if a member request with the primary key could not be found */ @Override public MemberRequest[] findByReceiverUserId_PrevAndNext( long memberRequestId, long receiverUserId, OrderByComparator orderByComparator) throws NoSuchMemberRequestException { MemberRequest memberRequest = findByPrimaryKey(memberRequestId); Session session = null; try { session = openSession(); MemberRequest[] array = new MemberRequestImpl[3]; array[0] = getByReceiverUserId_PrevAndNext( session, memberRequest, receiverUserId, orderByComparator, true); array[1] = memberRequest; array[2] = getByReceiverUserId_PrevAndNext( session, memberRequest, receiverUserId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected MemberRequest getByReceiverUserId_PrevAndNext( Session session, MemberRequest memberRequest, long receiverUserId, 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_MEMBERREQUEST_WHERE); sb.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_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(MemberRequestModelImpl.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(receiverUserId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( memberRequest)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the member requests where receiverUserId = ? from the database. * * @param receiverUserId the receiver user ID */ @Override public void removeByReceiverUserId(long receiverUserId) { for (MemberRequest memberRequest : findByReceiverUserId( receiverUserId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(memberRequest); } } /** * Returns the number of member requests where receiverUserId = ?. * * @param receiverUserId the receiver user ID * @return the number of matching member requests */ @Override public int countByReceiverUserId(long receiverUserId) { FinderPath finderPath = _finderPathCountByReceiverUserId; Object[] finderArgs = new Object[] {receiverUserId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_MEMBERREQUEST_WHERE); sb.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(receiverUserId); 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_RECEIVERUSERID_RECEIVERUSERID_2 = "memberRequest.receiverUserId = ?"; private FinderPath _finderPathWithPaginationFindByR_S; private FinderPath _finderPathWithoutPaginationFindByR_S; private FinderPath _finderPathCountByR_S; /** * Returns all the member requests where receiverUserId = ? and status = ?. * * @param receiverUserId the receiver user ID * @param status the status * @return the matching member requests */ @Override public List findByR_S(long receiverUserId, int status) { return findByR_S( receiverUserId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the member requests where receiverUserId = ? and status = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from MemberRequestModelImpl. *

* * @param receiverUserId the receiver user ID * @param status the status * @param start the lower bound of the range of member requests * @param end the upper bound of the range of member requests (not inclusive) * @return the range of matching member requests */ @Override public List findByR_S( long receiverUserId, int status, int start, int end) { return findByR_S(receiverUserId, status, start, end, null); } /** * Returns an ordered range of all the member requests where receiverUserId = ? and status = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from MemberRequestModelImpl. *

* * @param receiverUserId the receiver user ID * @param status the status * @param start the lower bound of the range of member requests * @param end the upper bound of the range of member requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching member requests */ @Override public List findByR_S( long receiverUserId, int status, int start, int end, OrderByComparator orderByComparator) { return findByR_S( receiverUserId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the member requests where receiverUserId = ? and status = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent, then the query will include the default ORDER BY logic from MemberRequestModelImpl. *

* * @param receiverUserId the receiver user ID * @param status the status * @param start the lower bound of the range of member requests * @param end the upper bound of the range of member requests (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 member requests */ @Override public List findByR_S( long receiverUserId, int status, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByR_S; finderArgs = new Object[] {receiverUserId, status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByR_S; finderArgs = new Object[] { receiverUserId, status, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MemberRequest memberRequest : list) { if ((receiverUserId != memberRequest.getReceiverUserId()) || (status != memberRequest.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_MEMBERREQUEST_WHERE); sb.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2); sb.append(_FINDER_COLUMN_R_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(MemberRequestModelImpl.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(receiverUserId); queryPos.add(status); list = (List)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first member request in the ordered set where receiverUserId = ? and status = ?. * * @param receiverUserId the receiver user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching member request * @throws NoSuchMemberRequestException if a matching member request could not be found */ @Override public MemberRequest findByR_S_First( long receiverUserId, int status, OrderByComparator orderByComparator) throws NoSuchMemberRequestException { MemberRequest memberRequest = fetchByR_S_First( receiverUserId, status, orderByComparator); if (memberRequest != null) { return memberRequest; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("receiverUserId="); sb.append(receiverUserId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchMemberRequestException(sb.toString()); } /** * Returns the first member request in the ordered set where receiverUserId = ? and status = ?. * * @param receiverUserId the receiver user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching member request, or null if a matching member request could not be found */ @Override public MemberRequest fetchByR_S_First( long receiverUserId, int status, OrderByComparator orderByComparator) { List list = findByR_S( receiverUserId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last member request in the ordered set where receiverUserId = ? and status = ?. * * @param receiverUserId the receiver user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching member request * @throws NoSuchMemberRequestException if a matching member request could not be found */ @Override public MemberRequest findByR_S_Last( long receiverUserId, int status, OrderByComparator orderByComparator) throws NoSuchMemberRequestException { MemberRequest memberRequest = fetchByR_S_Last( receiverUserId, status, orderByComparator); if (memberRequest != null) { return memberRequest; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("receiverUserId="); sb.append(receiverUserId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchMemberRequestException(sb.toString()); } /** * Returns the last member request in the ordered set where receiverUserId = ? and status = ?. * * @param receiverUserId the receiver user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching member request, or null if a matching member request could not be found */ @Override public MemberRequest fetchByR_S_Last( long receiverUserId, int status, OrderByComparator orderByComparator) { int count = countByR_S(receiverUserId, status); if (count == 0) { return null; } List list = findByR_S( receiverUserId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the member requests before and after the current member request in the ordered set where receiverUserId = ? and status = ?. * * @param memberRequestId the primary key of the current member request * @param receiverUserId the receiver user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next member request * @throws NoSuchMemberRequestException if a member request with the primary key could not be found */ @Override public MemberRequest[] findByR_S_PrevAndNext( long memberRequestId, long receiverUserId, int status, OrderByComparator orderByComparator) throws NoSuchMemberRequestException { MemberRequest memberRequest = findByPrimaryKey(memberRequestId); Session session = null; try { session = openSession(); MemberRequest[] array = new MemberRequestImpl[3]; array[0] = getByR_S_PrevAndNext( session, memberRequest, receiverUserId, status, orderByComparator, true); array[1] = memberRequest; array[2] = getByR_S_PrevAndNext( session, memberRequest, receiverUserId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected MemberRequest getByR_S_PrevAndNext( Session session, MemberRequest memberRequest, long receiverUserId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_MEMBERREQUEST_WHERE); sb.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2); sb.append(_FINDER_COLUMN_R_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(MemberRequestModelImpl.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(receiverUserId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( memberRequest)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the member requests where receiverUserId = ? and status = ? from the database. * * @param receiverUserId the receiver user ID * @param status the status */ @Override public void removeByR_S(long receiverUserId, int status) { for (MemberRequest memberRequest : findByR_S( receiverUserId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(memberRequest); } } /** * Returns the number of member requests where receiverUserId = ? and status = ?. * * @param receiverUserId the receiver user ID * @param status the status * @return the number of matching member requests */ @Override public int countByR_S(long receiverUserId, int status) { FinderPath finderPath = _finderPathCountByR_S; Object[] finderArgs = new Object[] {receiverUserId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_MEMBERREQUEST_WHERE); sb.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2); sb.append(_FINDER_COLUMN_R_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(receiverUserId); queryPos.add(status); 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_R_S_RECEIVERUSERID_2 = "memberRequest.receiverUserId = ? AND "; private static final String _FINDER_COLUMN_R_S_STATUS_2 = "memberRequest.status = ?"; private FinderPath _finderPathFetchByG_R_S; private FinderPath _finderPathCountByG_R_S; /** * Returns the member request where groupId = ? and receiverUserId = ? and status = ? or throws a NoSuchMemberRequestException if it could not be found. * * @param groupId the group ID * @param receiverUserId the receiver user ID * @param status the status * @return the matching member request * @throws NoSuchMemberRequestException if a matching member request could not be found */ @Override public MemberRequest findByG_R_S( long groupId, long receiverUserId, int status) throws NoSuchMemberRequestException { MemberRequest memberRequest = fetchByG_R_S( groupId, receiverUserId, status); if (memberRequest == null) { StringBundler sb = new StringBundler(8); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", receiverUserId="); sb.append(receiverUserId); sb.append(", status="); sb.append(status); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchMemberRequestException(sb.toString()); } return memberRequest; } /** * Returns the member request where groupId = ? and receiverUserId = ? and status = ? or returns null if it could not be found. Uses the finder cache. * * @param groupId the group ID * @param receiverUserId the receiver user ID * @param status the status * @return the matching member request, or null if a matching member request could not be found */ @Override public MemberRequest fetchByG_R_S( long groupId, long receiverUserId, int status) { return fetchByG_R_S(groupId, receiverUserId, status, true); } /** * Returns the member request where groupId = ? and receiverUserId = ? and status = ? or returns null if it could not be found, optionally using the finder cache. * * @param groupId the group ID * @param receiverUserId the receiver user ID * @param status the status * @param useFinderCache whether to use the finder cache * @return the matching member request, or null if a matching member request could not be found */ @Override public MemberRequest fetchByG_R_S( long groupId, long receiverUserId, int status, boolean useFinderCache) { Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {groupId, receiverUserId, status}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByG_R_S, finderArgs, this); } if (result instanceof MemberRequest) { MemberRequest memberRequest = (MemberRequest)result; if ((groupId != memberRequest.getGroupId()) || (receiverUserId != memberRequest.getReceiverUserId()) || (status != memberRequest.getStatus())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(5); sb.append(_SQL_SELECT_MEMBERREQUEST_WHERE); sb.append(_FINDER_COLUMN_G_R_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_R_S_RECEIVERUSERID_2); sb.append(_FINDER_COLUMN_G_R_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(receiverUserId); queryPos.add(status); List list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByG_R_S, finderArgs, list); } } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { if (!useFinderCache) { finderArgs = new Object[] { groupId, receiverUserId, status }; } _log.warn( "MemberRequestPersistenceImpl.fetchByG_R_S(long, long, int, 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."); } } MemberRequest memberRequest = list.get(0); result = memberRequest; cacheResult(memberRequest); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (MemberRequest)result; } } /** * Removes the member request where groupId = ? and receiverUserId = ? and status = ? from the database. * * @param groupId the group ID * @param receiverUserId the receiver user ID * @param status the status * @return the member request that was removed */ @Override public MemberRequest removeByG_R_S( long groupId, long receiverUserId, int status) throws NoSuchMemberRequestException { MemberRequest memberRequest = findByG_R_S( groupId, receiverUserId, status); return remove(memberRequest); } /** * Returns the number of member requests where groupId = ? and receiverUserId = ? and status = ?. * * @param groupId the group ID * @param receiverUserId the receiver user ID * @param status the status * @return the number of matching member requests */ @Override public int countByG_R_S(long groupId, long receiverUserId, int status) { FinderPath finderPath = _finderPathCountByG_R_S; Object[] finderArgs = new Object[] {groupId, receiverUserId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_COUNT_MEMBERREQUEST_WHERE); sb.append(_FINDER_COLUMN_G_R_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_R_S_RECEIVERUSERID_2); sb.append(_FINDER_COLUMN_G_R_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(receiverUserId); queryPos.add(status); 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_G_R_S_GROUPID_2 = "memberRequest.groupId = ? AND "; private static final String _FINDER_COLUMN_G_R_S_RECEIVERUSERID_2 = "memberRequest.receiverUserId = ? AND "; private static final String _FINDER_COLUMN_G_R_S_STATUS_2 = "memberRequest.status = ?"; public MemberRequestPersistenceImpl() { Map dbColumnNames = new HashMap(); dbColumnNames.put("key", "key_"); setDBColumnNames(dbColumnNames); setModelClass(MemberRequest.class); setModelImplClass(MemberRequestImpl.class); setModelPKClass(long.class); setTable(MemberRequestTable.INSTANCE); } /** * Caches the member request in the entity cache if it is enabled. * * @param memberRequest the member request */ @Override public void cacheResult(MemberRequest memberRequest) { entityCache.putResult( MemberRequestImpl.class, memberRequest.getPrimaryKey(), memberRequest); finderCache.putResult( _finderPathFetchByKey, new Object[] {memberRequest.getKey()}, memberRequest); finderCache.putResult( _finderPathFetchByG_R_S, new Object[] { memberRequest.getGroupId(), memberRequest.getReceiverUserId(), memberRequest.getStatus() }, memberRequest); } /** * Caches the member requests in the entity cache if it is enabled. * * @param memberRequests the member requests */ @Override public void cacheResult(List memberRequests) { for (MemberRequest memberRequest : memberRequests) { if (entityCache.getResult( MemberRequestImpl.class, memberRequest.getPrimaryKey()) == null) { cacheResult(memberRequest); } } } /** * Clears the cache for all member requests. * *

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

*/ @Override public void clearCache() { entityCache.clearCache(MemberRequestImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the member request. * *

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

*/ @Override public void clearCache(MemberRequest memberRequest) { entityCache.removeResult(MemberRequestImpl.class, memberRequest); } @Override public void clearCache(List memberRequests) { for (MemberRequest memberRequest : memberRequests) { entityCache.removeResult(MemberRequestImpl.class, memberRequest); } } @Override public void clearCache(Set primaryKeys) { finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (Serializable primaryKey : primaryKeys) { entityCache.removeResult(MemberRequestImpl.class, primaryKey); } } protected void cacheUniqueFindersCache( MemberRequestModelImpl memberRequestModelImpl) { Object[] args = new Object[] {memberRequestModelImpl.getKey()}; finderCache.putResult( _finderPathCountByKey, args, Long.valueOf(1), false); finderCache.putResult( _finderPathFetchByKey, args, memberRequestModelImpl, false); args = new Object[] { memberRequestModelImpl.getGroupId(), memberRequestModelImpl.getReceiverUserId(), memberRequestModelImpl.getStatus() }; finderCache.putResult( _finderPathCountByG_R_S, args, Long.valueOf(1), false); finderCache.putResult( _finderPathFetchByG_R_S, args, memberRequestModelImpl, false); } /** * Creates a new member request with the primary key. Does not add the member request to the database. * * @param memberRequestId the primary key for the new member request * @return the new member request */ @Override public MemberRequest create(long memberRequestId) { MemberRequest memberRequest = new MemberRequestImpl(); memberRequest.setNew(true); memberRequest.setPrimaryKey(memberRequestId); memberRequest.setCompanyId(CompanyThreadLocal.getCompanyId()); return memberRequest; } /** * Removes the member request with the primary key from the database. Also notifies the appropriate model listeners. * * @param memberRequestId the primary key of the member request * @return the member request that was removed * @throws NoSuchMemberRequestException if a member request with the primary key could not be found */ @Override public MemberRequest remove(long memberRequestId) throws NoSuchMemberRequestException { return remove((Serializable)memberRequestId); } /** * Removes the member request with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the member request * @return the member request that was removed * @throws NoSuchMemberRequestException if a member request with the primary key could not be found */ @Override public MemberRequest remove(Serializable primaryKey) throws NoSuchMemberRequestException { Session session = null; try { session = openSession(); MemberRequest memberRequest = (MemberRequest)session.get( MemberRequestImpl.class, primaryKey); if (memberRequest == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchMemberRequestException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(memberRequest); } catch (NoSuchMemberRequestException noSuchEntityException) { throw noSuchEntityException; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } @Override protected MemberRequest removeImpl(MemberRequest memberRequest) { Session session = null; try { session = openSession(); if (!session.contains(memberRequest)) { memberRequest = (MemberRequest)session.get( MemberRequestImpl.class, memberRequest.getPrimaryKeyObj()); } if (memberRequest != null) { session.delete(memberRequest); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } if (memberRequest != null) { clearCache(memberRequest); } return memberRequest; } @Override public MemberRequest updateImpl(MemberRequest memberRequest) { boolean isNew = memberRequest.isNew(); if (!(memberRequest instanceof MemberRequestModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(memberRequest.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( memberRequest); throw new IllegalArgumentException( "Implement ModelWrapper in memberRequest proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom MemberRequest implementation " + memberRequest.getClass()); } MemberRequestModelImpl memberRequestModelImpl = (MemberRequestModelImpl)memberRequest; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (memberRequest.getCreateDate() == null)) { if (serviceContext == null) { memberRequest.setCreateDate(now); } else { memberRequest.setCreateDate(serviceContext.getCreateDate(now)); } } if (!memberRequestModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { memberRequest.setModifiedDate(now); } else { memberRequest.setModifiedDate( serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (isNew) { session.save(memberRequest); } else { memberRequest = (MemberRequest)session.merge(memberRequest); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } entityCache.putResult( MemberRequestImpl.class, memberRequestModelImpl, false, true); cacheUniqueFindersCache(memberRequestModelImpl); if (isNew) { memberRequest.setNew(false); } memberRequest.resetOriginalValues(); return memberRequest; } /** * Returns the member request 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 member request * @return the member request * @throws NoSuchMemberRequestException if a member request with the primary key could not be found */ @Override public MemberRequest findByPrimaryKey(Serializable primaryKey) throws NoSuchMemberRequestException { MemberRequest memberRequest = fetchByPrimaryKey(primaryKey); if (memberRequest == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchMemberRequestException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return memberRequest; } /** * Returns the member request with the primary key or throws a NoSuchMemberRequestException if it could not be found. * * @param memberRequestId the primary key of the member request * @return the member request * @throws NoSuchMemberRequestException if a member request with the primary key could not be found */ @Override public MemberRequest findByPrimaryKey(long memberRequestId) throws NoSuchMemberRequestException { return findByPrimaryKey((Serializable)memberRequestId); } /** * Returns the member request with the primary key or returns null if it could not be found. * * @param memberRequestId the primary key of the member request * @return the member request, or null if a member request with the primary key could not be found */ @Override public MemberRequest fetchByPrimaryKey(long memberRequestId) { return fetchByPrimaryKey((Serializable)memberRequestId); } /** * Returns all the member requests. * * @return the member requests */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the member requests. * *

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

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

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

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

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

* * @param start the lower bound of the range of member requests * @param end the upper bound of the range of member requests (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 member requests */ @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_MEMBERREQUEST); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_MEMBERREQUEST; sql = sql.concat(MemberRequestModelImpl.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 member requests from the database. * */ @Override public void removeAll() { for (MemberRequest memberRequest : findAll()) { remove(memberRequest); } } /** * Returns the number of member requests. * * @return the number of member requests */ @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_MEMBERREQUEST); 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 "memberRequestId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_MEMBERREQUEST; } @Override protected Map getTableColumnsMap() { return MemberRequestModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the member request persistence. */ @Activate public void activate(BundleContext bundleContext) { _bundleContext = bundleContext; _argumentsResolverServiceRegistration = _bundleContext.registerService( ArgumentsResolver.class, new MemberRequestModelArgumentsResolver(), MapUtil.singletonDictionary( "model.class.name", MemberRequest.class.getName())); _finderPathWithPaginationFindAll = _createFinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0], new String[0], true); _finderPathWithoutPaginationFindAll = _createFinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0], new String[0], true); _finderPathCountAll = _createFinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0], new String[0], false); _finderPathFetchByKey = _createFinderPath( FINDER_CLASS_NAME_ENTITY, "fetchByKey", new String[] {String.class.getName()}, new String[] {"key_"}, true); _finderPathCountByKey = _createFinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByKey", new String[] {String.class.getName()}, new String[] {"key_"}, false); _finderPathWithPaginationFindByReceiverUserId = _createFinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByReceiverUserId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"receiverUserId"}, true); _finderPathWithoutPaginationFindByReceiverUserId = _createFinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByReceiverUserId", new String[] {Long.class.getName()}, new String[] {"receiverUserId"}, true); _finderPathCountByReceiverUserId = _createFinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByReceiverUserId", new String[] {Long.class.getName()}, new String[] {"receiverUserId"}, false); _finderPathWithPaginationFindByR_S = _createFinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"receiverUserId", "status"}, true); _finderPathWithoutPaginationFindByR_S = _createFinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_S", new String[] {Long.class.getName(), Integer.class.getName()}, new String[] {"receiverUserId", "status"}, true); _finderPathCountByR_S = _createFinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_S", new String[] {Long.class.getName(), Integer.class.getName()}, new String[] {"receiverUserId", "status"}, false); _finderPathFetchByG_R_S = _createFinderPath( FINDER_CLASS_NAME_ENTITY, "fetchByG_R_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, new String[] {"groupId", "receiverUserId", "status"}, true); _finderPathCountByG_R_S = _createFinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_R_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, new String[] {"groupId", "receiverUserId", "status"}, false); } @Deactivate public void deactivate() { entityCache.removeCache(MemberRequestImpl.class.getName()); _argumentsResolverServiceRegistration.unregister(); for (ServiceRegistration serviceRegistration : _serviceRegistrations) { serviceRegistration.unregister(); } } @Override @Reference( target = IMPersistenceConstants.SERVICE_CONFIGURATION_FILTER, unbind = "-" ) public void setConfiguration(Configuration configuration) { } @Override @Reference( target = IMPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setDataSource(DataSource dataSource) { super.setDataSource(dataSource); } @Override @Reference( target = IMPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setSessionFactory(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory); } private BundleContext _bundleContext; @Reference protected EntityCache entityCache; @Reference protected FinderCache finderCache; private static final String _SQL_SELECT_MEMBERREQUEST = "SELECT memberRequest FROM MemberRequest memberRequest"; private static final String _SQL_SELECT_MEMBERREQUEST_WHERE = "SELECT memberRequest FROM MemberRequest memberRequest WHERE "; private static final String _SQL_COUNT_MEMBERREQUEST = "SELECT COUNT(memberRequest) FROM MemberRequest memberRequest"; private static final String _SQL_COUNT_MEMBERREQUEST_WHERE = "SELECT COUNT(memberRequest) FROM MemberRequest memberRequest WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "memberRequest."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MemberRequest exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MemberRequest exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( MemberRequestPersistenceImpl.class); private static final Set _badColumnNames = SetUtil.fromArray( new String[] {"key"}); static { try { Class.forName(IMPersistenceConstants.class.getName()); } catch (ClassNotFoundException classNotFoundException) { throw new ExceptionInInitializerError(classNotFoundException); } } private FinderPath _createFinderPath( String cacheName, String methodName, String[] params, String[] columnNames, boolean baseModelResult) { FinderPath finderPath = new FinderPath( cacheName, methodName, params, columnNames, baseModelResult); if (!cacheName.equals(FINDER_CLASS_NAME_LIST_WITH_PAGINATION)) { _serviceRegistrations.add( _bundleContext.registerService( FinderPath.class, finderPath, MapUtil.singletonDictionary("cache.name", cacheName))); } return finderPath; } private Set> _serviceRegistrations = new HashSet<>(); private ServiceRegistration _argumentsResolverServiceRegistration; private static class MemberRequestModelArgumentsResolver implements ArgumentsResolver { @Override public Object[] getArguments( FinderPath finderPath, BaseModel baseModel, boolean checkColumn, boolean original) { String[] columnNames = finderPath.getColumnNames(); if ((columnNames == null) || (columnNames.length == 0)) { if (baseModel.isNew()) { return FINDER_ARGS_EMPTY; } return null; } MemberRequestModelImpl memberRequestModelImpl = (MemberRequestModelImpl)baseModel; long columnBitmask = memberRequestModelImpl.getColumnBitmask(); if (!checkColumn || (columnBitmask == 0)) { return _getValue(memberRequestModelImpl, columnNames, original); } Long finderPathColumnBitmask = _finderPathColumnBitmasksCache.get( finderPath); if (finderPathColumnBitmask == null) { finderPathColumnBitmask = 0L; for (String columnName : columnNames) { finderPathColumnBitmask |= memberRequestModelImpl.getColumnBitmask(columnName); } _finderPathColumnBitmasksCache.put( finderPath, finderPathColumnBitmask); } if ((columnBitmask & finderPathColumnBitmask) != 0) { return _getValue(memberRequestModelImpl, columnNames, original); } return null; } private Object[] _getValue( MemberRequestModelImpl memberRequestModelImpl, String[] columnNames, boolean original) { Object[] arguments = new Object[columnNames.length]; for (int i = 0; i < arguments.length; i++) { String columnName = columnNames[i]; if (original) { arguments[i] = memberRequestModelImpl.getColumnOriginalValue( columnName); } else { arguments[i] = memberRequestModelImpl.getColumnValue( columnName); } } return arguments; } private static Map _finderPathColumnBitmasksCache = new ConcurrentHashMap<>(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy