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