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