001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.NoSuchMembershipRequestException;
020    import com.liferay.portal.kernel.bean.BeanReference;
021    import com.liferay.portal.kernel.dao.orm.EntityCache;
022    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderCache;
024    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025    import com.liferay.portal.kernel.dao.orm.FinderPath;
026    import com.liferay.portal.kernel.dao.orm.Query;
027    import com.liferay.portal.kernel.dao.orm.QueryPos;
028    import com.liferay.portal.kernel.dao.orm.QueryUtil;
029    import com.liferay.portal.kernel.dao.orm.Session;
030    import com.liferay.portal.kernel.log.Log;
031    import com.liferay.portal.kernel.log.LogFactoryUtil;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.model.CacheModel;
036    import com.liferay.portal.model.MVCCModel;
037    import com.liferay.portal.model.MembershipRequest;
038    import com.liferay.portal.model.impl.MembershipRequestImpl;
039    import com.liferay.portal.model.impl.MembershipRequestModelImpl;
040    import com.liferay.portal.service.persistence.CompanyProvider;
041    import com.liferay.portal.service.persistence.MembershipRequestPersistence;
042    
043    import java.io.Serializable;
044    
045    import java.util.Collections;
046    import java.util.HashMap;
047    import java.util.HashSet;
048    import java.util.Iterator;
049    import java.util.List;
050    import java.util.Map;
051    import java.util.Set;
052    
053    /**
054     * The persistence implementation for the membership request service.
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see MembershipRequestPersistence
062     * @see com.liferay.portal.service.persistence.MembershipRequestUtil
063     * @generated
064     */
065    @ProviderType
066    public class MembershipRequestPersistenceImpl extends BasePersistenceImpl<MembershipRequest>
067            implements MembershipRequestPersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link MembershipRequestUtil} to access the membership request persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072             */
073            public static final String FINDER_CLASS_NAME_ENTITY = MembershipRequestImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List1";
076            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List2";
078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
079                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
080                            MembershipRequestImpl.class,
081                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
082            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
083                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
084                            MembershipRequestImpl.class,
085                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
087                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
090                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
091                            MembershipRequestImpl.class,
092                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
093                            new String[] {
094                                    Long.class.getName(),
095                                    
096                            Integer.class.getName(), Integer.class.getName(),
097                                    OrderByComparator.class.getName()
098                            });
099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
100                    new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
101                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
102                            MembershipRequestImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
104                            new String[] { Long.class.getName() },
105                            MembershipRequestModelImpl.GROUPID_COLUMN_BITMASK |
106                            MembershipRequestModelImpl.CREATEDATE_COLUMN_BITMASK);
107            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
108                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
110                            new String[] { Long.class.getName() });
111    
112            /**
113             * Returns all the membership requests where groupId = &#63;.
114             *
115             * @param groupId the group ID
116             * @return the matching membership requests
117             */
118            @Override
119            public List<MembershipRequest> findByGroupId(long groupId) {
120                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121            }
122    
123            /**
124             * Returns a range of all the membership requests where groupId = &#63;.
125             *
126             * <p>
127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
128             * </p>
129             *
130             * @param groupId the group ID
131             * @param start the lower bound of the range of membership requests
132             * @param end the upper bound of the range of membership requests (not inclusive)
133             * @return the range of matching membership requests
134             */
135            @Override
136            public List<MembershipRequest> findByGroupId(long groupId, int start,
137                    int end) {
138                    return findByGroupId(groupId, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the membership requests where groupId = &#63;.
143             *
144             * <p>
145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
146             * </p>
147             *
148             * @param groupId the group ID
149             * @param start the lower bound of the range of membership requests
150             * @param end the upper bound of the range of membership requests (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching membership requests
153             */
154            @Override
155            public List<MembershipRequest> findByGroupId(long groupId, int start,
156                    int end, OrderByComparator<MembershipRequest> orderByComparator) {
157                    return findByGroupId(groupId, start, end, orderByComparator, true);
158            }
159    
160            /**
161             * Returns an ordered range of all the membership requests where groupId = &#63;.
162             *
163             * <p>
164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
165             * </p>
166             *
167             * @param groupId the group ID
168             * @param start the lower bound of the range of membership requests
169             * @param end the upper bound of the range of membership requests (not inclusive)
170             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
171             * @param retrieveFromCache whether to retrieve from the finder cache
172             * @return the ordered range of matching membership requests
173             */
174            @Override
175            public List<MembershipRequest> findByGroupId(long groupId, int start,
176                    int end, OrderByComparator<MembershipRequest> orderByComparator,
177                    boolean retrieveFromCache) {
178                    boolean pagination = true;
179                    FinderPath finderPath = null;
180                    Object[] finderArgs = null;
181    
182                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
183                                    (orderByComparator == null)) {
184                            pagination = false;
185                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
186                            finderArgs = new Object[] { groupId };
187                    }
188                    else {
189                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
190                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
191                    }
192    
193                    List<MembershipRequest> list = null;
194    
195                    if (retrieveFromCache) {
196                            list = (List<MembershipRequest>)finderCache.getResult(finderPath,
197                                            finderArgs, this);
198    
199                            if ((list != null) && !list.isEmpty()) {
200                                    for (MembershipRequest membershipRequest : list) {
201                                            if ((groupId != membershipRequest.getGroupId())) {
202                                                    list = null;
203    
204                                                    break;
205                                            }
206                                    }
207                            }
208                    }
209    
210                    if (list == null) {
211                            StringBundler query = null;
212    
213                            if (orderByComparator != null) {
214                                    query = new StringBundler(3 +
215                                                    (orderByComparator.getOrderByFields().length * 3));
216                            }
217                            else {
218                                    query = new StringBundler(3);
219                            }
220    
221                            query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE);
222    
223                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
224    
225                            if (orderByComparator != null) {
226                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
227                                            orderByComparator);
228                            }
229                            else
230                             if (pagination) {
231                                    query.append(MembershipRequestModelImpl.ORDER_BY_JPQL);
232                            }
233    
234                            String sql = query.toString();
235    
236                            Session session = null;
237    
238                            try {
239                                    session = openSession();
240    
241                                    Query q = session.createQuery(sql);
242    
243                                    QueryPos qPos = QueryPos.getInstance(q);
244    
245                                    qPos.add(groupId);
246    
247                                    if (!pagination) {
248                                            list = (List<MembershipRequest>)QueryUtil.list(q,
249                                                            getDialect(), start, end, false);
250    
251                                            Collections.sort(list);
252    
253                                            list = Collections.unmodifiableList(list);
254                                    }
255                                    else {
256                                            list = (List<MembershipRequest>)QueryUtil.list(q,
257                                                            getDialect(), start, end);
258                                    }
259    
260                                    cacheResult(list);
261    
262                                    finderCache.putResult(finderPath, finderArgs, list);
263                            }
264                            catch (Exception e) {
265                                    finderCache.removeResult(finderPath, finderArgs);
266    
267                                    throw processException(e);
268                            }
269                            finally {
270                                    closeSession(session);
271                            }
272                    }
273    
274                    return list;
275            }
276    
277            /**
278             * Returns the first membership request in the ordered set where groupId = &#63;.
279             *
280             * @param groupId the group ID
281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
282             * @return the first matching membership request
283             * @throws NoSuchMembershipRequestException if a matching membership request could not be found
284             */
285            @Override
286            public MembershipRequest findByGroupId_First(long groupId,
287                    OrderByComparator<MembershipRequest> orderByComparator)
288                    throws NoSuchMembershipRequestException {
289                    MembershipRequest membershipRequest = fetchByGroupId_First(groupId,
290                                    orderByComparator);
291    
292                    if (membershipRequest != null) {
293                            return membershipRequest;
294                    }
295    
296                    StringBundler msg = new StringBundler(4);
297    
298                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
299    
300                    msg.append("groupId=");
301                    msg.append(groupId);
302    
303                    msg.append(StringPool.CLOSE_CURLY_BRACE);
304    
305                    throw new NoSuchMembershipRequestException(msg.toString());
306            }
307    
308            /**
309             * Returns the first membership request in the ordered set where groupId = &#63;.
310             *
311             * @param groupId the group ID
312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
313             * @return the first matching membership request, or <code>null</code> if a matching membership request could not be found
314             */
315            @Override
316            public MembershipRequest fetchByGroupId_First(long groupId,
317                    OrderByComparator<MembershipRequest> orderByComparator) {
318                    List<MembershipRequest> list = findByGroupId(groupId, 0, 1,
319                                    orderByComparator);
320    
321                    if (!list.isEmpty()) {
322                            return list.get(0);
323                    }
324    
325                    return null;
326            }
327    
328            /**
329             * Returns the last membership request in the ordered set where groupId = &#63;.
330             *
331             * @param groupId the group ID
332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
333             * @return the last matching membership request
334             * @throws NoSuchMembershipRequestException if a matching membership request could not be found
335             */
336            @Override
337            public MembershipRequest findByGroupId_Last(long groupId,
338                    OrderByComparator<MembershipRequest> orderByComparator)
339                    throws NoSuchMembershipRequestException {
340                    MembershipRequest membershipRequest = fetchByGroupId_Last(groupId,
341                                    orderByComparator);
342    
343                    if (membershipRequest != null) {
344                            return membershipRequest;
345                    }
346    
347                    StringBundler msg = new StringBundler(4);
348    
349                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
350    
351                    msg.append("groupId=");
352                    msg.append(groupId);
353    
354                    msg.append(StringPool.CLOSE_CURLY_BRACE);
355    
356                    throw new NoSuchMembershipRequestException(msg.toString());
357            }
358    
359            /**
360             * Returns the last membership request in the ordered set where groupId = &#63;.
361             *
362             * @param groupId the group ID
363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
364             * @return the last matching membership request, or <code>null</code> if a matching membership request could not be found
365             */
366            @Override
367            public MembershipRequest fetchByGroupId_Last(long groupId,
368                    OrderByComparator<MembershipRequest> orderByComparator) {
369                    int count = countByGroupId(groupId);
370    
371                    if (count == 0) {
372                            return null;
373                    }
374    
375                    List<MembershipRequest> list = findByGroupId(groupId, count - 1, count,
376                                    orderByComparator);
377    
378                    if (!list.isEmpty()) {
379                            return list.get(0);
380                    }
381    
382                    return null;
383            }
384    
385            /**
386             * Returns the membership requests before and after the current membership request in the ordered set where groupId = &#63;.
387             *
388             * @param membershipRequestId the primary key of the current membership request
389             * @param groupId the group ID
390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
391             * @return the previous, current, and next membership request
392             * @throws NoSuchMembershipRequestException if a membership request with the primary key could not be found
393             */
394            @Override
395            public MembershipRequest[] findByGroupId_PrevAndNext(
396                    long membershipRequestId, long groupId,
397                    OrderByComparator<MembershipRequest> orderByComparator)
398                    throws NoSuchMembershipRequestException {
399                    MembershipRequest membershipRequest = findByPrimaryKey(membershipRequestId);
400    
401                    Session session = null;
402    
403                    try {
404                            session = openSession();
405    
406                            MembershipRequest[] array = new MembershipRequestImpl[3];
407    
408                            array[0] = getByGroupId_PrevAndNext(session, membershipRequest,
409                                            groupId, orderByComparator, true);
410    
411                            array[1] = membershipRequest;
412    
413                            array[2] = getByGroupId_PrevAndNext(session, membershipRequest,
414                                            groupId, orderByComparator, false);
415    
416                            return array;
417                    }
418                    catch (Exception e) {
419                            throw processException(e);
420                    }
421                    finally {
422                            closeSession(session);
423                    }
424            }
425    
426            protected MembershipRequest getByGroupId_PrevAndNext(Session session,
427                    MembershipRequest membershipRequest, long groupId,
428                    OrderByComparator<MembershipRequest> orderByComparator, boolean previous) {
429                    StringBundler query = null;
430    
431                    if (orderByComparator != null) {
432                            query = new StringBundler(6 +
433                                            (orderByComparator.getOrderByFields().length * 6));
434                    }
435                    else {
436                            query = new StringBundler(3);
437                    }
438    
439                    query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE);
440    
441                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
442    
443                    if (orderByComparator != null) {
444                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
445    
446                            if (orderByConditionFields.length > 0) {
447                                    query.append(WHERE_AND);
448                            }
449    
450                            for (int i = 0; i < orderByConditionFields.length; i++) {
451                                    query.append(_ORDER_BY_ENTITY_ALIAS);
452                                    query.append(orderByConditionFields[i]);
453    
454                                    if ((i + 1) < orderByConditionFields.length) {
455                                            if (orderByComparator.isAscending() ^ previous) {
456                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
457                                            }
458                                            else {
459                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
460                                            }
461                                    }
462                                    else {
463                                            if (orderByComparator.isAscending() ^ previous) {
464                                                    query.append(WHERE_GREATER_THAN);
465                                            }
466                                            else {
467                                                    query.append(WHERE_LESSER_THAN);
468                                            }
469                                    }
470                            }
471    
472                            query.append(ORDER_BY_CLAUSE);
473    
474                            String[] orderByFields = orderByComparator.getOrderByFields();
475    
476                            for (int i = 0; i < orderByFields.length; i++) {
477                                    query.append(_ORDER_BY_ENTITY_ALIAS);
478                                    query.append(orderByFields[i]);
479    
480                                    if ((i + 1) < orderByFields.length) {
481                                            if (orderByComparator.isAscending() ^ previous) {
482                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
483                                            }
484                                            else {
485                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
486                                            }
487                                    }
488                                    else {
489                                            if (orderByComparator.isAscending() ^ previous) {
490                                                    query.append(ORDER_BY_ASC);
491                                            }
492                                            else {
493                                                    query.append(ORDER_BY_DESC);
494                                            }
495                                    }
496                            }
497                    }
498                    else {
499                            query.append(MembershipRequestModelImpl.ORDER_BY_JPQL);
500                    }
501    
502                    String sql = query.toString();
503    
504                    Query q = session.createQuery(sql);
505    
506                    q.setFirstResult(0);
507                    q.setMaxResults(2);
508    
509                    QueryPos qPos = QueryPos.getInstance(q);
510    
511                    qPos.add(groupId);
512    
513                    if (orderByComparator != null) {
514                            Object[] values = orderByComparator.getOrderByConditionValues(membershipRequest);
515    
516                            for (Object value : values) {
517                                    qPos.add(value);
518                            }
519                    }
520    
521                    List<MembershipRequest> list = q.list();
522    
523                    if (list.size() == 2) {
524                            return list.get(1);
525                    }
526                    else {
527                            return null;
528                    }
529            }
530    
531            /**
532             * Removes all the membership requests where groupId = &#63; from the database.
533             *
534             * @param groupId the group ID
535             */
536            @Override
537            public void removeByGroupId(long groupId) {
538                    for (MembershipRequest membershipRequest : findByGroupId(groupId,
539                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
540                            remove(membershipRequest);
541                    }
542            }
543    
544            /**
545             * Returns the number of membership requests where groupId = &#63;.
546             *
547             * @param groupId the group ID
548             * @return the number of matching membership requests
549             */
550            @Override
551            public int countByGroupId(long groupId) {
552                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
553    
554                    Object[] finderArgs = new Object[] { groupId };
555    
556                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
557    
558                    if (count == null) {
559                            StringBundler query = new StringBundler(2);
560    
561                            query.append(_SQL_COUNT_MEMBERSHIPREQUEST_WHERE);
562    
563                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
564    
565                            String sql = query.toString();
566    
567                            Session session = null;
568    
569                            try {
570                                    session = openSession();
571    
572                                    Query q = session.createQuery(sql);
573    
574                                    QueryPos qPos = QueryPos.getInstance(q);
575    
576                                    qPos.add(groupId);
577    
578                                    count = (Long)q.uniqueResult();
579    
580                                    finderCache.putResult(finderPath, finderArgs, count);
581                            }
582                            catch (Exception e) {
583                                    finderCache.removeResult(finderPath, finderArgs);
584    
585                                    throw processException(e);
586                            }
587                            finally {
588                                    closeSession(session);
589                            }
590                    }
591    
592                    return count.intValue();
593            }
594    
595            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "membershipRequest.groupId = ?";
596            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
597                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
598                            MembershipRequestImpl.class,
599                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
600                            new String[] {
601                                    Long.class.getName(),
602                                    
603                            Integer.class.getName(), Integer.class.getName(),
604                                    OrderByComparator.class.getName()
605                            });
606            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
607                    new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
608                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
609                            MembershipRequestImpl.class,
610                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
611                            new String[] { Long.class.getName() },
612                            MembershipRequestModelImpl.USERID_COLUMN_BITMASK |
613                            MembershipRequestModelImpl.CREATEDATE_COLUMN_BITMASK);
614            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
615                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
616                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
617                            new String[] { Long.class.getName() });
618    
619            /**
620             * Returns all the membership requests where userId = &#63;.
621             *
622             * @param userId the user ID
623             * @return the matching membership requests
624             */
625            @Override
626            public List<MembershipRequest> findByUserId(long userId) {
627                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
628            }
629    
630            /**
631             * Returns a range of all the membership requests where userId = &#63;.
632             *
633             * <p>
634             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
635             * </p>
636             *
637             * @param userId the user ID
638             * @param start the lower bound of the range of membership requests
639             * @param end the upper bound of the range of membership requests (not inclusive)
640             * @return the range of matching membership requests
641             */
642            @Override
643            public List<MembershipRequest> findByUserId(long userId, int start, int end) {
644                    return findByUserId(userId, start, end, null);
645            }
646    
647            /**
648             * Returns an ordered range of all the membership requests where userId = &#63;.
649             *
650             * <p>
651             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
652             * </p>
653             *
654             * @param userId the user ID
655             * @param start the lower bound of the range of membership requests
656             * @param end the upper bound of the range of membership requests (not inclusive)
657             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
658             * @return the ordered range of matching membership requests
659             */
660            @Override
661            public List<MembershipRequest> findByUserId(long userId, int start,
662                    int end, OrderByComparator<MembershipRequest> orderByComparator) {
663                    return findByUserId(userId, start, end, orderByComparator, true);
664            }
665    
666            /**
667             * Returns an ordered range of all the membership requests where userId = &#63;.
668             *
669             * <p>
670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
671             * </p>
672             *
673             * @param userId the user ID
674             * @param start the lower bound of the range of membership requests
675             * @param end the upper bound of the range of membership requests (not inclusive)
676             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
677             * @param retrieveFromCache whether to retrieve from the finder cache
678             * @return the ordered range of matching membership requests
679             */
680            @Override
681            public List<MembershipRequest> findByUserId(long userId, int start,
682                    int end, OrderByComparator<MembershipRequest> orderByComparator,
683                    boolean retrieveFromCache) {
684                    boolean pagination = true;
685                    FinderPath finderPath = null;
686                    Object[] finderArgs = null;
687    
688                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
689                                    (orderByComparator == null)) {
690                            pagination = false;
691                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
692                            finderArgs = new Object[] { userId };
693                    }
694                    else {
695                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
696                            finderArgs = new Object[] { userId, start, end, orderByComparator };
697                    }
698    
699                    List<MembershipRequest> list = null;
700    
701                    if (retrieveFromCache) {
702                            list = (List<MembershipRequest>)finderCache.getResult(finderPath,
703                                            finderArgs, this);
704    
705                            if ((list != null) && !list.isEmpty()) {
706                                    for (MembershipRequest membershipRequest : list) {
707                                            if ((userId != membershipRequest.getUserId())) {
708                                                    list = null;
709    
710                                                    break;
711                                            }
712                                    }
713                            }
714                    }
715    
716                    if (list == null) {
717                            StringBundler query = null;
718    
719                            if (orderByComparator != null) {
720                                    query = new StringBundler(3 +
721                                                    (orderByComparator.getOrderByFields().length * 3));
722                            }
723                            else {
724                                    query = new StringBundler(3);
725                            }
726    
727                            query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE);
728    
729                            query.append(_FINDER_COLUMN_USERID_USERID_2);
730    
731                            if (orderByComparator != null) {
732                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
733                                            orderByComparator);
734                            }
735                            else
736                             if (pagination) {
737                                    query.append(MembershipRequestModelImpl.ORDER_BY_JPQL);
738                            }
739    
740                            String sql = query.toString();
741    
742                            Session session = null;
743    
744                            try {
745                                    session = openSession();
746    
747                                    Query q = session.createQuery(sql);
748    
749                                    QueryPos qPos = QueryPos.getInstance(q);
750    
751                                    qPos.add(userId);
752    
753                                    if (!pagination) {
754                                            list = (List<MembershipRequest>)QueryUtil.list(q,
755                                                            getDialect(), start, end, false);
756    
757                                            Collections.sort(list);
758    
759                                            list = Collections.unmodifiableList(list);
760                                    }
761                                    else {
762                                            list = (List<MembershipRequest>)QueryUtil.list(q,
763                                                            getDialect(), start, end);
764                                    }
765    
766                                    cacheResult(list);
767    
768                                    finderCache.putResult(finderPath, finderArgs, list);
769                            }
770                            catch (Exception e) {
771                                    finderCache.removeResult(finderPath, finderArgs);
772    
773                                    throw processException(e);
774                            }
775                            finally {
776                                    closeSession(session);
777                            }
778                    }
779    
780                    return list;
781            }
782    
783            /**
784             * Returns the first membership request in the ordered set where userId = &#63;.
785             *
786             * @param userId the user ID
787             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
788             * @return the first matching membership request
789             * @throws NoSuchMembershipRequestException if a matching membership request could not be found
790             */
791            @Override
792            public MembershipRequest findByUserId_First(long userId,
793                    OrderByComparator<MembershipRequest> orderByComparator)
794                    throws NoSuchMembershipRequestException {
795                    MembershipRequest membershipRequest = fetchByUserId_First(userId,
796                                    orderByComparator);
797    
798                    if (membershipRequest != null) {
799                            return membershipRequest;
800                    }
801    
802                    StringBundler msg = new StringBundler(4);
803    
804                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
805    
806                    msg.append("userId=");
807                    msg.append(userId);
808    
809                    msg.append(StringPool.CLOSE_CURLY_BRACE);
810    
811                    throw new NoSuchMembershipRequestException(msg.toString());
812            }
813    
814            /**
815             * Returns the first membership request in the ordered set where userId = &#63;.
816             *
817             * @param userId the user ID
818             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
819             * @return the first matching membership request, or <code>null</code> if a matching membership request could not be found
820             */
821            @Override
822            public MembershipRequest fetchByUserId_First(long userId,
823                    OrderByComparator<MembershipRequest> orderByComparator) {
824                    List<MembershipRequest> list = findByUserId(userId, 0, 1,
825                                    orderByComparator);
826    
827                    if (!list.isEmpty()) {
828                            return list.get(0);
829                    }
830    
831                    return null;
832            }
833    
834            /**
835             * Returns the last membership request in the ordered set where userId = &#63;.
836             *
837             * @param userId the user ID
838             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
839             * @return the last matching membership request
840             * @throws NoSuchMembershipRequestException if a matching membership request could not be found
841             */
842            @Override
843            public MembershipRequest findByUserId_Last(long userId,
844                    OrderByComparator<MembershipRequest> orderByComparator)
845                    throws NoSuchMembershipRequestException {
846                    MembershipRequest membershipRequest = fetchByUserId_Last(userId,
847                                    orderByComparator);
848    
849                    if (membershipRequest != null) {
850                            return membershipRequest;
851                    }
852    
853                    StringBundler msg = new StringBundler(4);
854    
855                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
856    
857                    msg.append("userId=");
858                    msg.append(userId);
859    
860                    msg.append(StringPool.CLOSE_CURLY_BRACE);
861    
862                    throw new NoSuchMembershipRequestException(msg.toString());
863            }
864    
865            /**
866             * Returns the last membership request in the ordered set where userId = &#63;.
867             *
868             * @param userId the user ID
869             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
870             * @return the last matching membership request, or <code>null</code> if a matching membership request could not be found
871             */
872            @Override
873            public MembershipRequest fetchByUserId_Last(long userId,
874                    OrderByComparator<MembershipRequest> orderByComparator) {
875                    int count = countByUserId(userId);
876    
877                    if (count == 0) {
878                            return null;
879                    }
880    
881                    List<MembershipRequest> list = findByUserId(userId, count - 1, count,
882                                    orderByComparator);
883    
884                    if (!list.isEmpty()) {
885                            return list.get(0);
886                    }
887    
888                    return null;
889            }
890    
891            /**
892             * Returns the membership requests before and after the current membership request in the ordered set where userId = &#63;.
893             *
894             * @param membershipRequestId the primary key of the current membership request
895             * @param userId the user ID
896             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
897             * @return the previous, current, and next membership request
898             * @throws NoSuchMembershipRequestException if a membership request with the primary key could not be found
899             */
900            @Override
901            public MembershipRequest[] findByUserId_PrevAndNext(
902                    long membershipRequestId, long userId,
903                    OrderByComparator<MembershipRequest> orderByComparator)
904                    throws NoSuchMembershipRequestException {
905                    MembershipRequest membershipRequest = findByPrimaryKey(membershipRequestId);
906    
907                    Session session = null;
908    
909                    try {
910                            session = openSession();
911    
912                            MembershipRequest[] array = new MembershipRequestImpl[3];
913    
914                            array[0] = getByUserId_PrevAndNext(session, membershipRequest,
915                                            userId, orderByComparator, true);
916    
917                            array[1] = membershipRequest;
918    
919                            array[2] = getByUserId_PrevAndNext(session, membershipRequest,
920                                            userId, orderByComparator, false);
921    
922                            return array;
923                    }
924                    catch (Exception e) {
925                            throw processException(e);
926                    }
927                    finally {
928                            closeSession(session);
929                    }
930            }
931    
932            protected MembershipRequest getByUserId_PrevAndNext(Session session,
933                    MembershipRequest membershipRequest, long userId,
934                    OrderByComparator<MembershipRequest> orderByComparator, boolean previous) {
935                    StringBundler query = null;
936    
937                    if (orderByComparator != null) {
938                            query = new StringBundler(6 +
939                                            (orderByComparator.getOrderByFields().length * 6));
940                    }
941                    else {
942                            query = new StringBundler(3);
943                    }
944    
945                    query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE);
946    
947                    query.append(_FINDER_COLUMN_USERID_USERID_2);
948    
949                    if (orderByComparator != null) {
950                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
951    
952                            if (orderByConditionFields.length > 0) {
953                                    query.append(WHERE_AND);
954                            }
955    
956                            for (int i = 0; i < orderByConditionFields.length; i++) {
957                                    query.append(_ORDER_BY_ENTITY_ALIAS);
958                                    query.append(orderByConditionFields[i]);
959    
960                                    if ((i + 1) < orderByConditionFields.length) {
961                                            if (orderByComparator.isAscending() ^ previous) {
962                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
963                                            }
964                                            else {
965                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
966                                            }
967                                    }
968                                    else {
969                                            if (orderByComparator.isAscending() ^ previous) {
970                                                    query.append(WHERE_GREATER_THAN);
971                                            }
972                                            else {
973                                                    query.append(WHERE_LESSER_THAN);
974                                            }
975                                    }
976                            }
977    
978                            query.append(ORDER_BY_CLAUSE);
979    
980                            String[] orderByFields = orderByComparator.getOrderByFields();
981    
982                            for (int i = 0; i < orderByFields.length; i++) {
983                                    query.append(_ORDER_BY_ENTITY_ALIAS);
984                                    query.append(orderByFields[i]);
985    
986                                    if ((i + 1) < orderByFields.length) {
987                                            if (orderByComparator.isAscending() ^ previous) {
988                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
989                                            }
990                                            else {
991                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
992                                            }
993                                    }
994                                    else {
995                                            if (orderByComparator.isAscending() ^ previous) {
996                                                    query.append(ORDER_BY_ASC);
997                                            }
998                                            else {
999                                                    query.append(ORDER_BY_DESC);
1000                                            }
1001                                    }
1002                            }
1003                    }
1004                    else {
1005                            query.append(MembershipRequestModelImpl.ORDER_BY_JPQL);
1006                    }
1007    
1008                    String sql = query.toString();
1009    
1010                    Query q = session.createQuery(sql);
1011    
1012                    q.setFirstResult(0);
1013                    q.setMaxResults(2);
1014    
1015                    QueryPos qPos = QueryPos.getInstance(q);
1016    
1017                    qPos.add(userId);
1018    
1019                    if (orderByComparator != null) {
1020                            Object[] values = orderByComparator.getOrderByConditionValues(membershipRequest);
1021    
1022                            for (Object value : values) {
1023                                    qPos.add(value);
1024                            }
1025                    }
1026    
1027                    List<MembershipRequest> list = q.list();
1028    
1029                    if (list.size() == 2) {
1030                            return list.get(1);
1031                    }
1032                    else {
1033                            return null;
1034                    }
1035            }
1036    
1037            /**
1038             * Removes all the membership requests where userId = &#63; from the database.
1039             *
1040             * @param userId the user ID
1041             */
1042            @Override
1043            public void removeByUserId(long userId) {
1044                    for (MembershipRequest membershipRequest : findByUserId(userId,
1045                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1046                            remove(membershipRequest);
1047                    }
1048            }
1049    
1050            /**
1051             * Returns the number of membership requests where userId = &#63;.
1052             *
1053             * @param userId the user ID
1054             * @return the number of matching membership requests
1055             */
1056            @Override
1057            public int countByUserId(long userId) {
1058                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1059    
1060                    Object[] finderArgs = new Object[] { userId };
1061    
1062                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1063    
1064                    if (count == null) {
1065                            StringBundler query = new StringBundler(2);
1066    
1067                            query.append(_SQL_COUNT_MEMBERSHIPREQUEST_WHERE);
1068    
1069                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1070    
1071                            String sql = query.toString();
1072    
1073                            Session session = null;
1074    
1075                            try {
1076                                    session = openSession();
1077    
1078                                    Query q = session.createQuery(sql);
1079    
1080                                    QueryPos qPos = QueryPos.getInstance(q);
1081    
1082                                    qPos.add(userId);
1083    
1084                                    count = (Long)q.uniqueResult();
1085    
1086                                    finderCache.putResult(finderPath, finderArgs, count);
1087                            }
1088                            catch (Exception e) {
1089                                    finderCache.removeResult(finderPath, finderArgs);
1090    
1091                                    throw processException(e);
1092                            }
1093                            finally {
1094                                    closeSession(session);
1095                            }
1096                    }
1097    
1098                    return count.intValue();
1099            }
1100    
1101            private static final String _FINDER_COLUMN_USERID_USERID_2 = "membershipRequest.userId = ?";
1102            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
1103                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
1104                            MembershipRequestImpl.class,
1105                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
1106                            new String[] {
1107                                    Long.class.getName(), Long.class.getName(),
1108                                    
1109                            Integer.class.getName(), Integer.class.getName(),
1110                                    OrderByComparator.class.getName()
1111                            });
1112            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
1113                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
1114                            MembershipRequestImpl.class,
1115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
1116                            new String[] { Long.class.getName(), Long.class.getName() },
1117                            MembershipRequestModelImpl.GROUPID_COLUMN_BITMASK |
1118                            MembershipRequestModelImpl.STATUSID_COLUMN_BITMASK |
1119                            MembershipRequestModelImpl.CREATEDATE_COLUMN_BITMASK);
1120            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
1121                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
1122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
1123                            new String[] { Long.class.getName(), Long.class.getName() });
1124    
1125            /**
1126             * Returns all the membership requests where groupId = &#63; and statusId = &#63;.
1127             *
1128             * @param groupId the group ID
1129             * @param statusId the status ID
1130             * @return the matching membership requests
1131             */
1132            @Override
1133            public List<MembershipRequest> findByG_S(long groupId, long statusId) {
1134                    return findByG_S(groupId, statusId, QueryUtil.ALL_POS,
1135                            QueryUtil.ALL_POS, null);
1136            }
1137    
1138            /**
1139             * Returns a range of all the membership requests where groupId = &#63; and statusId = &#63;.
1140             *
1141             * <p>
1142             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
1143             * </p>
1144             *
1145             * @param groupId the group ID
1146             * @param statusId the status ID
1147             * @param start the lower bound of the range of membership requests
1148             * @param end the upper bound of the range of membership requests (not inclusive)
1149             * @return the range of matching membership requests
1150             */
1151            @Override
1152            public List<MembershipRequest> findByG_S(long groupId, long statusId,
1153                    int start, int end) {
1154                    return findByG_S(groupId, statusId, start, end, null);
1155            }
1156    
1157            /**
1158             * Returns an ordered range of all the membership requests where groupId = &#63; and statusId = &#63;.
1159             *
1160             * <p>
1161             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
1162             * </p>
1163             *
1164             * @param groupId the group ID
1165             * @param statusId the status ID
1166             * @param start the lower bound of the range of membership requests
1167             * @param end the upper bound of the range of membership requests (not inclusive)
1168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1169             * @return the ordered range of matching membership requests
1170             */
1171            @Override
1172            public List<MembershipRequest> findByG_S(long groupId, long statusId,
1173                    int start, int end,
1174                    OrderByComparator<MembershipRequest> orderByComparator) {
1175                    return findByG_S(groupId, statusId, start, end, orderByComparator, true);
1176            }
1177    
1178            /**
1179             * Returns an ordered range of all the membership requests where groupId = &#63; and statusId = &#63;.
1180             *
1181             * <p>
1182             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
1183             * </p>
1184             *
1185             * @param groupId the group ID
1186             * @param statusId the status ID
1187             * @param start the lower bound of the range of membership requests
1188             * @param end the upper bound of the range of membership requests (not inclusive)
1189             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1190             * @param retrieveFromCache whether to retrieve from the finder cache
1191             * @return the ordered range of matching membership requests
1192             */
1193            @Override
1194            public List<MembershipRequest> findByG_S(long groupId, long statusId,
1195                    int start, int end,
1196                    OrderByComparator<MembershipRequest> orderByComparator,
1197                    boolean retrieveFromCache) {
1198                    boolean pagination = true;
1199                    FinderPath finderPath = null;
1200                    Object[] finderArgs = null;
1201    
1202                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1203                                    (orderByComparator == null)) {
1204                            pagination = false;
1205                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
1206                            finderArgs = new Object[] { groupId, statusId };
1207                    }
1208                    else {
1209                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
1210                            finderArgs = new Object[] {
1211                                            groupId, statusId,
1212                                            
1213                                            start, end, orderByComparator
1214                                    };
1215                    }
1216    
1217                    List<MembershipRequest> list = null;
1218    
1219                    if (retrieveFromCache) {
1220                            list = (List<MembershipRequest>)finderCache.getResult(finderPath,
1221                                            finderArgs, this);
1222    
1223                            if ((list != null) && !list.isEmpty()) {
1224                                    for (MembershipRequest membershipRequest : list) {
1225                                            if ((groupId != membershipRequest.getGroupId()) ||
1226                                                            (statusId != membershipRequest.getStatusId())) {
1227                                                    list = null;
1228    
1229                                                    break;
1230                                            }
1231                                    }
1232                            }
1233                    }
1234    
1235                    if (list == null) {
1236                            StringBundler query = null;
1237    
1238                            if (orderByComparator != null) {
1239                                    query = new StringBundler(4 +
1240                                                    (orderByComparator.getOrderByFields().length * 3));
1241                            }
1242                            else {
1243                                    query = new StringBundler(4);
1244                            }
1245    
1246                            query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE);
1247    
1248                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
1249    
1250                            query.append(_FINDER_COLUMN_G_S_STATUSID_2);
1251    
1252                            if (orderByComparator != null) {
1253                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1254                                            orderByComparator);
1255                            }
1256                            else
1257                             if (pagination) {
1258                                    query.append(MembershipRequestModelImpl.ORDER_BY_JPQL);
1259                            }
1260    
1261                            String sql = query.toString();
1262    
1263                            Session session = null;
1264    
1265                            try {
1266                                    session = openSession();
1267    
1268                                    Query q = session.createQuery(sql);
1269    
1270                                    QueryPos qPos = QueryPos.getInstance(q);
1271    
1272                                    qPos.add(groupId);
1273    
1274                                    qPos.add(statusId);
1275    
1276                                    if (!pagination) {
1277                                            list = (List<MembershipRequest>)QueryUtil.list(q,
1278                                                            getDialect(), start, end, false);
1279    
1280                                            Collections.sort(list);
1281    
1282                                            list = Collections.unmodifiableList(list);
1283                                    }
1284                                    else {
1285                                            list = (List<MembershipRequest>)QueryUtil.list(q,
1286                                                            getDialect(), start, end);
1287                                    }
1288    
1289                                    cacheResult(list);
1290    
1291                                    finderCache.putResult(finderPath, finderArgs, list);
1292                            }
1293                            catch (Exception e) {
1294                                    finderCache.removeResult(finderPath, finderArgs);
1295    
1296                                    throw processException(e);
1297                            }
1298                            finally {
1299                                    closeSession(session);
1300                            }
1301                    }
1302    
1303                    return list;
1304            }
1305    
1306            /**
1307             * Returns the first membership request in the ordered set where groupId = &#63; and statusId = &#63;.
1308             *
1309             * @param groupId the group ID
1310             * @param statusId the status ID
1311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1312             * @return the first matching membership request
1313             * @throws NoSuchMembershipRequestException if a matching membership request could not be found
1314             */
1315            @Override
1316            public MembershipRequest findByG_S_First(long groupId, long statusId,
1317                    OrderByComparator<MembershipRequest> orderByComparator)
1318                    throws NoSuchMembershipRequestException {
1319                    MembershipRequest membershipRequest = fetchByG_S_First(groupId,
1320                                    statusId, orderByComparator);
1321    
1322                    if (membershipRequest != null) {
1323                            return membershipRequest;
1324                    }
1325    
1326                    StringBundler msg = new StringBundler(6);
1327    
1328                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1329    
1330                    msg.append("groupId=");
1331                    msg.append(groupId);
1332    
1333                    msg.append(", statusId=");
1334                    msg.append(statusId);
1335    
1336                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1337    
1338                    throw new NoSuchMembershipRequestException(msg.toString());
1339            }
1340    
1341            /**
1342             * Returns the first membership request in the ordered set where groupId = &#63; and statusId = &#63;.
1343             *
1344             * @param groupId the group ID
1345             * @param statusId the status ID
1346             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1347             * @return the first matching membership request, or <code>null</code> if a matching membership request could not be found
1348             */
1349            @Override
1350            public MembershipRequest fetchByG_S_First(long groupId, long statusId,
1351                    OrderByComparator<MembershipRequest> orderByComparator) {
1352                    List<MembershipRequest> list = findByG_S(groupId, statusId, 0, 1,
1353                                    orderByComparator);
1354    
1355                    if (!list.isEmpty()) {
1356                            return list.get(0);
1357                    }
1358    
1359                    return null;
1360            }
1361    
1362            /**
1363             * Returns the last membership request in the ordered set where groupId = &#63; and statusId = &#63;.
1364             *
1365             * @param groupId the group ID
1366             * @param statusId the status ID
1367             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1368             * @return the last matching membership request
1369             * @throws NoSuchMembershipRequestException if a matching membership request could not be found
1370             */
1371            @Override
1372            public MembershipRequest findByG_S_Last(long groupId, long statusId,
1373                    OrderByComparator<MembershipRequest> orderByComparator)
1374                    throws NoSuchMembershipRequestException {
1375                    MembershipRequest membershipRequest = fetchByG_S_Last(groupId,
1376                                    statusId, orderByComparator);
1377    
1378                    if (membershipRequest != null) {
1379                            return membershipRequest;
1380                    }
1381    
1382                    StringBundler msg = new StringBundler(6);
1383    
1384                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1385    
1386                    msg.append("groupId=");
1387                    msg.append(groupId);
1388    
1389                    msg.append(", statusId=");
1390                    msg.append(statusId);
1391    
1392                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1393    
1394                    throw new NoSuchMembershipRequestException(msg.toString());
1395            }
1396    
1397            /**
1398             * Returns the last membership request in the ordered set where groupId = &#63; and statusId = &#63;.
1399             *
1400             * @param groupId the group ID
1401             * @param statusId the status ID
1402             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1403             * @return the last matching membership request, or <code>null</code> if a matching membership request could not be found
1404             */
1405            @Override
1406            public MembershipRequest fetchByG_S_Last(long groupId, long statusId,
1407                    OrderByComparator<MembershipRequest> orderByComparator) {
1408                    int count = countByG_S(groupId, statusId);
1409    
1410                    if (count == 0) {
1411                            return null;
1412                    }
1413    
1414                    List<MembershipRequest> list = findByG_S(groupId, statusId, count - 1,
1415                                    count, orderByComparator);
1416    
1417                    if (!list.isEmpty()) {
1418                            return list.get(0);
1419                    }
1420    
1421                    return null;
1422            }
1423    
1424            /**
1425             * Returns the membership requests before and after the current membership request in the ordered set where groupId = &#63; and statusId = &#63;.
1426             *
1427             * @param membershipRequestId the primary key of the current membership request
1428             * @param groupId the group ID
1429             * @param statusId the status ID
1430             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1431             * @return the previous, current, and next membership request
1432             * @throws NoSuchMembershipRequestException if a membership request with the primary key could not be found
1433             */
1434            @Override
1435            public MembershipRequest[] findByG_S_PrevAndNext(long membershipRequestId,
1436                    long groupId, long statusId,
1437                    OrderByComparator<MembershipRequest> orderByComparator)
1438                    throws NoSuchMembershipRequestException {
1439                    MembershipRequest membershipRequest = findByPrimaryKey(membershipRequestId);
1440    
1441                    Session session = null;
1442    
1443                    try {
1444                            session = openSession();
1445    
1446                            MembershipRequest[] array = new MembershipRequestImpl[3];
1447    
1448                            array[0] = getByG_S_PrevAndNext(session, membershipRequest,
1449                                            groupId, statusId, orderByComparator, true);
1450    
1451                            array[1] = membershipRequest;
1452    
1453                            array[2] = getByG_S_PrevAndNext(session, membershipRequest,
1454                                            groupId, statusId, orderByComparator, false);
1455    
1456                            return array;
1457                    }
1458                    catch (Exception e) {
1459                            throw processException(e);
1460                    }
1461                    finally {
1462                            closeSession(session);
1463                    }
1464            }
1465    
1466            protected MembershipRequest getByG_S_PrevAndNext(Session session,
1467                    MembershipRequest membershipRequest, long groupId, long statusId,
1468                    OrderByComparator<MembershipRequest> orderByComparator, boolean previous) {
1469                    StringBundler query = null;
1470    
1471                    if (orderByComparator != null) {
1472                            query = new StringBundler(6 +
1473                                            (orderByComparator.getOrderByFields().length * 6));
1474                    }
1475                    else {
1476                            query = new StringBundler(3);
1477                    }
1478    
1479                    query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE);
1480    
1481                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
1482    
1483                    query.append(_FINDER_COLUMN_G_S_STATUSID_2);
1484    
1485                    if (orderByComparator != null) {
1486                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1487    
1488                            if (orderByConditionFields.length > 0) {
1489                                    query.append(WHERE_AND);
1490                            }
1491    
1492                            for (int i = 0; i < orderByConditionFields.length; i++) {
1493                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1494                                    query.append(orderByConditionFields[i]);
1495    
1496                                    if ((i + 1) < orderByConditionFields.length) {
1497                                            if (orderByComparator.isAscending() ^ previous) {
1498                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1499                                            }
1500                                            else {
1501                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1502                                            }
1503                                    }
1504                                    else {
1505                                            if (orderByComparator.isAscending() ^ previous) {
1506                                                    query.append(WHERE_GREATER_THAN);
1507                                            }
1508                                            else {
1509                                                    query.append(WHERE_LESSER_THAN);
1510                                            }
1511                                    }
1512                            }
1513    
1514                            query.append(ORDER_BY_CLAUSE);
1515    
1516                            String[] orderByFields = orderByComparator.getOrderByFields();
1517    
1518                            for (int i = 0; i < orderByFields.length; i++) {
1519                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1520                                    query.append(orderByFields[i]);
1521    
1522                                    if ((i + 1) < orderByFields.length) {
1523                                            if (orderByComparator.isAscending() ^ previous) {
1524                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1525                                            }
1526                                            else {
1527                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1528                                            }
1529                                    }
1530                                    else {
1531                                            if (orderByComparator.isAscending() ^ previous) {
1532                                                    query.append(ORDER_BY_ASC);
1533                                            }
1534                                            else {
1535                                                    query.append(ORDER_BY_DESC);
1536                                            }
1537                                    }
1538                            }
1539                    }
1540                    else {
1541                            query.append(MembershipRequestModelImpl.ORDER_BY_JPQL);
1542                    }
1543    
1544                    String sql = query.toString();
1545    
1546                    Query q = session.createQuery(sql);
1547    
1548                    q.setFirstResult(0);
1549                    q.setMaxResults(2);
1550    
1551                    QueryPos qPos = QueryPos.getInstance(q);
1552    
1553                    qPos.add(groupId);
1554    
1555                    qPos.add(statusId);
1556    
1557                    if (orderByComparator != null) {
1558                            Object[] values = orderByComparator.getOrderByConditionValues(membershipRequest);
1559    
1560                            for (Object value : values) {
1561                                    qPos.add(value);
1562                            }
1563                    }
1564    
1565                    List<MembershipRequest> list = q.list();
1566    
1567                    if (list.size() == 2) {
1568                            return list.get(1);
1569                    }
1570                    else {
1571                            return null;
1572                    }
1573            }
1574    
1575            /**
1576             * Removes all the membership requests where groupId = &#63; and statusId = &#63; from the database.
1577             *
1578             * @param groupId the group ID
1579             * @param statusId the status ID
1580             */
1581            @Override
1582            public void removeByG_S(long groupId, long statusId) {
1583                    for (MembershipRequest membershipRequest : findByG_S(groupId, statusId,
1584                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1585                            remove(membershipRequest);
1586                    }
1587            }
1588    
1589            /**
1590             * Returns the number of membership requests where groupId = &#63; and statusId = &#63;.
1591             *
1592             * @param groupId the group ID
1593             * @param statusId the status ID
1594             * @return the number of matching membership requests
1595             */
1596            @Override
1597            public int countByG_S(long groupId, long statusId) {
1598                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
1599    
1600                    Object[] finderArgs = new Object[] { groupId, statusId };
1601    
1602                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1603    
1604                    if (count == null) {
1605                            StringBundler query = new StringBundler(3);
1606    
1607                            query.append(_SQL_COUNT_MEMBERSHIPREQUEST_WHERE);
1608    
1609                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
1610    
1611                            query.append(_FINDER_COLUMN_G_S_STATUSID_2);
1612    
1613                            String sql = query.toString();
1614    
1615                            Session session = null;
1616    
1617                            try {
1618                                    session = openSession();
1619    
1620                                    Query q = session.createQuery(sql);
1621    
1622                                    QueryPos qPos = QueryPos.getInstance(q);
1623    
1624                                    qPos.add(groupId);
1625    
1626                                    qPos.add(statusId);
1627    
1628                                    count = (Long)q.uniqueResult();
1629    
1630                                    finderCache.putResult(finderPath, finderArgs, count);
1631                            }
1632                            catch (Exception e) {
1633                                    finderCache.removeResult(finderPath, finderArgs);
1634    
1635                                    throw processException(e);
1636                            }
1637                            finally {
1638                                    closeSession(session);
1639                            }
1640                    }
1641    
1642                    return count.intValue();
1643            }
1644    
1645            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "membershipRequest.groupId = ? AND ";
1646            private static final String _FINDER_COLUMN_G_S_STATUSID_2 = "membershipRequest.statusId = ?";
1647            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
1648                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
1649                            MembershipRequestImpl.class,
1650                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
1651                            new String[] {
1652                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1653                                    
1654                            Integer.class.getName(), Integer.class.getName(),
1655                                    OrderByComparator.class.getName()
1656                            });
1657            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
1658                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED,
1659                            MembershipRequestImpl.class,
1660                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
1661                            new String[] {
1662                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
1663                            },
1664                            MembershipRequestModelImpl.GROUPID_COLUMN_BITMASK |
1665                            MembershipRequestModelImpl.USERID_COLUMN_BITMASK |
1666                            MembershipRequestModelImpl.STATUSID_COLUMN_BITMASK |
1667                            MembershipRequestModelImpl.CREATEDATE_COLUMN_BITMASK);
1668            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
1669                            MembershipRequestModelImpl.FINDER_CACHE_ENABLED, Long.class,
1670                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
1671                            new String[] {
1672                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
1673                            });
1674    
1675            /**
1676             * Returns all the membership requests where groupId = &#63; and userId = &#63; and statusId = &#63;.
1677             *
1678             * @param groupId the group ID
1679             * @param userId the user ID
1680             * @param statusId the status ID
1681             * @return the matching membership requests
1682             */
1683            @Override
1684            public List<MembershipRequest> findByG_U_S(long groupId, long userId,
1685                    long statusId) {
1686                    return findByG_U_S(groupId, userId, statusId, QueryUtil.ALL_POS,
1687                            QueryUtil.ALL_POS, null);
1688            }
1689    
1690            /**
1691             * Returns a range of all the membership requests where groupId = &#63; and userId = &#63; and statusId = &#63;.
1692             *
1693             * <p>
1694             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
1695             * </p>
1696             *
1697             * @param groupId the group ID
1698             * @param userId the user ID
1699             * @param statusId the status ID
1700             * @param start the lower bound of the range of membership requests
1701             * @param end the upper bound of the range of membership requests (not inclusive)
1702             * @return the range of matching membership requests
1703             */
1704            @Override
1705            public List<MembershipRequest> findByG_U_S(long groupId, long userId,
1706                    long statusId, int start, int end) {
1707                    return findByG_U_S(groupId, userId, statusId, start, end, null);
1708            }
1709    
1710            /**
1711             * Returns an ordered range of all the membership requests where groupId = &#63; and userId = &#63; and statusId = &#63;.
1712             *
1713             * <p>
1714             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
1715             * </p>
1716             *
1717             * @param groupId the group ID
1718             * @param userId the user ID
1719             * @param statusId the status ID
1720             * @param start the lower bound of the range of membership requests
1721             * @param end the upper bound of the range of membership requests (not inclusive)
1722             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1723             * @return the ordered range of matching membership requests
1724             */
1725            @Override
1726            public List<MembershipRequest> findByG_U_S(long groupId, long userId,
1727                    long statusId, int start, int end,
1728                    OrderByComparator<MembershipRequest> orderByComparator) {
1729                    return findByG_U_S(groupId, userId, statusId, start, end,
1730                            orderByComparator, true);
1731            }
1732    
1733            /**
1734             * Returns an ordered range of all the membership requests where groupId = &#63; and userId = &#63; and statusId = &#63;.
1735             *
1736             * <p>
1737             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
1738             * </p>
1739             *
1740             * @param groupId the group ID
1741             * @param userId the user ID
1742             * @param statusId the status ID
1743             * @param start the lower bound of the range of membership requests
1744             * @param end the upper bound of the range of membership requests (not inclusive)
1745             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1746             * @param retrieveFromCache whether to retrieve from the finder cache
1747             * @return the ordered range of matching membership requests
1748             */
1749            @Override
1750            public List<MembershipRequest> findByG_U_S(long groupId, long userId,
1751                    long statusId, int start, int end,
1752                    OrderByComparator<MembershipRequest> orderByComparator,
1753                    boolean retrieveFromCache) {
1754                    boolean pagination = true;
1755                    FinderPath finderPath = null;
1756                    Object[] finderArgs = null;
1757    
1758                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1759                                    (orderByComparator == null)) {
1760                            pagination = false;
1761                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
1762                            finderArgs = new Object[] { groupId, userId, statusId };
1763                    }
1764                    else {
1765                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
1766                            finderArgs = new Object[] {
1767                                            groupId, userId, statusId,
1768                                            
1769                                            start, end, orderByComparator
1770                                    };
1771                    }
1772    
1773                    List<MembershipRequest> list = null;
1774    
1775                    if (retrieveFromCache) {
1776                            list = (List<MembershipRequest>)finderCache.getResult(finderPath,
1777                                            finderArgs, this);
1778    
1779                            if ((list != null) && !list.isEmpty()) {
1780                                    for (MembershipRequest membershipRequest : list) {
1781                                            if ((groupId != membershipRequest.getGroupId()) ||
1782                                                            (userId != membershipRequest.getUserId()) ||
1783                                                            (statusId != membershipRequest.getStatusId())) {
1784                                                    list = null;
1785    
1786                                                    break;
1787                                            }
1788                                    }
1789                            }
1790                    }
1791    
1792                    if (list == null) {
1793                            StringBundler query = null;
1794    
1795                            if (orderByComparator != null) {
1796                                    query = new StringBundler(5 +
1797                                                    (orderByComparator.getOrderByFields().length * 3));
1798                            }
1799                            else {
1800                                    query = new StringBundler(5);
1801                            }
1802    
1803                            query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE);
1804    
1805                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
1806    
1807                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
1808    
1809                            query.append(_FINDER_COLUMN_G_U_S_STATUSID_2);
1810    
1811                            if (orderByComparator != null) {
1812                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1813                                            orderByComparator);
1814                            }
1815                            else
1816                             if (pagination) {
1817                                    query.append(MembershipRequestModelImpl.ORDER_BY_JPQL);
1818                            }
1819    
1820                            String sql = query.toString();
1821    
1822                            Session session = null;
1823    
1824                            try {
1825                                    session = openSession();
1826    
1827                                    Query q = session.createQuery(sql);
1828    
1829                                    QueryPos qPos = QueryPos.getInstance(q);
1830    
1831                                    qPos.add(groupId);
1832    
1833                                    qPos.add(userId);
1834    
1835                                    qPos.add(statusId);
1836    
1837                                    if (!pagination) {
1838                                            list = (List<MembershipRequest>)QueryUtil.list(q,
1839                                                            getDialect(), start, end, false);
1840    
1841                                            Collections.sort(list);
1842    
1843                                            list = Collections.unmodifiableList(list);
1844                                    }
1845                                    else {
1846                                            list = (List<MembershipRequest>)QueryUtil.list(q,
1847                                                            getDialect(), start, end);
1848                                    }
1849    
1850                                    cacheResult(list);
1851    
1852                                    finderCache.putResult(finderPath, finderArgs, list);
1853                            }
1854                            catch (Exception e) {
1855                                    finderCache.removeResult(finderPath, finderArgs);
1856    
1857                                    throw processException(e);
1858                            }
1859                            finally {
1860                                    closeSession(session);
1861                            }
1862                    }
1863    
1864                    return list;
1865            }
1866    
1867            /**
1868             * Returns the first membership request in the ordered set where groupId = &#63; and userId = &#63; and statusId = &#63;.
1869             *
1870             * @param groupId the group ID
1871             * @param userId the user ID
1872             * @param statusId the status ID
1873             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1874             * @return the first matching membership request
1875             * @throws NoSuchMembershipRequestException if a matching membership request could not be found
1876             */
1877            @Override
1878            public MembershipRequest findByG_U_S_First(long groupId, long userId,
1879                    long statusId, OrderByComparator<MembershipRequest> orderByComparator)
1880                    throws NoSuchMembershipRequestException {
1881                    MembershipRequest membershipRequest = fetchByG_U_S_First(groupId,
1882                                    userId, statusId, orderByComparator);
1883    
1884                    if (membershipRequest != null) {
1885                            return membershipRequest;
1886                    }
1887    
1888                    StringBundler msg = new StringBundler(8);
1889    
1890                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1891    
1892                    msg.append("groupId=");
1893                    msg.append(groupId);
1894    
1895                    msg.append(", userId=");
1896                    msg.append(userId);
1897    
1898                    msg.append(", statusId=");
1899                    msg.append(statusId);
1900    
1901                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1902    
1903                    throw new NoSuchMembershipRequestException(msg.toString());
1904            }
1905    
1906            /**
1907             * Returns the first membership request in the ordered set where groupId = &#63; and userId = &#63; and statusId = &#63;.
1908             *
1909             * @param groupId the group ID
1910             * @param userId the user ID
1911             * @param statusId the status ID
1912             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1913             * @return the first matching membership request, or <code>null</code> if a matching membership request could not be found
1914             */
1915            @Override
1916            public MembershipRequest fetchByG_U_S_First(long groupId, long userId,
1917                    long statusId, OrderByComparator<MembershipRequest> orderByComparator) {
1918                    List<MembershipRequest> list = findByG_U_S(groupId, userId, statusId,
1919                                    0, 1, orderByComparator);
1920    
1921                    if (!list.isEmpty()) {
1922                            return list.get(0);
1923                    }
1924    
1925                    return null;
1926            }
1927    
1928            /**
1929             * Returns the last membership request in the ordered set where groupId = &#63; and userId = &#63; and statusId = &#63;.
1930             *
1931             * @param groupId the group ID
1932             * @param userId the user ID
1933             * @param statusId the status ID
1934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1935             * @return the last matching membership request
1936             * @throws NoSuchMembershipRequestException if a matching membership request could not be found
1937             */
1938            @Override
1939            public MembershipRequest findByG_U_S_Last(long groupId, long userId,
1940                    long statusId, OrderByComparator<MembershipRequest> orderByComparator)
1941                    throws NoSuchMembershipRequestException {
1942                    MembershipRequest membershipRequest = fetchByG_U_S_Last(groupId,
1943                                    userId, statusId, orderByComparator);
1944    
1945                    if (membershipRequest != null) {
1946                            return membershipRequest;
1947                    }
1948    
1949                    StringBundler msg = new StringBundler(8);
1950    
1951                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1952    
1953                    msg.append("groupId=");
1954                    msg.append(groupId);
1955    
1956                    msg.append(", userId=");
1957                    msg.append(userId);
1958    
1959                    msg.append(", statusId=");
1960                    msg.append(statusId);
1961    
1962                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1963    
1964                    throw new NoSuchMembershipRequestException(msg.toString());
1965            }
1966    
1967            /**
1968             * Returns the last membership request in the ordered set where groupId = &#63; and userId = &#63; and statusId = &#63;.
1969             *
1970             * @param groupId the group ID
1971             * @param userId the user ID
1972             * @param statusId the status ID
1973             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1974             * @return the last matching membership request, or <code>null</code> if a matching membership request could not be found
1975             */
1976            @Override
1977            public MembershipRequest fetchByG_U_S_Last(long groupId, long userId,
1978                    long statusId, OrderByComparator<MembershipRequest> orderByComparator) {
1979                    int count = countByG_U_S(groupId, userId, statusId);
1980    
1981                    if (count == 0) {
1982                            return null;
1983                    }
1984    
1985                    List<MembershipRequest> list = findByG_U_S(groupId, userId, statusId,
1986                                    count - 1, count, orderByComparator);
1987    
1988                    if (!list.isEmpty()) {
1989                            return list.get(0);
1990                    }
1991    
1992                    return null;
1993            }
1994    
1995            /**
1996             * Returns the membership requests before and after the current membership request in the ordered set where groupId = &#63; and userId = &#63; and statusId = &#63;.
1997             *
1998             * @param membershipRequestId the primary key of the current membership request
1999             * @param groupId the group ID
2000             * @param userId the user ID
2001             * @param statusId the status ID
2002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2003             * @return the previous, current, and next membership request
2004             * @throws NoSuchMembershipRequestException if a membership request with the primary key could not be found
2005             */
2006            @Override
2007            public MembershipRequest[] findByG_U_S_PrevAndNext(
2008                    long membershipRequestId, long groupId, long userId, long statusId,
2009                    OrderByComparator<MembershipRequest> orderByComparator)
2010                    throws NoSuchMembershipRequestException {
2011                    MembershipRequest membershipRequest = findByPrimaryKey(membershipRequestId);
2012    
2013                    Session session = null;
2014    
2015                    try {
2016                            session = openSession();
2017    
2018                            MembershipRequest[] array = new MembershipRequestImpl[3];
2019    
2020                            array[0] = getByG_U_S_PrevAndNext(session, membershipRequest,
2021                                            groupId, userId, statusId, orderByComparator, true);
2022    
2023                            array[1] = membershipRequest;
2024    
2025                            array[2] = getByG_U_S_PrevAndNext(session, membershipRequest,
2026                                            groupId, userId, statusId, orderByComparator, false);
2027    
2028                            return array;
2029                    }
2030                    catch (Exception e) {
2031                            throw processException(e);
2032                    }
2033                    finally {
2034                            closeSession(session);
2035                    }
2036            }
2037    
2038            protected MembershipRequest getByG_U_S_PrevAndNext(Session session,
2039                    MembershipRequest membershipRequest, long groupId, long userId,
2040                    long statusId, OrderByComparator<MembershipRequest> orderByComparator,
2041                    boolean previous) {
2042                    StringBundler query = null;
2043    
2044                    if (orderByComparator != null) {
2045                            query = new StringBundler(6 +
2046                                            (orderByComparator.getOrderByFields().length * 6));
2047                    }
2048                    else {
2049                            query = new StringBundler(3);
2050                    }
2051    
2052                    query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE);
2053    
2054                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
2055    
2056                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
2057    
2058                    query.append(_FINDER_COLUMN_G_U_S_STATUSID_2);
2059    
2060                    if (orderByComparator != null) {
2061                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2062    
2063                            if (orderByConditionFields.length > 0) {
2064                                    query.append(WHERE_AND);
2065                            }
2066    
2067                            for (int i = 0; i < orderByConditionFields.length; i++) {
2068                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2069                                    query.append(orderByConditionFields[i]);
2070    
2071                                    if ((i + 1) < orderByConditionFields.length) {
2072                                            if (orderByComparator.isAscending() ^ previous) {
2073                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2074                                            }
2075                                            else {
2076                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2077                                            }
2078                                    }
2079                                    else {
2080                                            if (orderByComparator.isAscending() ^ previous) {
2081                                                    query.append(WHERE_GREATER_THAN);
2082                                            }
2083                                            else {
2084                                                    query.append(WHERE_LESSER_THAN);
2085                                            }
2086                                    }
2087                            }
2088    
2089                            query.append(ORDER_BY_CLAUSE);
2090    
2091                            String[] orderByFields = orderByComparator.getOrderByFields();
2092    
2093                            for (int i = 0; i < orderByFields.length; i++) {
2094                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2095                                    query.append(orderByFields[i]);
2096    
2097                                    if ((i + 1) < orderByFields.length) {
2098                                            if (orderByComparator.isAscending() ^ previous) {
2099                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2100                                            }
2101                                            else {
2102                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2103                                            }
2104                                    }
2105                                    else {
2106                                            if (orderByComparator.isAscending() ^ previous) {
2107                                                    query.append(ORDER_BY_ASC);
2108                                            }
2109                                            else {
2110                                                    query.append(ORDER_BY_DESC);
2111                                            }
2112                                    }
2113                            }
2114                    }
2115                    else {
2116                            query.append(MembershipRequestModelImpl.ORDER_BY_JPQL);
2117                    }
2118    
2119                    String sql = query.toString();
2120    
2121                    Query q = session.createQuery(sql);
2122    
2123                    q.setFirstResult(0);
2124                    q.setMaxResults(2);
2125    
2126                    QueryPos qPos = QueryPos.getInstance(q);
2127    
2128                    qPos.add(groupId);
2129    
2130                    qPos.add(userId);
2131    
2132                    qPos.add(statusId);
2133    
2134                    if (orderByComparator != null) {
2135                            Object[] values = orderByComparator.getOrderByConditionValues(membershipRequest);
2136    
2137                            for (Object value : values) {
2138                                    qPos.add(value);
2139                            }
2140                    }
2141    
2142                    List<MembershipRequest> list = q.list();
2143    
2144                    if (list.size() == 2) {
2145                            return list.get(1);
2146                    }
2147                    else {
2148                            return null;
2149                    }
2150            }
2151    
2152            /**
2153             * Removes all the membership requests where groupId = &#63; and userId = &#63; and statusId = &#63; from the database.
2154             *
2155             * @param groupId the group ID
2156             * @param userId the user ID
2157             * @param statusId the status ID
2158             */
2159            @Override
2160            public void removeByG_U_S(long groupId, long userId, long statusId) {
2161                    for (MembershipRequest membershipRequest : findByG_U_S(groupId, userId,
2162                                    statusId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2163                            remove(membershipRequest);
2164                    }
2165            }
2166    
2167            /**
2168             * Returns the number of membership requests where groupId = &#63; and userId = &#63; and statusId = &#63;.
2169             *
2170             * @param groupId the group ID
2171             * @param userId the user ID
2172             * @param statusId the status ID
2173             * @return the number of matching membership requests
2174             */
2175            @Override
2176            public int countByG_U_S(long groupId, long userId, long statusId) {
2177                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
2178    
2179                    Object[] finderArgs = new Object[] { groupId, userId, statusId };
2180    
2181                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2182    
2183                    if (count == null) {
2184                            StringBundler query = new StringBundler(4);
2185    
2186                            query.append(_SQL_COUNT_MEMBERSHIPREQUEST_WHERE);
2187    
2188                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
2189    
2190                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
2191    
2192                            query.append(_FINDER_COLUMN_G_U_S_STATUSID_2);
2193    
2194                            String sql = query.toString();
2195    
2196                            Session session = null;
2197    
2198                            try {
2199                                    session = openSession();
2200    
2201                                    Query q = session.createQuery(sql);
2202    
2203                                    QueryPos qPos = QueryPos.getInstance(q);
2204    
2205                                    qPos.add(groupId);
2206    
2207                                    qPos.add(userId);
2208    
2209                                    qPos.add(statusId);
2210    
2211                                    count = (Long)q.uniqueResult();
2212    
2213                                    finderCache.putResult(finderPath, finderArgs, count);
2214                            }
2215                            catch (Exception e) {
2216                                    finderCache.removeResult(finderPath, finderArgs);
2217    
2218                                    throw processException(e);
2219                            }
2220                            finally {
2221                                    closeSession(session);
2222                            }
2223                    }
2224    
2225                    return count.intValue();
2226            }
2227    
2228            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "membershipRequest.groupId = ? AND ";
2229            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "membershipRequest.userId = ? AND ";
2230            private static final String _FINDER_COLUMN_G_U_S_STATUSID_2 = "membershipRequest.statusId = ?";
2231    
2232            public MembershipRequestPersistenceImpl() {
2233                    setModelClass(MembershipRequest.class);
2234            }
2235    
2236            /**
2237             * Caches the membership request in the entity cache if it is enabled.
2238             *
2239             * @param membershipRequest the membership request
2240             */
2241            @Override
2242            public void cacheResult(MembershipRequest membershipRequest) {
2243                    entityCache.putResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2244                            MembershipRequestImpl.class, membershipRequest.getPrimaryKey(),
2245                            membershipRequest);
2246    
2247                    membershipRequest.resetOriginalValues();
2248            }
2249    
2250            /**
2251             * Caches the membership requests in the entity cache if it is enabled.
2252             *
2253             * @param membershipRequests the membership requests
2254             */
2255            @Override
2256            public void cacheResult(List<MembershipRequest> membershipRequests) {
2257                    for (MembershipRequest membershipRequest : membershipRequests) {
2258                            if (entityCache.getResult(
2259                                                    MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2260                                                    MembershipRequestImpl.class,
2261                                                    membershipRequest.getPrimaryKey()) == null) {
2262                                    cacheResult(membershipRequest);
2263                            }
2264                            else {
2265                                    membershipRequest.resetOriginalValues();
2266                            }
2267                    }
2268            }
2269    
2270            /**
2271             * Clears the cache for all membership requests.
2272             *
2273             * <p>
2274             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
2275             * </p>
2276             */
2277            @Override
2278            public void clearCache() {
2279                    entityCache.clearCache(MembershipRequestImpl.class);
2280    
2281                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
2282                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2283                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2284            }
2285    
2286            /**
2287             * Clears the cache for the membership request.
2288             *
2289             * <p>
2290             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
2291             * </p>
2292             */
2293            @Override
2294            public void clearCache(MembershipRequest membershipRequest) {
2295                    entityCache.removeResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2296                            MembershipRequestImpl.class, membershipRequest.getPrimaryKey());
2297    
2298                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2299                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2300            }
2301    
2302            @Override
2303            public void clearCache(List<MembershipRequest> membershipRequests) {
2304                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2305                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2306    
2307                    for (MembershipRequest membershipRequest : membershipRequests) {
2308                            entityCache.removeResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2309                                    MembershipRequestImpl.class, membershipRequest.getPrimaryKey());
2310                    }
2311            }
2312    
2313            /**
2314             * Creates a new membership request with the primary key. Does not add the membership request to the database.
2315             *
2316             * @param membershipRequestId the primary key for the new membership request
2317             * @return the new membership request
2318             */
2319            @Override
2320            public MembershipRequest create(long membershipRequestId) {
2321                    MembershipRequest membershipRequest = new MembershipRequestImpl();
2322    
2323                    membershipRequest.setNew(true);
2324                    membershipRequest.setPrimaryKey(membershipRequestId);
2325    
2326                    return membershipRequest;
2327            }
2328    
2329            /**
2330             * Removes the membership request with the primary key from the database. Also notifies the appropriate model listeners.
2331             *
2332             * @param membershipRequestId the primary key of the membership request
2333             * @return the membership request that was removed
2334             * @throws NoSuchMembershipRequestException if a membership request with the primary key could not be found
2335             */
2336            @Override
2337            public MembershipRequest remove(long membershipRequestId)
2338                    throws NoSuchMembershipRequestException {
2339                    return remove((Serializable)membershipRequestId);
2340            }
2341    
2342            /**
2343             * Removes the membership request with the primary key from the database. Also notifies the appropriate model listeners.
2344             *
2345             * @param primaryKey the primary key of the membership request
2346             * @return the membership request that was removed
2347             * @throws NoSuchMembershipRequestException if a membership request with the primary key could not be found
2348             */
2349            @Override
2350            public MembershipRequest remove(Serializable primaryKey)
2351                    throws NoSuchMembershipRequestException {
2352                    Session session = null;
2353    
2354                    try {
2355                            session = openSession();
2356    
2357                            MembershipRequest membershipRequest = (MembershipRequest)session.get(MembershipRequestImpl.class,
2358                                            primaryKey);
2359    
2360                            if (membershipRequest == null) {
2361                                    if (_log.isWarnEnabled()) {
2362                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2363                                    }
2364    
2365                                    throw new NoSuchMembershipRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2366                                            primaryKey);
2367                            }
2368    
2369                            return remove(membershipRequest);
2370                    }
2371                    catch (NoSuchMembershipRequestException nsee) {
2372                            throw nsee;
2373                    }
2374                    catch (Exception e) {
2375                            throw processException(e);
2376                    }
2377                    finally {
2378                            closeSession(session);
2379                    }
2380            }
2381    
2382            @Override
2383            protected MembershipRequest removeImpl(MembershipRequest membershipRequest) {
2384                    membershipRequest = toUnwrappedModel(membershipRequest);
2385    
2386                    Session session = null;
2387    
2388                    try {
2389                            session = openSession();
2390    
2391                            if (!session.contains(membershipRequest)) {
2392                                    membershipRequest = (MembershipRequest)session.get(MembershipRequestImpl.class,
2393                                                    membershipRequest.getPrimaryKeyObj());
2394                            }
2395    
2396                            if (membershipRequest != null) {
2397                                    session.delete(membershipRequest);
2398                            }
2399                    }
2400                    catch (Exception e) {
2401                            throw processException(e);
2402                    }
2403                    finally {
2404                            closeSession(session);
2405                    }
2406    
2407                    if (membershipRequest != null) {
2408                            clearCache(membershipRequest);
2409                    }
2410    
2411                    return membershipRequest;
2412            }
2413    
2414            @Override
2415            public MembershipRequest updateImpl(MembershipRequest membershipRequest) {
2416                    membershipRequest = toUnwrappedModel(membershipRequest);
2417    
2418                    boolean isNew = membershipRequest.isNew();
2419    
2420                    MembershipRequestModelImpl membershipRequestModelImpl = (MembershipRequestModelImpl)membershipRequest;
2421    
2422                    Session session = null;
2423    
2424                    try {
2425                            session = openSession();
2426    
2427                            if (membershipRequest.isNew()) {
2428                                    session.save(membershipRequest);
2429    
2430                                    membershipRequest.setNew(false);
2431                            }
2432                            else {
2433                                    membershipRequest = (MembershipRequest)session.merge(membershipRequest);
2434                            }
2435                    }
2436                    catch (Exception e) {
2437                            throw processException(e);
2438                    }
2439                    finally {
2440                            closeSession(session);
2441                    }
2442    
2443                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2444    
2445                    if (isNew || !MembershipRequestModelImpl.COLUMN_BITMASK_ENABLED) {
2446                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2447                    }
2448    
2449                    else {
2450                            if ((membershipRequestModelImpl.getColumnBitmask() &
2451                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2452                                    Object[] args = new Object[] {
2453                                                    membershipRequestModelImpl.getOriginalGroupId()
2454                                            };
2455    
2456                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2457                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2458                                            args);
2459    
2460                                    args = new Object[] { membershipRequestModelImpl.getGroupId() };
2461    
2462                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2463                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2464                                            args);
2465                            }
2466    
2467                            if ((membershipRequestModelImpl.getColumnBitmask() &
2468                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
2469                                    Object[] args = new Object[] {
2470                                                    membershipRequestModelImpl.getOriginalUserId()
2471                                            };
2472    
2473                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
2474                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
2475                                            args);
2476    
2477                                    args = new Object[] { membershipRequestModelImpl.getUserId() };
2478    
2479                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
2480                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
2481                                            args);
2482                            }
2483    
2484                            if ((membershipRequestModelImpl.getColumnBitmask() &
2485                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
2486                                    Object[] args = new Object[] {
2487                                                    membershipRequestModelImpl.getOriginalGroupId(),
2488                                                    membershipRequestModelImpl.getOriginalStatusId()
2489                                            };
2490    
2491                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
2492                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
2493                                            args);
2494    
2495                                    args = new Object[] {
2496                                                    membershipRequestModelImpl.getGroupId(),
2497                                                    membershipRequestModelImpl.getStatusId()
2498                                            };
2499    
2500                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
2501                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
2502                                            args);
2503                            }
2504    
2505                            if ((membershipRequestModelImpl.getColumnBitmask() &
2506                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
2507                                    Object[] args = new Object[] {
2508                                                    membershipRequestModelImpl.getOriginalGroupId(),
2509                                                    membershipRequestModelImpl.getOriginalUserId(),
2510                                                    membershipRequestModelImpl.getOriginalStatusId()
2511                                            };
2512    
2513                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
2514                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
2515                                            args);
2516    
2517                                    args = new Object[] {
2518                                                    membershipRequestModelImpl.getGroupId(),
2519                                                    membershipRequestModelImpl.getUserId(),
2520                                                    membershipRequestModelImpl.getStatusId()
2521                                            };
2522    
2523                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
2524                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
2525                                            args);
2526                            }
2527                    }
2528    
2529                    entityCache.putResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2530                            MembershipRequestImpl.class, membershipRequest.getPrimaryKey(),
2531                            membershipRequest, false);
2532    
2533                    membershipRequest.resetOriginalValues();
2534    
2535                    return membershipRequest;
2536            }
2537    
2538            protected MembershipRequest toUnwrappedModel(
2539                    MembershipRequest membershipRequest) {
2540                    if (membershipRequest instanceof MembershipRequestImpl) {
2541                            return membershipRequest;
2542                    }
2543    
2544                    MembershipRequestImpl membershipRequestImpl = new MembershipRequestImpl();
2545    
2546                    membershipRequestImpl.setNew(membershipRequest.isNew());
2547                    membershipRequestImpl.setPrimaryKey(membershipRequest.getPrimaryKey());
2548    
2549                    membershipRequestImpl.setMvccVersion(membershipRequest.getMvccVersion());
2550                    membershipRequestImpl.setMembershipRequestId(membershipRequest.getMembershipRequestId());
2551                    membershipRequestImpl.setGroupId(membershipRequest.getGroupId());
2552                    membershipRequestImpl.setCompanyId(membershipRequest.getCompanyId());
2553                    membershipRequestImpl.setUserId(membershipRequest.getUserId());
2554                    membershipRequestImpl.setCreateDate(membershipRequest.getCreateDate());
2555                    membershipRequestImpl.setComments(membershipRequest.getComments());
2556                    membershipRequestImpl.setReplyComments(membershipRequest.getReplyComments());
2557                    membershipRequestImpl.setReplyDate(membershipRequest.getReplyDate());
2558                    membershipRequestImpl.setReplierUserId(membershipRequest.getReplierUserId());
2559                    membershipRequestImpl.setStatusId(membershipRequest.getStatusId());
2560    
2561                    return membershipRequestImpl;
2562            }
2563    
2564            /**
2565             * Returns the membership request with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2566             *
2567             * @param primaryKey the primary key of the membership request
2568             * @return the membership request
2569             * @throws NoSuchMembershipRequestException if a membership request with the primary key could not be found
2570             */
2571            @Override
2572            public MembershipRequest findByPrimaryKey(Serializable primaryKey)
2573                    throws NoSuchMembershipRequestException {
2574                    MembershipRequest membershipRequest = fetchByPrimaryKey(primaryKey);
2575    
2576                    if (membershipRequest == null) {
2577                            if (_log.isWarnEnabled()) {
2578                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2579                            }
2580    
2581                            throw new NoSuchMembershipRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2582                                    primaryKey);
2583                    }
2584    
2585                    return membershipRequest;
2586            }
2587    
2588            /**
2589             * Returns the membership request with the primary key or throws a {@link NoSuchMembershipRequestException} if it could not be found.
2590             *
2591             * @param membershipRequestId the primary key of the membership request
2592             * @return the membership request
2593             * @throws NoSuchMembershipRequestException if a membership request with the primary key could not be found
2594             */
2595            @Override
2596            public MembershipRequest findByPrimaryKey(long membershipRequestId)
2597                    throws NoSuchMembershipRequestException {
2598                    return findByPrimaryKey((Serializable)membershipRequestId);
2599            }
2600    
2601            /**
2602             * Returns the membership request with the primary key or returns <code>null</code> if it could not be found.
2603             *
2604             * @param primaryKey the primary key of the membership request
2605             * @return the membership request, or <code>null</code> if a membership request with the primary key could not be found
2606             */
2607            @Override
2608            public MembershipRequest fetchByPrimaryKey(Serializable primaryKey) {
2609                    MembershipRequest membershipRequest = (MembershipRequest)entityCache.getResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2610                                    MembershipRequestImpl.class, primaryKey);
2611    
2612                    if (membershipRequest == _nullMembershipRequest) {
2613                            return null;
2614                    }
2615    
2616                    if (membershipRequest == null) {
2617                            Session session = null;
2618    
2619                            try {
2620                                    session = openSession();
2621    
2622                                    membershipRequest = (MembershipRequest)session.get(MembershipRequestImpl.class,
2623                                                    primaryKey);
2624    
2625                                    if (membershipRequest != null) {
2626                                            cacheResult(membershipRequest);
2627                                    }
2628                                    else {
2629                                            entityCache.putResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2630                                                    MembershipRequestImpl.class, primaryKey,
2631                                                    _nullMembershipRequest);
2632                                    }
2633                            }
2634                            catch (Exception e) {
2635                                    entityCache.removeResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2636                                            MembershipRequestImpl.class, primaryKey);
2637    
2638                                    throw processException(e);
2639                            }
2640                            finally {
2641                                    closeSession(session);
2642                            }
2643                    }
2644    
2645                    return membershipRequest;
2646            }
2647    
2648            /**
2649             * Returns the membership request with the primary key or returns <code>null</code> if it could not be found.
2650             *
2651             * @param membershipRequestId the primary key of the membership request
2652             * @return the membership request, or <code>null</code> if a membership request with the primary key could not be found
2653             */
2654            @Override
2655            public MembershipRequest fetchByPrimaryKey(long membershipRequestId) {
2656                    return fetchByPrimaryKey((Serializable)membershipRequestId);
2657            }
2658    
2659            @Override
2660            public Map<Serializable, MembershipRequest> fetchByPrimaryKeys(
2661                    Set<Serializable> primaryKeys) {
2662                    if (primaryKeys.isEmpty()) {
2663                            return Collections.emptyMap();
2664                    }
2665    
2666                    Map<Serializable, MembershipRequest> map = new HashMap<Serializable, MembershipRequest>();
2667    
2668                    if (primaryKeys.size() == 1) {
2669                            Iterator<Serializable> iterator = primaryKeys.iterator();
2670    
2671                            Serializable primaryKey = iterator.next();
2672    
2673                            MembershipRequest membershipRequest = fetchByPrimaryKey(primaryKey);
2674    
2675                            if (membershipRequest != null) {
2676                                    map.put(primaryKey, membershipRequest);
2677                            }
2678    
2679                            return map;
2680                    }
2681    
2682                    Set<Serializable> uncachedPrimaryKeys = null;
2683    
2684                    for (Serializable primaryKey : primaryKeys) {
2685                            MembershipRequest membershipRequest = (MembershipRequest)entityCache.getResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2686                                            MembershipRequestImpl.class, primaryKey);
2687    
2688                            if (membershipRequest == null) {
2689                                    if (uncachedPrimaryKeys == null) {
2690                                            uncachedPrimaryKeys = new HashSet<Serializable>();
2691                                    }
2692    
2693                                    uncachedPrimaryKeys.add(primaryKey);
2694                            }
2695                            else {
2696                                    map.put(primaryKey, membershipRequest);
2697                            }
2698                    }
2699    
2700                    if (uncachedPrimaryKeys == null) {
2701                            return map;
2702                    }
2703    
2704                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2705                                    1);
2706    
2707                    query.append(_SQL_SELECT_MEMBERSHIPREQUEST_WHERE_PKS_IN);
2708    
2709                    for (Serializable primaryKey : uncachedPrimaryKeys) {
2710                            query.append(String.valueOf(primaryKey));
2711    
2712                            query.append(StringPool.COMMA);
2713                    }
2714    
2715                    query.setIndex(query.index() - 1);
2716    
2717                    query.append(StringPool.CLOSE_PARENTHESIS);
2718    
2719                    String sql = query.toString();
2720    
2721                    Session session = null;
2722    
2723                    try {
2724                            session = openSession();
2725    
2726                            Query q = session.createQuery(sql);
2727    
2728                            for (MembershipRequest membershipRequest : (List<MembershipRequest>)q.list()) {
2729                                    map.put(membershipRequest.getPrimaryKeyObj(), membershipRequest);
2730    
2731                                    cacheResult(membershipRequest);
2732    
2733                                    uncachedPrimaryKeys.remove(membershipRequest.getPrimaryKeyObj());
2734                            }
2735    
2736                            for (Serializable primaryKey : uncachedPrimaryKeys) {
2737                                    entityCache.putResult(MembershipRequestModelImpl.ENTITY_CACHE_ENABLED,
2738                                            MembershipRequestImpl.class, primaryKey,
2739                                            _nullMembershipRequest);
2740                            }
2741                    }
2742                    catch (Exception e) {
2743                            throw processException(e);
2744                    }
2745                    finally {
2746                            closeSession(session);
2747                    }
2748    
2749                    return map;
2750            }
2751    
2752            /**
2753             * Returns all the membership requests.
2754             *
2755             * @return the membership requests
2756             */
2757            @Override
2758            public List<MembershipRequest> findAll() {
2759                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2760            }
2761    
2762            /**
2763             * Returns a range of all the membership requests.
2764             *
2765             * <p>
2766             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
2767             * </p>
2768             *
2769             * @param start the lower bound of the range of membership requests
2770             * @param end the upper bound of the range of membership requests (not inclusive)
2771             * @return the range of membership requests
2772             */
2773            @Override
2774            public List<MembershipRequest> findAll(int start, int end) {
2775                    return findAll(start, end, null);
2776            }
2777    
2778            /**
2779             * Returns an ordered range of all the membership requests.
2780             *
2781             * <p>
2782             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
2783             * </p>
2784             *
2785             * @param start the lower bound of the range of membership requests
2786             * @param end the upper bound of the range of membership requests (not inclusive)
2787             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2788             * @return the ordered range of membership requests
2789             */
2790            @Override
2791            public List<MembershipRequest> findAll(int start, int end,
2792                    OrderByComparator<MembershipRequest> orderByComparator) {
2793                    return findAll(start, end, orderByComparator, true);
2794            }
2795    
2796            /**
2797             * Returns an ordered range of all the membership requests.
2798             *
2799             * <p>
2800             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MembershipRequestModelImpl}. If both <code>orderByComparator</code> 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.
2801             * </p>
2802             *
2803             * @param start the lower bound of the range of membership requests
2804             * @param end the upper bound of the range of membership requests (not inclusive)
2805             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2806             * @param retrieveFromCache whether to retrieve from the finder cache
2807             * @return the ordered range of membership requests
2808             */
2809            @Override
2810            public List<MembershipRequest> findAll(int start, int end,
2811                    OrderByComparator<MembershipRequest> orderByComparator,
2812                    boolean retrieveFromCache) {
2813                    boolean pagination = true;
2814                    FinderPath finderPath = null;
2815                    Object[] finderArgs = null;
2816    
2817                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2818                                    (orderByComparator == null)) {
2819                            pagination = false;
2820                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2821                            finderArgs = FINDER_ARGS_EMPTY;
2822                    }
2823                    else {
2824                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2825                            finderArgs = new Object[] { start, end, orderByComparator };
2826                    }
2827    
2828                    List<MembershipRequest> list = null;
2829    
2830                    if (retrieveFromCache) {
2831                            list = (List<MembershipRequest>)finderCache.getResult(finderPath,
2832                                            finderArgs, this);
2833                    }
2834    
2835                    if (list == null) {
2836                            StringBundler query = null;
2837                            String sql = null;
2838    
2839                            if (orderByComparator != null) {
2840                                    query = new StringBundler(2 +
2841                                                    (orderByComparator.getOrderByFields().length * 3));
2842    
2843                                    query.append(_SQL_SELECT_MEMBERSHIPREQUEST);
2844    
2845                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2846                                            orderByComparator);
2847    
2848                                    sql = query.toString();
2849                            }
2850                            else {
2851                                    sql = _SQL_SELECT_MEMBERSHIPREQUEST;
2852    
2853                                    if (pagination) {
2854                                            sql = sql.concat(MembershipRequestModelImpl.ORDER_BY_JPQL);
2855                                    }
2856                            }
2857    
2858                            Session session = null;
2859    
2860                            try {
2861                                    session = openSession();
2862    
2863                                    Query q = session.createQuery(sql);
2864    
2865                                    if (!pagination) {
2866                                            list = (List<MembershipRequest>)QueryUtil.list(q,
2867                                                            getDialect(), start, end, false);
2868    
2869                                            Collections.sort(list);
2870    
2871                                            list = Collections.unmodifiableList(list);
2872                                    }
2873                                    else {
2874                                            list = (List<MembershipRequest>)QueryUtil.list(q,
2875                                                            getDialect(), start, end);
2876                                    }
2877    
2878                                    cacheResult(list);
2879    
2880                                    finderCache.putResult(finderPath, finderArgs, list);
2881                            }
2882                            catch (Exception e) {
2883                                    finderCache.removeResult(finderPath, finderArgs);
2884    
2885                                    throw processException(e);
2886                            }
2887                            finally {
2888                                    closeSession(session);
2889                            }
2890                    }
2891    
2892                    return list;
2893            }
2894    
2895            /**
2896             * Removes all the membership requests from the database.
2897             *
2898             */
2899            @Override
2900            public void removeAll() {
2901                    for (MembershipRequest membershipRequest : findAll()) {
2902                            remove(membershipRequest);
2903                    }
2904            }
2905    
2906            /**
2907             * Returns the number of membership requests.
2908             *
2909             * @return the number of membership requests
2910             */
2911            @Override
2912            public int countAll() {
2913                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
2914                                    FINDER_ARGS_EMPTY, this);
2915    
2916                    if (count == null) {
2917                            Session session = null;
2918    
2919                            try {
2920                                    session = openSession();
2921    
2922                                    Query q = session.createQuery(_SQL_COUNT_MEMBERSHIPREQUEST);
2923    
2924                                    count = (Long)q.uniqueResult();
2925    
2926                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
2927                                            count);
2928                            }
2929                            catch (Exception e) {
2930                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
2931                                            FINDER_ARGS_EMPTY);
2932    
2933                                    throw processException(e);
2934                            }
2935                            finally {
2936                                    closeSession(session);
2937                            }
2938                    }
2939    
2940                    return count.intValue();
2941            }
2942    
2943            @Override
2944            protected Map<String, Integer> getTableColumnsMap() {
2945                    return MembershipRequestModelImpl.TABLE_COLUMNS_MAP;
2946            }
2947    
2948            /**
2949             * Initializes the membership request persistence.
2950             */
2951            public void afterPropertiesSet() {
2952            }
2953    
2954            public void destroy() {
2955                    entityCache.removeCache(MembershipRequestImpl.class.getName());
2956                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
2957                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2958                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2959            }
2960    
2961            @BeanReference(type = CompanyProvider.class)
2962            protected CompanyProvider companyProvider;
2963            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
2964            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
2965            private static final String _SQL_SELECT_MEMBERSHIPREQUEST = "SELECT membershipRequest FROM MembershipRequest membershipRequest";
2966            private static final String _SQL_SELECT_MEMBERSHIPREQUEST_WHERE_PKS_IN = "SELECT membershipRequest FROM MembershipRequest membershipRequest WHERE membershipRequestId IN (";
2967            private static final String _SQL_SELECT_MEMBERSHIPREQUEST_WHERE = "SELECT membershipRequest FROM MembershipRequest membershipRequest WHERE ";
2968            private static final String _SQL_COUNT_MEMBERSHIPREQUEST = "SELECT COUNT(membershipRequest) FROM MembershipRequest membershipRequest";
2969            private static final String _SQL_COUNT_MEMBERSHIPREQUEST_WHERE = "SELECT COUNT(membershipRequest) FROM MembershipRequest membershipRequest WHERE ";
2970            private static final String _ORDER_BY_ENTITY_ALIAS = "membershipRequest.";
2971            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MembershipRequest exists with the primary key ";
2972            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MembershipRequest exists with the key {";
2973            private static final Log _log = LogFactoryUtil.getLog(MembershipRequestPersistenceImpl.class);
2974            private static final MembershipRequest _nullMembershipRequest = new MembershipRequestImpl() {
2975                            @Override
2976                            public Object clone() {
2977                                    return this;
2978                            }
2979    
2980                            @Override
2981                            public CacheModel<MembershipRequest> toCacheModel() {
2982                                    return _nullMembershipRequestCacheModel;
2983                            }
2984                    };
2985    
2986            private static final CacheModel<MembershipRequest> _nullMembershipRequestCacheModel =
2987                    new NullCacheModel();
2988    
2989            private static class NullCacheModel implements CacheModel<MembershipRequest>,
2990                    MVCCModel {
2991                    @Override
2992                    public long getMvccVersion() {
2993                            return -1;
2994                    }
2995    
2996                    @Override
2997                    public void setMvccVersion(long mvccVersion) {
2998                    }
2999    
3000                    @Override
3001                    public MembershipRequest toEntityModel() {
3002                            return _nullMembershipRequest;
3003                    }
3004            }
3005    }