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 aQute.bnd.annotation.ProviderType;

import com.liferay.invitation.invite.members.exception.NoSuchMemberRequestException;
import com.liferay.invitation.invite.members.model.MemberRequest;
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.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.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.CompanyProvider;
import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.spring.extender.service.ServiceReference;

import java.io.Serializable;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;

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

/**
 * The persistence implementation for the member request service.
 *
 * 

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

* * @author Brian Wing Shun Chan * @generated */ @ProviderType 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 msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("key="); msg.append(key); msg.append("}"); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchMemberRequestException(msg.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 retrieveFromCache whether to retrieve from 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 retrieveFromCache) { key = Objects.toString(key, ""); Object[] finderArgs = new Object[] { key }; Object result = null; if (retrieveFromCache) { 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 query = new StringBundler(3); query.append(_SQL_SELECT_MEMBERREQUEST_WHERE); boolean bindKey = false; if (key.isEmpty()) { query.append(_FINDER_COLUMN_KEY_KEY_3); } else { bindKey = true; query.append(_FINDER_COLUMN_KEY_KEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindKey) { qPos.add(key); } List list = q.list(); if (list.isEmpty()) { finderCache.putResult(_finderPathFetchByKey, finderArgs, list); } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { _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 e) { finderCache.removeResult(_finderPathFetchByKey, finderArgs); throw processException(e); } 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 query = new StringBundler(2); query.append(_SQL_COUNT_MEMBERREQUEST_WHERE); boolean bindKey = false; if (key.isEmpty()) { query.append(_FINDER_COLUMN_KEY_KEY_3); } else { bindKey = true; query.append(_FINDER_COLUMN_KEY_KEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindKey) { qPos.add(key); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching member requests */ @Override public List findByReceiverUserId(long receiverUserId, int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindByReceiverUserId; finderArgs = new Object[] { receiverUserId }; } else { finderPath = _finderPathWithPaginationFindByReceiverUserId; finderArgs = new Object[] { receiverUserId, start, end, orderByComparator }; } List list = null; if (retrieveFromCache) { 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 query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MEMBERREQUEST_WHERE); query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MemberRequestModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(receiverUserId); if (!pagination) { list = (List)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("receiverUserId="); msg.append(receiverUserId); msg.append("}"); throw new NoSuchMemberRequestException(msg.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 msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("receiverUserId="); msg.append(receiverUserId); msg.append("}"); throw new NoSuchMemberRequestException(msg.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 e) { throw processException(e); } finally { closeSession(session); } } protected MemberRequest getByReceiverUserId_PrevAndNext(Session session, MemberRequest memberRequest, long receiverUserId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_MEMBERREQUEST_WHERE); query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MemberRequestModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(receiverUserId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( memberRequest)) { qPos.add(orderByConditionValue); } } List list = q.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 query = new StringBundler(2); query.append(_SQL_COUNT_MEMBERREQUEST_WHERE); query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(receiverUserId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 retrieveFromCache whether to retrieve from 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 retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindByR_S; finderArgs = new Object[] { receiverUserId, status }; } else { finderPath = _finderPathWithPaginationFindByR_S; finderArgs = new Object[] { receiverUserId, status, start, end, orderByComparator }; } List list = null; if (retrieveFromCache) { 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 query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MEMBERREQUEST_WHERE); query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2); query.append(_FINDER_COLUMN_R_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MemberRequestModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(receiverUserId); qPos.add(status); if (!pagination) { list = (List)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("receiverUserId="); msg.append(receiverUserId); msg.append(", status="); msg.append(status); msg.append("}"); throw new NoSuchMemberRequestException(msg.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 msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("receiverUserId="); msg.append(receiverUserId); msg.append(", status="); msg.append(status); msg.append("}"); throw new NoSuchMemberRequestException(msg.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 e) { throw processException(e); } finally { closeSession(session); } } protected MemberRequest getByR_S_PrevAndNext(Session session, MemberRequest memberRequest, long receiverUserId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_MEMBERREQUEST_WHERE); query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2); query.append(_FINDER_COLUMN_R_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(MemberRequestModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(receiverUserId); qPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( memberRequest)) { qPos.add(orderByConditionValue); } } List list = q.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 query = new StringBundler(3); query.append(_SQL_COUNT_MEMBERREQUEST_WHERE); query.append(_FINDER_COLUMN_R_S_RECEIVERUSERID_2); query.append(_FINDER_COLUMN_R_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(receiverUserId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", receiverUserId="); msg.append(receiverUserId); msg.append(", status="); msg.append(status); msg.append("}"); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchMemberRequestException(msg.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 retrieveFromCache whether to retrieve from 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 retrieveFromCache) { Object[] finderArgs = new Object[] { groupId, receiverUserId, status }; Object result = null; if (retrieveFromCache) { 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 query = new StringBundler(5); query.append(_SQL_SELECT_MEMBERREQUEST_WHERE); query.append(_FINDER_COLUMN_G_R_S_GROUPID_2); query.append(_FINDER_COLUMN_G_R_S_RECEIVERUSERID_2); query.append(_FINDER_COLUMN_G_R_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(receiverUserId); qPos.add(status); List list = q.list(); if (list.isEmpty()) { finderCache.putResult(_finderPathFetchByG_R_S, finderArgs, list); } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { _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 e) { finderCache.removeResult(_finderPathFetchByG_R_S, finderArgs); throw processException(e); } 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 query = new StringBundler(4); query.append(_SQL_COUNT_MEMBERREQUEST_WHERE); query.append(_FINDER_COLUMN_G_R_S_GROUPID_2); query.append(_FINDER_COLUMN_G_R_S_RECEIVERUSERID_2); query.append(_FINDER_COLUMN_G_R_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(receiverUserId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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() { setModelClass(MemberRequest.class); try { Field field = BasePersistenceImpl.class.getDeclaredField( "_dbColumnNames"); field.setAccessible(true); Map dbColumnNames = new HashMap(); dbColumnNames.put("key", "key_"); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * 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(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, 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); memberRequest.resetOriginalValues(); } /** * 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( MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, memberRequest.getPrimaryKey()) == null) { cacheResult(memberRequest); } else { memberRequest.resetOriginalValues(); } } } /** * 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(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, memberRequest.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((MemberRequestModelImpl)memberRequest, true); } @Override public void clearCache(List memberRequests) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (MemberRequest memberRequest : memberRequests) { entityCache.removeResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, memberRequest.getPrimaryKey()); clearUniqueFindersCache((MemberRequestModelImpl)memberRequest, true); } } 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); } protected void clearUniqueFindersCache( MemberRequestModelImpl memberRequestModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { memberRequestModelImpl.getKey() }; finderCache.removeResult(_finderPathCountByKey, args); finderCache.removeResult(_finderPathFetchByKey, args); } if ((memberRequestModelImpl.getColumnBitmask() & _finderPathFetchByKey.getColumnBitmask()) != 0) { Object[] args = new Object[] { memberRequestModelImpl.getOriginalKey() }; finderCache.removeResult(_finderPathCountByKey, args); finderCache.removeResult(_finderPathFetchByKey, args); } if (clearCurrent) { Object[] args = new Object[] { memberRequestModelImpl.getGroupId(), memberRequestModelImpl.getReceiverUserId(), memberRequestModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_R_S, args); finderCache.removeResult(_finderPathFetchByG_R_S, args); } if ((memberRequestModelImpl.getColumnBitmask() & _finderPathFetchByG_R_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { memberRequestModelImpl.getOriginalGroupId(), memberRequestModelImpl.getOriginalReceiverUserId(), memberRequestModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByG_R_S, args); finderCache.removeResult(_finderPathFetchByG_R_S, args); } } /** * 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(companyProvider.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 nsee) { throw nsee; } catch (Exception e) { throw processException(e); } 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 e) { throw processException(e); } 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 (memberRequest.isNew()) { session.save(memberRequest); memberRequest.setNew(false); } else { memberRequest = (MemberRequest)session.merge(memberRequest); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!MemberRequestModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { memberRequestModelImpl.getReceiverUserId() }; finderCache.removeResult(_finderPathCountByReceiverUserId, args); finderCache.removeResult(_finderPathWithoutPaginationFindByReceiverUserId, args); args = new Object[] { memberRequestModelImpl.getReceiverUserId(), memberRequestModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByR_S, args); finderCache.removeResult(_finderPathWithoutPaginationFindByR_S, args); finderCache.removeResult(_finderPathCountAll, FINDER_ARGS_EMPTY); finderCache.removeResult(_finderPathWithoutPaginationFindAll, FINDER_ARGS_EMPTY); } else { if ((memberRequestModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByReceiverUserId.getColumnBitmask()) != 0) { Object[] args = new Object[] { memberRequestModelImpl.getOriginalReceiverUserId() }; finderCache.removeResult(_finderPathCountByReceiverUserId, args); finderCache.removeResult(_finderPathWithoutPaginationFindByReceiverUserId, args); args = new Object[] { memberRequestModelImpl.getReceiverUserId() }; finderCache.removeResult(_finderPathCountByReceiverUserId, args); finderCache.removeResult(_finderPathWithoutPaginationFindByReceiverUserId, args); } if ((memberRequestModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByR_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { memberRequestModelImpl.getOriginalReceiverUserId(), memberRequestModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByR_S, args); finderCache.removeResult(_finderPathWithoutPaginationFindByR_S, args); args = new Object[] { memberRequestModelImpl.getReceiverUserId(), memberRequestModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByR_S, args); finderCache.removeResult(_finderPathWithoutPaginationFindByR_S, args); } } entityCache.putResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, memberRequest.getPrimaryKey(), memberRequest, false); clearUniqueFindersCache(memberRequestModelImpl, false); cacheUniqueFindersCache(memberRequestModelImpl); 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 primaryKey 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(Serializable primaryKey) { Serializable serializable = entityCache.getResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, primaryKey); if (serializable == nullModel) { return null; } MemberRequest memberRequest = (MemberRequest)serializable; if (memberRequest == null) { Session session = null; try { session = openSession(); memberRequest = (MemberRequest)session.get(MemberRequestImpl.class, primaryKey); if (memberRequest != null) { cacheResult(memberRequest); } else { entityCache.putResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return memberRequest; } /** * 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); } @Override public Map fetchByPrimaryKeys( Set primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map map = new HashMap(); if (primaryKeys.size() == 1) { Iterator iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); MemberRequest memberRequest = fetchByPrimaryKey(primaryKey); if (memberRequest != null) { map.put(primaryKey, memberRequest); } return map; } Set uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (MemberRequest)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_MEMBERREQUEST_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(","); } query.setIndex(query.index() - 1); query.append(")"); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (MemberRequest memberRequest : (List)q.list()) { map.put(memberRequest.getPrimaryKeyObj(), memberRequest); cacheResult(memberRequest); uncachedPrimaryKeys.remove(memberRequest.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from MemberRequestModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param 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 retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of member requests */ @Override public List findAll(int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] { start, end, orderByComparator }; } List list = null; if (retrieveFromCache) { list = (List)finderCache.getResult(finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_MEMBERREQUEST); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_MEMBERREQUEST; if (pagination) { sql = sql.concat(MemberRequestModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 q = session.createQuery(_SQL_COUNT_MEMBERREQUEST); count = (Long)q.uniqueResult(); finderCache.putResult(_finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception e) { finderCache.removeResult(_finderPathCountAll, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } @Override public Set getBadColumnNames() { return _badColumnNames; } @Override protected Map getTableColumnsMap() { return MemberRequestModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the member request persistence. */ public void afterPropertiesSet() { _finderPathWithPaginationFindAll = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, MemberRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); _finderPathWithoutPaginationFindAll = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, MemberRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); _finderPathCountAll = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); _finderPathFetchByKey = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, MemberRequestImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByKey", new String[] { String.class.getName() }, MemberRequestModelImpl.KEY_COLUMN_BITMASK); _finderPathCountByKey = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByKey", new String[] { String.class.getName() }); _finderPathWithPaginationFindByReceiverUserId = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, MemberRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByReceiverUserId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByReceiverUserId = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, MemberRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByReceiverUserId", new String[] { Long.class.getName() }, MemberRequestModelImpl.RECEIVERUSERID_COLUMN_BITMASK | MemberRequestModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByReceiverUserId = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByReceiverUserId", new String[] { Long.class.getName() }); _finderPathWithPaginationFindByR_S = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, MemberRequestImpl.class, 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() }); _finderPathWithoutPaginationFindByR_S = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, MemberRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_S", new String[] { Long.class.getName(), Integer.class.getName() }, MemberRequestModelImpl.RECEIVERUSERID_COLUMN_BITMASK | MemberRequestModelImpl.STATUS_COLUMN_BITMASK | MemberRequestModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByR_S = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_S", new String[] { Long.class.getName(), Integer.class.getName() }); _finderPathFetchByG_R_S = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, MemberRequestImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_R_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, MemberRequestModelImpl.GROUPID_COLUMN_BITMASK | MemberRequestModelImpl.RECEIVERUSERID_COLUMN_BITMASK | MemberRequestModelImpl.STATUS_COLUMN_BITMASK); _finderPathCountByG_R_S = new FinderPath(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_R_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); } public void destroy() { entityCache.removeCache(MemberRequestImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @ServiceReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; @ServiceReference(type = EntityCache.class) protected EntityCache entityCache; @ServiceReference(type = FinderCache.class) protected FinderCache finderCache; private static final String _SQL_SELECT_MEMBERREQUEST = "SELECT memberRequest FROM MemberRequest memberRequest"; private static final String _SQL_SELECT_MEMBERREQUEST_WHERE_PKS_IN = "SELECT memberRequest FROM MemberRequest memberRequest WHERE memberRequestId IN ("; 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" }); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy