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