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