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