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