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