001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.social.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.Session;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.Validator;
035    import com.liferay.portal.model.CacheModel;
036    import com.liferay.portal.service.persistence.CompanyProvider;
037    import com.liferay.portal.service.persistence.CompanyProviderWrapper;
038    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
039    
040    import com.liferay.portlet.social.exception.NoSuchActivityAchievementException;
041    import com.liferay.portlet.social.model.SocialActivityAchievement;
042    import com.liferay.portlet.social.model.impl.SocialActivityAchievementImpl;
043    import com.liferay.portlet.social.model.impl.SocialActivityAchievementModelImpl;
044    import com.liferay.portlet.social.service.persistence.SocialActivityAchievementPersistence;
045    
046    import java.io.Serializable;
047    
048    import java.util.Collections;
049    import java.util.HashMap;
050    import java.util.HashSet;
051    import java.util.Iterator;
052    import java.util.List;
053    import java.util.Map;
054    import java.util.Set;
055    
056    /**
057     * The persistence implementation for the social activity achievement service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see SocialActivityAchievementPersistence
065     * @see com.liferay.portlet.social.service.persistence.SocialActivityAchievementUtil
066     * @generated
067     */
068    @ProviderType
069    public class SocialActivityAchievementPersistenceImpl
070            extends BasePersistenceImpl<SocialActivityAchievement>
071            implements SocialActivityAchievementPersistence {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link SocialActivityAchievementUtil} to access the social activity achievement persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
076             */
077            public static final String FINDER_CLASS_NAME_ENTITY = SocialActivityAchievementImpl.class.getName();
078            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List1";
080            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List2";
082            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
083                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
084                            SocialActivityAchievementImpl.class,
085                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
087                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
088                            SocialActivityAchievementImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
091                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
092                            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll",
093                            new String[0]);
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
095                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
096                            SocialActivityAchievementImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
098                            new String[] {
099                                    Long.class.getName(),
100                                    
101                            Integer.class.getName(), Integer.class.getName(),
102                                    OrderByComparator.class.getName()
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
105                    new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
106                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
107                            SocialActivityAchievementImpl.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
109                            new String[] { Long.class.getName() },
110                            SocialActivityAchievementModelImpl.GROUPID_COLUMN_BITMASK);
111            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
112                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
113                            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
114                            "countByGroupId", new String[] { Long.class.getName() });
115    
116            /**
117             * Returns all the social activity achievements where groupId = &#63;.
118             *
119             * @param groupId the group ID
120             * @return the matching social activity achievements
121             */
122            @Override
123            public List<SocialActivityAchievement> findByGroupId(long groupId) {
124                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
125            }
126    
127            /**
128             * Returns a range of all the social activity achievements where groupId = &#63;.
129             *
130             * <p>
131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
132             * </p>
133             *
134             * @param groupId the group ID
135             * @param start the lower bound of the range of social activity achievements
136             * @param end the upper bound of the range of social activity achievements (not inclusive)
137             * @return the range of matching social activity achievements
138             */
139            @Override
140            public List<SocialActivityAchievement> findByGroupId(long groupId,
141                    int start, int end) {
142                    return findByGroupId(groupId, start, end, null);
143            }
144    
145            /**
146             * Returns an ordered range of all the social activity achievements where groupId = &#63;.
147             *
148             * <p>
149             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
150             * </p>
151             *
152             * @param groupId the group ID
153             * @param start the lower bound of the range of social activity achievements
154             * @param end the upper bound of the range of social activity achievements (not inclusive)
155             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
156             * @return the ordered range of matching social activity achievements
157             */
158            @Override
159            public List<SocialActivityAchievement> findByGroupId(long groupId,
160                    int start, int end,
161                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
162                    return findByGroupId(groupId, start, end, orderByComparator, true);
163            }
164    
165            /**
166             * Returns an ordered range of all the social activity achievements where groupId = &#63;.
167             *
168             * <p>
169             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
170             * </p>
171             *
172             * @param groupId the group ID
173             * @param start the lower bound of the range of social activity achievements
174             * @param end the upper bound of the range of social activity achievements (not inclusive)
175             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
176             * @param retrieveFromCache whether to retrieve from the finder cache
177             * @return the ordered range of matching social activity achievements
178             */
179            @Override
180            public List<SocialActivityAchievement> findByGroupId(long groupId,
181                    int start, int end,
182                    OrderByComparator<SocialActivityAchievement> orderByComparator,
183                    boolean retrieveFromCache) {
184                    boolean pagination = true;
185                    FinderPath finderPath = null;
186                    Object[] finderArgs = null;
187    
188                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
189                                    (orderByComparator == null)) {
190                            pagination = false;
191                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
192                            finderArgs = new Object[] { groupId };
193                    }
194                    else {
195                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
196                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
197                    }
198    
199                    List<SocialActivityAchievement> list = null;
200    
201                    if (retrieveFromCache) {
202                            list = (List<SocialActivityAchievement>)finderCache.getResult(finderPath,
203                                            finderArgs, this);
204    
205                            if ((list != null) && !list.isEmpty()) {
206                                    for (SocialActivityAchievement socialActivityAchievement : list) {
207                                            if ((groupId != socialActivityAchievement.getGroupId())) {
208                                                    list = null;
209    
210                                                    break;
211                                            }
212                                    }
213                            }
214                    }
215    
216                    if (list == null) {
217                            StringBundler query = null;
218    
219                            if (orderByComparator != null) {
220                                    query = new StringBundler(3 +
221                                                    (orderByComparator.getOrderByFields().length * 2));
222                            }
223                            else {
224                                    query = new StringBundler(3);
225                            }
226    
227                            query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
228    
229                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
230    
231                            if (orderByComparator != null) {
232                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
233                                            orderByComparator);
234                            }
235                            else
236                             if (pagination) {
237                                    query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
238                            }
239    
240                            String sql = query.toString();
241    
242                            Session session = null;
243    
244                            try {
245                                    session = openSession();
246    
247                                    Query q = session.createQuery(sql);
248    
249                                    QueryPos qPos = QueryPos.getInstance(q);
250    
251                                    qPos.add(groupId);
252    
253                                    if (!pagination) {
254                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
255                                                            getDialect(), start, end, false);
256    
257                                            Collections.sort(list);
258    
259                                            list = Collections.unmodifiableList(list);
260                                    }
261                                    else {
262                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
263                                                            getDialect(), start, end);
264                                    }
265    
266                                    cacheResult(list);
267    
268                                    finderCache.putResult(finderPath, finderArgs, list);
269                            }
270                            catch (Exception e) {
271                                    finderCache.removeResult(finderPath, finderArgs);
272    
273                                    throw processException(e);
274                            }
275                            finally {
276                                    closeSession(session);
277                            }
278                    }
279    
280                    return list;
281            }
282    
283            /**
284             * Returns the first social activity achievement in the ordered set where groupId = &#63;.
285             *
286             * @param groupId the group ID
287             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
288             * @return the first matching social activity achievement
289             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
290             */
291            @Override
292            public SocialActivityAchievement findByGroupId_First(long groupId,
293                    OrderByComparator<SocialActivityAchievement> orderByComparator)
294                    throws NoSuchActivityAchievementException {
295                    SocialActivityAchievement socialActivityAchievement = fetchByGroupId_First(groupId,
296                                    orderByComparator);
297    
298                    if (socialActivityAchievement != null) {
299                            return socialActivityAchievement;
300                    }
301    
302                    StringBundler msg = new StringBundler(4);
303    
304                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
305    
306                    msg.append("groupId=");
307                    msg.append(groupId);
308    
309                    msg.append(StringPool.CLOSE_CURLY_BRACE);
310    
311                    throw new NoSuchActivityAchievementException(msg.toString());
312            }
313    
314            /**
315             * Returns the first social activity achievement in the ordered set where groupId = &#63;.
316             *
317             * @param groupId the group ID
318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
319             * @return the first matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
320             */
321            @Override
322            public SocialActivityAchievement fetchByGroupId_First(long groupId,
323                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
324                    List<SocialActivityAchievement> list = findByGroupId(groupId, 0, 1,
325                                    orderByComparator);
326    
327                    if (!list.isEmpty()) {
328                            return list.get(0);
329                    }
330    
331                    return null;
332            }
333    
334            /**
335             * Returns the last social activity achievement in the ordered set where groupId = &#63;.
336             *
337             * @param groupId the group ID
338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
339             * @return the last matching social activity achievement
340             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
341             */
342            @Override
343            public SocialActivityAchievement findByGroupId_Last(long groupId,
344                    OrderByComparator<SocialActivityAchievement> orderByComparator)
345                    throws NoSuchActivityAchievementException {
346                    SocialActivityAchievement socialActivityAchievement = fetchByGroupId_Last(groupId,
347                                    orderByComparator);
348    
349                    if (socialActivityAchievement != null) {
350                            return socialActivityAchievement;
351                    }
352    
353                    StringBundler msg = new StringBundler(4);
354    
355                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
356    
357                    msg.append("groupId=");
358                    msg.append(groupId);
359    
360                    msg.append(StringPool.CLOSE_CURLY_BRACE);
361    
362                    throw new NoSuchActivityAchievementException(msg.toString());
363            }
364    
365            /**
366             * Returns the last social activity achievement in the ordered set where groupId = &#63;.
367             *
368             * @param groupId the group ID
369             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
370             * @return the last matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
371             */
372            @Override
373            public SocialActivityAchievement fetchByGroupId_Last(long groupId,
374                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
375                    int count = countByGroupId(groupId);
376    
377                    if (count == 0) {
378                            return null;
379                    }
380    
381                    List<SocialActivityAchievement> list = findByGroupId(groupId,
382                                    count - 1, count, orderByComparator);
383    
384                    if (!list.isEmpty()) {
385                            return list.get(0);
386                    }
387    
388                    return null;
389            }
390    
391            /**
392             * Returns the social activity achievements before and after the current social activity achievement in the ordered set where groupId = &#63;.
393             *
394             * @param activityAchievementId the primary key of the current social activity achievement
395             * @param groupId the group ID
396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
397             * @return the previous, current, and next social activity achievement
398             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
399             */
400            @Override
401            public SocialActivityAchievement[] findByGroupId_PrevAndNext(
402                    long activityAchievementId, long groupId,
403                    OrderByComparator<SocialActivityAchievement> orderByComparator)
404                    throws NoSuchActivityAchievementException {
405                    SocialActivityAchievement socialActivityAchievement = findByPrimaryKey(activityAchievementId);
406    
407                    Session session = null;
408    
409                    try {
410                            session = openSession();
411    
412                            SocialActivityAchievement[] array = new SocialActivityAchievementImpl[3];
413    
414                            array[0] = getByGroupId_PrevAndNext(session,
415                                            socialActivityAchievement, groupId, orderByComparator, true);
416    
417                            array[1] = socialActivityAchievement;
418    
419                            array[2] = getByGroupId_PrevAndNext(session,
420                                            socialActivityAchievement, groupId, orderByComparator, false);
421    
422                            return array;
423                    }
424                    catch (Exception e) {
425                            throw processException(e);
426                    }
427                    finally {
428                            closeSession(session);
429                    }
430            }
431    
432            protected SocialActivityAchievement getByGroupId_PrevAndNext(
433                    Session session, SocialActivityAchievement socialActivityAchievement,
434                    long groupId,
435                    OrderByComparator<SocialActivityAchievement> orderByComparator,
436                    boolean previous) {
437                    StringBundler query = null;
438    
439                    if (orderByComparator != null) {
440                            query = new StringBundler(4 +
441                                            (orderByComparator.getOrderByConditionFields().length * 3) +
442                                            (orderByComparator.getOrderByFields().length * 3));
443                    }
444                    else {
445                            query = new StringBundler(3);
446                    }
447    
448                    query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
449    
450                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
451    
452                    if (orderByComparator != null) {
453                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
454    
455                            if (orderByConditionFields.length > 0) {
456                                    query.append(WHERE_AND);
457                            }
458    
459                            for (int i = 0; i < orderByConditionFields.length; i++) {
460                                    query.append(_ORDER_BY_ENTITY_ALIAS);
461                                    query.append(orderByConditionFields[i]);
462    
463                                    if ((i + 1) < orderByConditionFields.length) {
464                                            if (orderByComparator.isAscending() ^ previous) {
465                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
466                                            }
467                                            else {
468                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
469                                            }
470                                    }
471                                    else {
472                                            if (orderByComparator.isAscending() ^ previous) {
473                                                    query.append(WHERE_GREATER_THAN);
474                                            }
475                                            else {
476                                                    query.append(WHERE_LESSER_THAN);
477                                            }
478                                    }
479                            }
480    
481                            query.append(ORDER_BY_CLAUSE);
482    
483                            String[] orderByFields = orderByComparator.getOrderByFields();
484    
485                            for (int i = 0; i < orderByFields.length; i++) {
486                                    query.append(_ORDER_BY_ENTITY_ALIAS);
487                                    query.append(orderByFields[i]);
488    
489                                    if ((i + 1) < orderByFields.length) {
490                                            if (orderByComparator.isAscending() ^ previous) {
491                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
492                                            }
493                                            else {
494                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
495                                            }
496                                    }
497                                    else {
498                                            if (orderByComparator.isAscending() ^ previous) {
499                                                    query.append(ORDER_BY_ASC);
500                                            }
501                                            else {
502                                                    query.append(ORDER_BY_DESC);
503                                            }
504                                    }
505                            }
506                    }
507                    else {
508                            query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
509                    }
510    
511                    String sql = query.toString();
512    
513                    Query q = session.createQuery(sql);
514    
515                    q.setFirstResult(0);
516                    q.setMaxResults(2);
517    
518                    QueryPos qPos = QueryPos.getInstance(q);
519    
520                    qPos.add(groupId);
521    
522                    if (orderByComparator != null) {
523                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivityAchievement);
524    
525                            for (Object value : values) {
526                                    qPos.add(value);
527                            }
528                    }
529    
530                    List<SocialActivityAchievement> list = q.list();
531    
532                    if (list.size() == 2) {
533                            return list.get(1);
534                    }
535                    else {
536                            return null;
537                    }
538            }
539    
540            /**
541             * Removes all the social activity achievements where groupId = &#63; from the database.
542             *
543             * @param groupId the group ID
544             */
545            @Override
546            public void removeByGroupId(long groupId) {
547                    for (SocialActivityAchievement socialActivityAchievement : findByGroupId(
548                                    groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
549                            remove(socialActivityAchievement);
550                    }
551            }
552    
553            /**
554             * Returns the number of social activity achievements where groupId = &#63;.
555             *
556             * @param groupId the group ID
557             * @return the number of matching social activity achievements
558             */
559            @Override
560            public int countByGroupId(long groupId) {
561                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
562    
563                    Object[] finderArgs = new Object[] { groupId };
564    
565                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
566    
567                    if (count == null) {
568                            StringBundler query = new StringBundler(2);
569    
570                            query.append(_SQL_COUNT_SOCIALACTIVITYACHIEVEMENT_WHERE);
571    
572                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
573    
574                            String sql = query.toString();
575    
576                            Session session = null;
577    
578                            try {
579                                    session = openSession();
580    
581                                    Query q = session.createQuery(sql);
582    
583                                    QueryPos qPos = QueryPos.getInstance(q);
584    
585                                    qPos.add(groupId);
586    
587                                    count = (Long)q.uniqueResult();
588    
589                                    finderCache.putResult(finderPath, finderArgs, count);
590                            }
591                            catch (Exception e) {
592                                    finderCache.removeResult(finderPath, finderArgs);
593    
594                                    throw processException(e);
595                            }
596                            finally {
597                                    closeSession(session);
598                            }
599                    }
600    
601                    return count.intValue();
602            }
603    
604            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "socialActivityAchievement.groupId = ?";
605            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
606                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
607                            SocialActivityAchievementImpl.class,
608                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U",
609                            new String[] {
610                                    Long.class.getName(), Long.class.getName(),
611                                    
612                            Integer.class.getName(), Integer.class.getName(),
613                                    OrderByComparator.class.getName()
614                            });
615            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
616                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
617                            SocialActivityAchievementImpl.class,
618                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
619                            new String[] { Long.class.getName(), Long.class.getName() },
620                            SocialActivityAchievementModelImpl.GROUPID_COLUMN_BITMASK |
621                            SocialActivityAchievementModelImpl.USERID_COLUMN_BITMASK);
622            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
623                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
624                            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
625                            "countByG_U",
626                            new String[] { Long.class.getName(), Long.class.getName() });
627    
628            /**
629             * Returns all the social activity achievements where groupId = &#63; and userId = &#63;.
630             *
631             * @param groupId the group ID
632             * @param userId the user ID
633             * @return the matching social activity achievements
634             */
635            @Override
636            public List<SocialActivityAchievement> findByG_U(long groupId, long userId) {
637                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
638                            null);
639            }
640    
641            /**
642             * Returns a range of all the social activity achievements where groupId = &#63; and userId = &#63;.
643             *
644             * <p>
645             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
646             * </p>
647             *
648             * @param groupId the group ID
649             * @param userId the user ID
650             * @param start the lower bound of the range of social activity achievements
651             * @param end the upper bound of the range of social activity achievements (not inclusive)
652             * @return the range of matching social activity achievements
653             */
654            @Override
655            public List<SocialActivityAchievement> findByG_U(long groupId, long userId,
656                    int start, int end) {
657                    return findByG_U(groupId, userId, start, end, null);
658            }
659    
660            /**
661             * Returns an ordered range of all the social activity achievements where groupId = &#63; and userId = &#63;.
662             *
663             * <p>
664             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
665             * </p>
666             *
667             * @param groupId the group ID
668             * @param userId the user ID
669             * @param start the lower bound of the range of social activity achievements
670             * @param end the upper bound of the range of social activity achievements (not inclusive)
671             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
672             * @return the ordered range of matching social activity achievements
673             */
674            @Override
675            public List<SocialActivityAchievement> findByG_U(long groupId, long userId,
676                    int start, int end,
677                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
678                    return findByG_U(groupId, userId, start, end, orderByComparator, true);
679            }
680    
681            /**
682             * Returns an ordered range of all the social activity achievements where groupId = &#63; and userId = &#63;.
683             *
684             * <p>
685             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
686             * </p>
687             *
688             * @param groupId the group ID
689             * @param userId the user ID
690             * @param start the lower bound of the range of social activity achievements
691             * @param end the upper bound of the range of social activity achievements (not inclusive)
692             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
693             * @param retrieveFromCache whether to retrieve from the finder cache
694             * @return the ordered range of matching social activity achievements
695             */
696            @Override
697            public List<SocialActivityAchievement> findByG_U(long groupId, long userId,
698                    int start, int end,
699                    OrderByComparator<SocialActivityAchievement> orderByComparator,
700                    boolean retrieveFromCache) {
701                    boolean pagination = true;
702                    FinderPath finderPath = null;
703                    Object[] finderArgs = null;
704    
705                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
706                                    (orderByComparator == null)) {
707                            pagination = false;
708                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
709                            finderArgs = new Object[] { groupId, userId };
710                    }
711                    else {
712                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
713                            finderArgs = new Object[] {
714                                            groupId, userId,
715                                            
716                                            start, end, orderByComparator
717                                    };
718                    }
719    
720                    List<SocialActivityAchievement> list = null;
721    
722                    if (retrieveFromCache) {
723                            list = (List<SocialActivityAchievement>)finderCache.getResult(finderPath,
724                                            finderArgs, this);
725    
726                            if ((list != null) && !list.isEmpty()) {
727                                    for (SocialActivityAchievement socialActivityAchievement : list) {
728                                            if ((groupId != socialActivityAchievement.getGroupId()) ||
729                                                            (userId != socialActivityAchievement.getUserId())) {
730                                                    list = null;
731    
732                                                    break;
733                                            }
734                                    }
735                            }
736                    }
737    
738                    if (list == null) {
739                            StringBundler query = null;
740    
741                            if (orderByComparator != null) {
742                                    query = new StringBundler(4 +
743                                                    (orderByComparator.getOrderByFields().length * 2));
744                            }
745                            else {
746                                    query = new StringBundler(4);
747                            }
748    
749                            query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
750    
751                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
752    
753                            query.append(_FINDER_COLUMN_G_U_USERID_2);
754    
755                            if (orderByComparator != null) {
756                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
757                                            orderByComparator);
758                            }
759                            else
760                             if (pagination) {
761                                    query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
762                            }
763    
764                            String sql = query.toString();
765    
766                            Session session = null;
767    
768                            try {
769                                    session = openSession();
770    
771                                    Query q = session.createQuery(sql);
772    
773                                    QueryPos qPos = QueryPos.getInstance(q);
774    
775                                    qPos.add(groupId);
776    
777                                    qPos.add(userId);
778    
779                                    if (!pagination) {
780                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
781                                                            getDialect(), start, end, false);
782    
783                                            Collections.sort(list);
784    
785                                            list = Collections.unmodifiableList(list);
786                                    }
787                                    else {
788                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
789                                                            getDialect(), start, end);
790                                    }
791    
792                                    cacheResult(list);
793    
794                                    finderCache.putResult(finderPath, finderArgs, list);
795                            }
796                            catch (Exception e) {
797                                    finderCache.removeResult(finderPath, finderArgs);
798    
799                                    throw processException(e);
800                            }
801                            finally {
802                                    closeSession(session);
803                            }
804                    }
805    
806                    return list;
807            }
808    
809            /**
810             * Returns the first social activity achievement in the ordered set where groupId = &#63; and userId = &#63;.
811             *
812             * @param groupId the group ID
813             * @param userId the user ID
814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
815             * @return the first matching social activity achievement
816             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
817             */
818            @Override
819            public SocialActivityAchievement findByG_U_First(long groupId, long userId,
820                    OrderByComparator<SocialActivityAchievement> orderByComparator)
821                    throws NoSuchActivityAchievementException {
822                    SocialActivityAchievement socialActivityAchievement = fetchByG_U_First(groupId,
823                                    userId, orderByComparator);
824    
825                    if (socialActivityAchievement != null) {
826                            return socialActivityAchievement;
827                    }
828    
829                    StringBundler msg = new StringBundler(6);
830    
831                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
832    
833                    msg.append("groupId=");
834                    msg.append(groupId);
835    
836                    msg.append(", userId=");
837                    msg.append(userId);
838    
839                    msg.append(StringPool.CLOSE_CURLY_BRACE);
840    
841                    throw new NoSuchActivityAchievementException(msg.toString());
842            }
843    
844            /**
845             * Returns the first social activity achievement in the ordered set where groupId = &#63; and userId = &#63;.
846             *
847             * @param groupId the group ID
848             * @param userId the user ID
849             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
850             * @return the first matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
851             */
852            @Override
853            public SocialActivityAchievement fetchByG_U_First(long groupId,
854                    long userId,
855                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
856                    List<SocialActivityAchievement> list = findByG_U(groupId, userId, 0, 1,
857                                    orderByComparator);
858    
859                    if (!list.isEmpty()) {
860                            return list.get(0);
861                    }
862    
863                    return null;
864            }
865    
866            /**
867             * Returns the last social activity achievement in the ordered set where groupId = &#63; and userId = &#63;.
868             *
869             * @param groupId the group ID
870             * @param userId the user ID
871             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
872             * @return the last matching social activity achievement
873             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
874             */
875            @Override
876            public SocialActivityAchievement findByG_U_Last(long groupId, long userId,
877                    OrderByComparator<SocialActivityAchievement> orderByComparator)
878                    throws NoSuchActivityAchievementException {
879                    SocialActivityAchievement socialActivityAchievement = fetchByG_U_Last(groupId,
880                                    userId, orderByComparator);
881    
882                    if (socialActivityAchievement != null) {
883                            return socialActivityAchievement;
884                    }
885    
886                    StringBundler msg = new StringBundler(6);
887    
888                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
889    
890                    msg.append("groupId=");
891                    msg.append(groupId);
892    
893                    msg.append(", userId=");
894                    msg.append(userId);
895    
896                    msg.append(StringPool.CLOSE_CURLY_BRACE);
897    
898                    throw new NoSuchActivityAchievementException(msg.toString());
899            }
900    
901            /**
902             * Returns the last social activity achievement in the ordered set where groupId = &#63; and userId = &#63;.
903             *
904             * @param groupId the group ID
905             * @param userId the user ID
906             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
907             * @return the last matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
908             */
909            @Override
910            public SocialActivityAchievement fetchByG_U_Last(long groupId, long userId,
911                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
912                    int count = countByG_U(groupId, userId);
913    
914                    if (count == 0) {
915                            return null;
916                    }
917    
918                    List<SocialActivityAchievement> list = findByG_U(groupId, userId,
919                                    count - 1, count, orderByComparator);
920    
921                    if (!list.isEmpty()) {
922                            return list.get(0);
923                    }
924    
925                    return null;
926            }
927    
928            /**
929             * Returns the social activity achievements before and after the current social activity achievement in the ordered set where groupId = &#63; and userId = &#63;.
930             *
931             * @param activityAchievementId the primary key of the current social activity achievement
932             * @param groupId the group ID
933             * @param userId the user ID
934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
935             * @return the previous, current, and next social activity achievement
936             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
937             */
938            @Override
939            public SocialActivityAchievement[] findByG_U_PrevAndNext(
940                    long activityAchievementId, long groupId, long userId,
941                    OrderByComparator<SocialActivityAchievement> orderByComparator)
942                    throws NoSuchActivityAchievementException {
943                    SocialActivityAchievement socialActivityAchievement = findByPrimaryKey(activityAchievementId);
944    
945                    Session session = null;
946    
947                    try {
948                            session = openSession();
949    
950                            SocialActivityAchievement[] array = new SocialActivityAchievementImpl[3];
951    
952                            array[0] = getByG_U_PrevAndNext(session, socialActivityAchievement,
953                                            groupId, userId, orderByComparator, true);
954    
955                            array[1] = socialActivityAchievement;
956    
957                            array[2] = getByG_U_PrevAndNext(session, socialActivityAchievement,
958                                            groupId, userId, orderByComparator, false);
959    
960                            return array;
961                    }
962                    catch (Exception e) {
963                            throw processException(e);
964                    }
965                    finally {
966                            closeSession(session);
967                    }
968            }
969    
970            protected SocialActivityAchievement getByG_U_PrevAndNext(Session session,
971                    SocialActivityAchievement socialActivityAchievement, long groupId,
972                    long userId,
973                    OrderByComparator<SocialActivityAchievement> orderByComparator,
974                    boolean previous) {
975                    StringBundler query = null;
976    
977                    if (orderByComparator != null) {
978                            query = new StringBundler(5 +
979                                            (orderByComparator.getOrderByConditionFields().length * 3) +
980                                            (orderByComparator.getOrderByFields().length * 3));
981                    }
982                    else {
983                            query = new StringBundler(4);
984                    }
985    
986                    query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
987    
988                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
989    
990                    query.append(_FINDER_COLUMN_G_U_USERID_2);
991    
992                    if (orderByComparator != null) {
993                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
994    
995                            if (orderByConditionFields.length > 0) {
996                                    query.append(WHERE_AND);
997                            }
998    
999                            for (int i = 0; i < orderByConditionFields.length; i++) {
1000                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1001                                    query.append(orderByConditionFields[i]);
1002    
1003                                    if ((i + 1) < orderByConditionFields.length) {
1004                                            if (orderByComparator.isAscending() ^ previous) {
1005                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1006                                            }
1007                                            else {
1008                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1009                                            }
1010                                    }
1011                                    else {
1012                                            if (orderByComparator.isAscending() ^ previous) {
1013                                                    query.append(WHERE_GREATER_THAN);
1014                                            }
1015                                            else {
1016                                                    query.append(WHERE_LESSER_THAN);
1017                                            }
1018                                    }
1019                            }
1020    
1021                            query.append(ORDER_BY_CLAUSE);
1022    
1023                            String[] orderByFields = orderByComparator.getOrderByFields();
1024    
1025                            for (int i = 0; i < orderByFields.length; i++) {
1026                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1027                                    query.append(orderByFields[i]);
1028    
1029                                    if ((i + 1) < orderByFields.length) {
1030                                            if (orderByComparator.isAscending() ^ previous) {
1031                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1032                                            }
1033                                            else {
1034                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1035                                            }
1036                                    }
1037                                    else {
1038                                            if (orderByComparator.isAscending() ^ previous) {
1039                                                    query.append(ORDER_BY_ASC);
1040                                            }
1041                                            else {
1042                                                    query.append(ORDER_BY_DESC);
1043                                            }
1044                                    }
1045                            }
1046                    }
1047                    else {
1048                            query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
1049                    }
1050    
1051                    String sql = query.toString();
1052    
1053                    Query q = session.createQuery(sql);
1054    
1055                    q.setFirstResult(0);
1056                    q.setMaxResults(2);
1057    
1058                    QueryPos qPos = QueryPos.getInstance(q);
1059    
1060                    qPos.add(groupId);
1061    
1062                    qPos.add(userId);
1063    
1064                    if (orderByComparator != null) {
1065                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivityAchievement);
1066    
1067                            for (Object value : values) {
1068                                    qPos.add(value);
1069                            }
1070                    }
1071    
1072                    List<SocialActivityAchievement> list = q.list();
1073    
1074                    if (list.size() == 2) {
1075                            return list.get(1);
1076                    }
1077                    else {
1078                            return null;
1079                    }
1080            }
1081    
1082            /**
1083             * Removes all the social activity achievements where groupId = &#63; and userId = &#63; from the database.
1084             *
1085             * @param groupId the group ID
1086             * @param userId the user ID
1087             */
1088            @Override
1089            public void removeByG_U(long groupId, long userId) {
1090                    for (SocialActivityAchievement socialActivityAchievement : findByG_U(
1091                                    groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1092                            remove(socialActivityAchievement);
1093                    }
1094            }
1095    
1096            /**
1097             * Returns the number of social activity achievements where groupId = &#63; and userId = &#63;.
1098             *
1099             * @param groupId the group ID
1100             * @param userId the user ID
1101             * @return the number of matching social activity achievements
1102             */
1103            @Override
1104            public int countByG_U(long groupId, long userId) {
1105                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
1106    
1107                    Object[] finderArgs = new Object[] { groupId, userId };
1108    
1109                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1110    
1111                    if (count == null) {
1112                            StringBundler query = new StringBundler(3);
1113    
1114                            query.append(_SQL_COUNT_SOCIALACTIVITYACHIEVEMENT_WHERE);
1115    
1116                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1117    
1118                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1119    
1120                            String sql = query.toString();
1121    
1122                            Session session = null;
1123    
1124                            try {
1125                                    session = openSession();
1126    
1127                                    Query q = session.createQuery(sql);
1128    
1129                                    QueryPos qPos = QueryPos.getInstance(q);
1130    
1131                                    qPos.add(groupId);
1132    
1133                                    qPos.add(userId);
1134    
1135                                    count = (Long)q.uniqueResult();
1136    
1137                                    finderCache.putResult(finderPath, finderArgs, count);
1138                            }
1139                            catch (Exception e) {
1140                                    finderCache.removeResult(finderPath, finderArgs);
1141    
1142                                    throw processException(e);
1143                            }
1144                            finally {
1145                                    closeSession(session);
1146                            }
1147                    }
1148    
1149                    return count.intValue();
1150            }
1151    
1152            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "socialActivityAchievement.groupId = ? AND ";
1153            private static final String _FINDER_COLUMN_G_U_USERID_2 = "socialActivityAchievement.userId = ?";
1154            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
1155                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
1156                            SocialActivityAchievementImpl.class,
1157                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N",
1158                            new String[] {
1159                                    Long.class.getName(), String.class.getName(),
1160                                    
1161                            Integer.class.getName(), Integer.class.getName(),
1162                                    OrderByComparator.class.getName()
1163                            });
1164            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
1165                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
1166                            SocialActivityAchievementImpl.class,
1167                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N",
1168                            new String[] { Long.class.getName(), String.class.getName() },
1169                            SocialActivityAchievementModelImpl.GROUPID_COLUMN_BITMASK |
1170                            SocialActivityAchievementModelImpl.NAME_COLUMN_BITMASK);
1171            public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
1172                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
1173                            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1174                            "countByG_N",
1175                            new String[] { Long.class.getName(), String.class.getName() });
1176    
1177            /**
1178             * Returns all the social activity achievements where groupId = &#63; and name = &#63;.
1179             *
1180             * @param groupId the group ID
1181             * @param name the name
1182             * @return the matching social activity achievements
1183             */
1184            @Override
1185            public List<SocialActivityAchievement> findByG_N(long groupId, String name) {
1186                    return findByG_N(groupId, name, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1187                            null);
1188            }
1189    
1190            /**
1191             * Returns a range of all the social activity achievements where groupId = &#63; and name = &#63;.
1192             *
1193             * <p>
1194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1195             * </p>
1196             *
1197             * @param groupId the group ID
1198             * @param name the name
1199             * @param start the lower bound of the range of social activity achievements
1200             * @param end the upper bound of the range of social activity achievements (not inclusive)
1201             * @return the range of matching social activity achievements
1202             */
1203            @Override
1204            public List<SocialActivityAchievement> findByG_N(long groupId, String name,
1205                    int start, int end) {
1206                    return findByG_N(groupId, name, start, end, null);
1207            }
1208    
1209            /**
1210             * Returns an ordered range of all the social activity achievements where groupId = &#63; and name = &#63;.
1211             *
1212             * <p>
1213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1214             * </p>
1215             *
1216             * @param groupId the group ID
1217             * @param name the name
1218             * @param start the lower bound of the range of social activity achievements
1219             * @param end the upper bound of the range of social activity achievements (not inclusive)
1220             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1221             * @return the ordered range of matching social activity achievements
1222             */
1223            @Override
1224            public List<SocialActivityAchievement> findByG_N(long groupId, String name,
1225                    int start, int end,
1226                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
1227                    return findByG_N(groupId, name, start, end, orderByComparator, true);
1228            }
1229    
1230            /**
1231             * Returns an ordered range of all the social activity achievements where groupId = &#63; and name = &#63;.
1232             *
1233             * <p>
1234             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1235             * </p>
1236             *
1237             * @param groupId the group ID
1238             * @param name the name
1239             * @param start the lower bound of the range of social activity achievements
1240             * @param end the upper bound of the range of social activity achievements (not inclusive)
1241             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1242             * @param retrieveFromCache whether to retrieve from the finder cache
1243             * @return the ordered range of matching social activity achievements
1244             */
1245            @Override
1246            public List<SocialActivityAchievement> findByG_N(long groupId, String name,
1247                    int start, int end,
1248                    OrderByComparator<SocialActivityAchievement> orderByComparator,
1249                    boolean retrieveFromCache) {
1250                    boolean pagination = true;
1251                    FinderPath finderPath = null;
1252                    Object[] finderArgs = null;
1253    
1254                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1255                                    (orderByComparator == null)) {
1256                            pagination = false;
1257                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N;
1258                            finderArgs = new Object[] { groupId, name };
1259                    }
1260                    else {
1261                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N;
1262                            finderArgs = new Object[] {
1263                                            groupId, name,
1264                                            
1265                                            start, end, orderByComparator
1266                                    };
1267                    }
1268    
1269                    List<SocialActivityAchievement> list = null;
1270    
1271                    if (retrieveFromCache) {
1272                            list = (List<SocialActivityAchievement>)finderCache.getResult(finderPath,
1273                                            finderArgs, this);
1274    
1275                            if ((list != null) && !list.isEmpty()) {
1276                                    for (SocialActivityAchievement socialActivityAchievement : list) {
1277                                            if ((groupId != socialActivityAchievement.getGroupId()) ||
1278                                                            !Validator.equals(name,
1279                                                                    socialActivityAchievement.getName())) {
1280                                                    list = null;
1281    
1282                                                    break;
1283                                            }
1284                                    }
1285                            }
1286                    }
1287    
1288                    if (list == null) {
1289                            StringBundler query = null;
1290    
1291                            if (orderByComparator != null) {
1292                                    query = new StringBundler(4 +
1293                                                    (orderByComparator.getOrderByFields().length * 2));
1294                            }
1295                            else {
1296                                    query = new StringBundler(4);
1297                            }
1298    
1299                            query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
1300    
1301                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1302    
1303                            boolean bindName = false;
1304    
1305                            if (name == null) {
1306                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
1307                            }
1308                            else if (name.equals(StringPool.BLANK)) {
1309                                    query.append(_FINDER_COLUMN_G_N_NAME_3);
1310                            }
1311                            else {
1312                                    bindName = true;
1313    
1314                                    query.append(_FINDER_COLUMN_G_N_NAME_2);
1315                            }
1316    
1317                            if (orderByComparator != null) {
1318                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1319                                            orderByComparator);
1320                            }
1321                            else
1322                             if (pagination) {
1323                                    query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
1324                            }
1325    
1326                            String sql = query.toString();
1327    
1328                            Session session = null;
1329    
1330                            try {
1331                                    session = openSession();
1332    
1333                                    Query q = session.createQuery(sql);
1334    
1335                                    QueryPos qPos = QueryPos.getInstance(q);
1336    
1337                                    qPos.add(groupId);
1338    
1339                                    if (bindName) {
1340                                            qPos.add(name);
1341                                    }
1342    
1343                                    if (!pagination) {
1344                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
1345                                                            getDialect(), start, end, false);
1346    
1347                                            Collections.sort(list);
1348    
1349                                            list = Collections.unmodifiableList(list);
1350                                    }
1351                                    else {
1352                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
1353                                                            getDialect(), start, end);
1354                                    }
1355    
1356                                    cacheResult(list);
1357    
1358                                    finderCache.putResult(finderPath, finderArgs, list);
1359                            }
1360                            catch (Exception e) {
1361                                    finderCache.removeResult(finderPath, finderArgs);
1362    
1363                                    throw processException(e);
1364                            }
1365                            finally {
1366                                    closeSession(session);
1367                            }
1368                    }
1369    
1370                    return list;
1371            }
1372    
1373            /**
1374             * Returns the first social activity achievement in the ordered set where groupId = &#63; and name = &#63;.
1375             *
1376             * @param groupId the group ID
1377             * @param name the name
1378             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1379             * @return the first matching social activity achievement
1380             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
1381             */
1382            @Override
1383            public SocialActivityAchievement findByG_N_First(long groupId, String name,
1384                    OrderByComparator<SocialActivityAchievement> orderByComparator)
1385                    throws NoSuchActivityAchievementException {
1386                    SocialActivityAchievement socialActivityAchievement = fetchByG_N_First(groupId,
1387                                    name, orderByComparator);
1388    
1389                    if (socialActivityAchievement != null) {
1390                            return socialActivityAchievement;
1391                    }
1392    
1393                    StringBundler msg = new StringBundler(6);
1394    
1395                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1396    
1397                    msg.append("groupId=");
1398                    msg.append(groupId);
1399    
1400                    msg.append(", name=");
1401                    msg.append(name);
1402    
1403                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1404    
1405                    throw new NoSuchActivityAchievementException(msg.toString());
1406            }
1407    
1408            /**
1409             * Returns the first social activity achievement in the ordered set where groupId = &#63; and name = &#63;.
1410             *
1411             * @param groupId the group ID
1412             * @param name the name
1413             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1414             * @return the first matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
1415             */
1416            @Override
1417            public SocialActivityAchievement fetchByG_N_First(long groupId,
1418                    String name,
1419                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
1420                    List<SocialActivityAchievement> list = findByG_N(groupId, name, 0, 1,
1421                                    orderByComparator);
1422    
1423                    if (!list.isEmpty()) {
1424                            return list.get(0);
1425                    }
1426    
1427                    return null;
1428            }
1429    
1430            /**
1431             * Returns the last social activity achievement in the ordered set where groupId = &#63; and name = &#63;.
1432             *
1433             * @param groupId the group ID
1434             * @param name the name
1435             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1436             * @return the last matching social activity achievement
1437             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
1438             */
1439            @Override
1440            public SocialActivityAchievement findByG_N_Last(long groupId, String name,
1441                    OrderByComparator<SocialActivityAchievement> orderByComparator)
1442                    throws NoSuchActivityAchievementException {
1443                    SocialActivityAchievement socialActivityAchievement = fetchByG_N_Last(groupId,
1444                                    name, orderByComparator);
1445    
1446                    if (socialActivityAchievement != null) {
1447                            return socialActivityAchievement;
1448                    }
1449    
1450                    StringBundler msg = new StringBundler(6);
1451    
1452                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1453    
1454                    msg.append("groupId=");
1455                    msg.append(groupId);
1456    
1457                    msg.append(", name=");
1458                    msg.append(name);
1459    
1460                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1461    
1462                    throw new NoSuchActivityAchievementException(msg.toString());
1463            }
1464    
1465            /**
1466             * Returns the last social activity achievement in the ordered set where groupId = &#63; and name = &#63;.
1467             *
1468             * @param groupId the group ID
1469             * @param name the name
1470             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1471             * @return the last matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
1472             */
1473            @Override
1474            public SocialActivityAchievement fetchByG_N_Last(long groupId, String name,
1475                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
1476                    int count = countByG_N(groupId, name);
1477    
1478                    if (count == 0) {
1479                            return null;
1480                    }
1481    
1482                    List<SocialActivityAchievement> list = findByG_N(groupId, name,
1483                                    count - 1, count, orderByComparator);
1484    
1485                    if (!list.isEmpty()) {
1486                            return list.get(0);
1487                    }
1488    
1489                    return null;
1490            }
1491    
1492            /**
1493             * Returns the social activity achievements before and after the current social activity achievement in the ordered set where groupId = &#63; and name = &#63;.
1494             *
1495             * @param activityAchievementId the primary key of the current social activity achievement
1496             * @param groupId the group ID
1497             * @param name the name
1498             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1499             * @return the previous, current, and next social activity achievement
1500             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
1501             */
1502            @Override
1503            public SocialActivityAchievement[] findByG_N_PrevAndNext(
1504                    long activityAchievementId, long groupId, String name,
1505                    OrderByComparator<SocialActivityAchievement> orderByComparator)
1506                    throws NoSuchActivityAchievementException {
1507                    SocialActivityAchievement socialActivityAchievement = findByPrimaryKey(activityAchievementId);
1508    
1509                    Session session = null;
1510    
1511                    try {
1512                            session = openSession();
1513    
1514                            SocialActivityAchievement[] array = new SocialActivityAchievementImpl[3];
1515    
1516                            array[0] = getByG_N_PrevAndNext(session, socialActivityAchievement,
1517                                            groupId, name, orderByComparator, true);
1518    
1519                            array[1] = socialActivityAchievement;
1520    
1521                            array[2] = getByG_N_PrevAndNext(session, socialActivityAchievement,
1522                                            groupId, name, orderByComparator, false);
1523    
1524                            return array;
1525                    }
1526                    catch (Exception e) {
1527                            throw processException(e);
1528                    }
1529                    finally {
1530                            closeSession(session);
1531                    }
1532            }
1533    
1534            protected SocialActivityAchievement getByG_N_PrevAndNext(Session session,
1535                    SocialActivityAchievement socialActivityAchievement, long groupId,
1536                    String name,
1537                    OrderByComparator<SocialActivityAchievement> orderByComparator,
1538                    boolean previous) {
1539                    StringBundler query = null;
1540    
1541                    if (orderByComparator != null) {
1542                            query = new StringBundler(5 +
1543                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1544                                            (orderByComparator.getOrderByFields().length * 3));
1545                    }
1546                    else {
1547                            query = new StringBundler(4);
1548                    }
1549    
1550                    query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
1551    
1552                    query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1553    
1554                    boolean bindName = false;
1555    
1556                    if (name == null) {
1557                            query.append(_FINDER_COLUMN_G_N_NAME_1);
1558                    }
1559                    else if (name.equals(StringPool.BLANK)) {
1560                            query.append(_FINDER_COLUMN_G_N_NAME_3);
1561                    }
1562                    else {
1563                            bindName = true;
1564    
1565                            query.append(_FINDER_COLUMN_G_N_NAME_2);
1566                    }
1567    
1568                    if (orderByComparator != null) {
1569                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1570    
1571                            if (orderByConditionFields.length > 0) {
1572                                    query.append(WHERE_AND);
1573                            }
1574    
1575                            for (int i = 0; i < orderByConditionFields.length; i++) {
1576                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1577                                    query.append(orderByConditionFields[i]);
1578    
1579                                    if ((i + 1) < orderByConditionFields.length) {
1580                                            if (orderByComparator.isAscending() ^ previous) {
1581                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1582                                            }
1583                                            else {
1584                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1585                                            }
1586                                    }
1587                                    else {
1588                                            if (orderByComparator.isAscending() ^ previous) {
1589                                                    query.append(WHERE_GREATER_THAN);
1590                                            }
1591                                            else {
1592                                                    query.append(WHERE_LESSER_THAN);
1593                                            }
1594                                    }
1595                            }
1596    
1597                            query.append(ORDER_BY_CLAUSE);
1598    
1599                            String[] orderByFields = orderByComparator.getOrderByFields();
1600    
1601                            for (int i = 0; i < orderByFields.length; i++) {
1602                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1603                                    query.append(orderByFields[i]);
1604    
1605                                    if ((i + 1) < orderByFields.length) {
1606                                            if (orderByComparator.isAscending() ^ previous) {
1607                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1608                                            }
1609                                            else {
1610                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1611                                            }
1612                                    }
1613                                    else {
1614                                            if (orderByComparator.isAscending() ^ previous) {
1615                                                    query.append(ORDER_BY_ASC);
1616                                            }
1617                                            else {
1618                                                    query.append(ORDER_BY_DESC);
1619                                            }
1620                                    }
1621                            }
1622                    }
1623                    else {
1624                            query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
1625                    }
1626    
1627                    String sql = query.toString();
1628    
1629                    Query q = session.createQuery(sql);
1630    
1631                    q.setFirstResult(0);
1632                    q.setMaxResults(2);
1633    
1634                    QueryPos qPos = QueryPos.getInstance(q);
1635    
1636                    qPos.add(groupId);
1637    
1638                    if (bindName) {
1639                            qPos.add(name);
1640                    }
1641    
1642                    if (orderByComparator != null) {
1643                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivityAchievement);
1644    
1645                            for (Object value : values) {
1646                                    qPos.add(value);
1647                            }
1648                    }
1649    
1650                    List<SocialActivityAchievement> list = q.list();
1651    
1652                    if (list.size() == 2) {
1653                            return list.get(1);
1654                    }
1655                    else {
1656                            return null;
1657                    }
1658            }
1659    
1660            /**
1661             * Removes all the social activity achievements where groupId = &#63; and name = &#63; from the database.
1662             *
1663             * @param groupId the group ID
1664             * @param name the name
1665             */
1666            @Override
1667            public void removeByG_N(long groupId, String name) {
1668                    for (SocialActivityAchievement socialActivityAchievement : findByG_N(
1669                                    groupId, name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1670                            remove(socialActivityAchievement);
1671                    }
1672            }
1673    
1674            /**
1675             * Returns the number of social activity achievements where groupId = &#63; and name = &#63;.
1676             *
1677             * @param groupId the group ID
1678             * @param name the name
1679             * @return the number of matching social activity achievements
1680             */
1681            @Override
1682            public int countByG_N(long groupId, String name) {
1683                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
1684    
1685                    Object[] finderArgs = new Object[] { groupId, name };
1686    
1687                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1688    
1689                    if (count == null) {
1690                            StringBundler query = new StringBundler(3);
1691    
1692                            query.append(_SQL_COUNT_SOCIALACTIVITYACHIEVEMENT_WHERE);
1693    
1694                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1695    
1696                            boolean bindName = false;
1697    
1698                            if (name == null) {
1699                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
1700                            }
1701                            else if (name.equals(StringPool.BLANK)) {
1702                                    query.append(_FINDER_COLUMN_G_N_NAME_3);
1703                            }
1704                            else {
1705                                    bindName = true;
1706    
1707                                    query.append(_FINDER_COLUMN_G_N_NAME_2);
1708                            }
1709    
1710                            String sql = query.toString();
1711    
1712                            Session session = null;
1713    
1714                            try {
1715                                    session = openSession();
1716    
1717                                    Query q = session.createQuery(sql);
1718    
1719                                    QueryPos qPos = QueryPos.getInstance(q);
1720    
1721                                    qPos.add(groupId);
1722    
1723                                    if (bindName) {
1724                                            qPos.add(name);
1725                                    }
1726    
1727                                    count = (Long)q.uniqueResult();
1728    
1729                                    finderCache.putResult(finderPath, finderArgs, count);
1730                            }
1731                            catch (Exception e) {
1732                                    finderCache.removeResult(finderPath, finderArgs);
1733    
1734                                    throw processException(e);
1735                            }
1736                            finally {
1737                                    closeSession(session);
1738                            }
1739                    }
1740    
1741                    return count.intValue();
1742            }
1743    
1744            private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "socialActivityAchievement.groupId = ? AND ";
1745            private static final String _FINDER_COLUMN_G_N_NAME_1 = "socialActivityAchievement.name IS NULL";
1746            private static final String _FINDER_COLUMN_G_N_NAME_2 = "socialActivityAchievement.name = ?";
1747            private static final String _FINDER_COLUMN_G_N_NAME_3 = "(socialActivityAchievement.name IS NULL OR socialActivityAchievement.name = '')";
1748            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
1749                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
1750                            SocialActivityAchievementImpl.class,
1751                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F",
1752                            new String[] {
1753                                    Long.class.getName(), Boolean.class.getName(),
1754                                    
1755                            Integer.class.getName(), Integer.class.getName(),
1756                                    OrderByComparator.class.getName()
1757                            });
1758            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
1759                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
1760                            SocialActivityAchievementImpl.class,
1761                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
1762                            new String[] { Long.class.getName(), Boolean.class.getName() },
1763                            SocialActivityAchievementModelImpl.GROUPID_COLUMN_BITMASK |
1764                            SocialActivityAchievementModelImpl.FIRSTINGROUP_COLUMN_BITMASK);
1765            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
1766                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
1767                            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1768                            "countByG_F",
1769                            new String[] { Long.class.getName(), Boolean.class.getName() });
1770    
1771            /**
1772             * Returns all the social activity achievements where groupId = &#63; and firstInGroup = &#63;.
1773             *
1774             * @param groupId the group ID
1775             * @param firstInGroup the first in group
1776             * @return the matching social activity achievements
1777             */
1778            @Override
1779            public List<SocialActivityAchievement> findByG_F(long groupId,
1780                    boolean firstInGroup) {
1781                    return findByG_F(groupId, firstInGroup, QueryUtil.ALL_POS,
1782                            QueryUtil.ALL_POS, null);
1783            }
1784    
1785            /**
1786             * Returns a range of all the social activity achievements where groupId = &#63; and firstInGroup = &#63;.
1787             *
1788             * <p>
1789             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1790             * </p>
1791             *
1792             * @param groupId the group ID
1793             * @param firstInGroup the first in group
1794             * @param start the lower bound of the range of social activity achievements
1795             * @param end the upper bound of the range of social activity achievements (not inclusive)
1796             * @return the range of matching social activity achievements
1797             */
1798            @Override
1799            public List<SocialActivityAchievement> findByG_F(long groupId,
1800                    boolean firstInGroup, int start, int end) {
1801                    return findByG_F(groupId, firstInGroup, start, end, null);
1802            }
1803    
1804            /**
1805             * Returns an ordered range of all the social activity achievements where groupId = &#63; and firstInGroup = &#63;.
1806             *
1807             * <p>
1808             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1809             * </p>
1810             *
1811             * @param groupId the group ID
1812             * @param firstInGroup the first in group
1813             * @param start the lower bound of the range of social activity achievements
1814             * @param end the upper bound of the range of social activity achievements (not inclusive)
1815             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1816             * @return the ordered range of matching social activity achievements
1817             */
1818            @Override
1819            public List<SocialActivityAchievement> findByG_F(long groupId,
1820                    boolean firstInGroup, int start, int end,
1821                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
1822                    return findByG_F(groupId, firstInGroup, start, end, orderByComparator,
1823                            true);
1824            }
1825    
1826            /**
1827             * Returns an ordered range of all the social activity achievements where groupId = &#63; and firstInGroup = &#63;.
1828             *
1829             * <p>
1830             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1831             * </p>
1832             *
1833             * @param groupId the group ID
1834             * @param firstInGroup the first in group
1835             * @param start the lower bound of the range of social activity achievements
1836             * @param end the upper bound of the range of social activity achievements (not inclusive)
1837             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1838             * @param retrieveFromCache whether to retrieve from the finder cache
1839             * @return the ordered range of matching social activity achievements
1840             */
1841            @Override
1842            public List<SocialActivityAchievement> findByG_F(long groupId,
1843                    boolean firstInGroup, int start, int end,
1844                    OrderByComparator<SocialActivityAchievement> orderByComparator,
1845                    boolean retrieveFromCache) {
1846                    boolean pagination = true;
1847                    FinderPath finderPath = null;
1848                    Object[] finderArgs = null;
1849    
1850                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1851                                    (orderByComparator == null)) {
1852                            pagination = false;
1853                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
1854                            finderArgs = new Object[] { groupId, firstInGroup };
1855                    }
1856                    else {
1857                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
1858                            finderArgs = new Object[] {
1859                                            groupId, firstInGroup,
1860                                            
1861                                            start, end, orderByComparator
1862                                    };
1863                    }
1864    
1865                    List<SocialActivityAchievement> list = null;
1866    
1867                    if (retrieveFromCache) {
1868                            list = (List<SocialActivityAchievement>)finderCache.getResult(finderPath,
1869                                            finderArgs, this);
1870    
1871                            if ((list != null) && !list.isEmpty()) {
1872                                    for (SocialActivityAchievement socialActivityAchievement : list) {
1873                                            if ((groupId != socialActivityAchievement.getGroupId()) ||
1874                                                            (firstInGroup != socialActivityAchievement.getFirstInGroup())) {
1875                                                    list = null;
1876    
1877                                                    break;
1878                                            }
1879                                    }
1880                            }
1881                    }
1882    
1883                    if (list == null) {
1884                            StringBundler query = null;
1885    
1886                            if (orderByComparator != null) {
1887                                    query = new StringBundler(4 +
1888                                                    (orderByComparator.getOrderByFields().length * 2));
1889                            }
1890                            else {
1891                                    query = new StringBundler(4);
1892                            }
1893    
1894                            query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
1895    
1896                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1897    
1898                            query.append(_FINDER_COLUMN_G_F_FIRSTINGROUP_2);
1899    
1900                            if (orderByComparator != null) {
1901                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1902                                            orderByComparator);
1903                            }
1904                            else
1905                             if (pagination) {
1906                                    query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
1907                            }
1908    
1909                            String sql = query.toString();
1910    
1911                            Session session = null;
1912    
1913                            try {
1914                                    session = openSession();
1915    
1916                                    Query q = session.createQuery(sql);
1917    
1918                                    QueryPos qPos = QueryPos.getInstance(q);
1919    
1920                                    qPos.add(groupId);
1921    
1922                                    qPos.add(firstInGroup);
1923    
1924                                    if (!pagination) {
1925                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
1926                                                            getDialect(), start, end, false);
1927    
1928                                            Collections.sort(list);
1929    
1930                                            list = Collections.unmodifiableList(list);
1931                                    }
1932                                    else {
1933                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
1934                                                            getDialect(), start, end);
1935                                    }
1936    
1937                                    cacheResult(list);
1938    
1939                                    finderCache.putResult(finderPath, finderArgs, list);
1940                            }
1941                            catch (Exception e) {
1942                                    finderCache.removeResult(finderPath, finderArgs);
1943    
1944                                    throw processException(e);
1945                            }
1946                            finally {
1947                                    closeSession(session);
1948                            }
1949                    }
1950    
1951                    return list;
1952            }
1953    
1954            /**
1955             * Returns the first social activity achievement in the ordered set where groupId = &#63; and firstInGroup = &#63;.
1956             *
1957             * @param groupId the group ID
1958             * @param firstInGroup the first in group
1959             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1960             * @return the first matching social activity achievement
1961             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
1962             */
1963            @Override
1964            public SocialActivityAchievement findByG_F_First(long groupId,
1965                    boolean firstInGroup,
1966                    OrderByComparator<SocialActivityAchievement> orderByComparator)
1967                    throws NoSuchActivityAchievementException {
1968                    SocialActivityAchievement socialActivityAchievement = fetchByG_F_First(groupId,
1969                                    firstInGroup, orderByComparator);
1970    
1971                    if (socialActivityAchievement != null) {
1972                            return socialActivityAchievement;
1973                    }
1974    
1975                    StringBundler msg = new StringBundler(6);
1976    
1977                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1978    
1979                    msg.append("groupId=");
1980                    msg.append(groupId);
1981    
1982                    msg.append(", firstInGroup=");
1983                    msg.append(firstInGroup);
1984    
1985                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1986    
1987                    throw new NoSuchActivityAchievementException(msg.toString());
1988            }
1989    
1990            /**
1991             * Returns the first social activity achievement in the ordered set where groupId = &#63; and firstInGroup = &#63;.
1992             *
1993             * @param groupId the group ID
1994             * @param firstInGroup the first in group
1995             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1996             * @return the first matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
1997             */
1998            @Override
1999            public SocialActivityAchievement fetchByG_F_First(long groupId,
2000                    boolean firstInGroup,
2001                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
2002                    List<SocialActivityAchievement> list = findByG_F(groupId, firstInGroup,
2003                                    0, 1, orderByComparator);
2004    
2005                    if (!list.isEmpty()) {
2006                            return list.get(0);
2007                    }
2008    
2009                    return null;
2010            }
2011    
2012            /**
2013             * Returns the last social activity achievement in the ordered set where groupId = &#63; and firstInGroup = &#63;.
2014             *
2015             * @param groupId the group ID
2016             * @param firstInGroup the first in group
2017             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2018             * @return the last matching social activity achievement
2019             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
2020             */
2021            @Override
2022            public SocialActivityAchievement findByG_F_Last(long groupId,
2023                    boolean firstInGroup,
2024                    OrderByComparator<SocialActivityAchievement> orderByComparator)
2025                    throws NoSuchActivityAchievementException {
2026                    SocialActivityAchievement socialActivityAchievement = fetchByG_F_Last(groupId,
2027                                    firstInGroup, orderByComparator);
2028    
2029                    if (socialActivityAchievement != null) {
2030                            return socialActivityAchievement;
2031                    }
2032    
2033                    StringBundler msg = new StringBundler(6);
2034    
2035                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2036    
2037                    msg.append("groupId=");
2038                    msg.append(groupId);
2039    
2040                    msg.append(", firstInGroup=");
2041                    msg.append(firstInGroup);
2042    
2043                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2044    
2045                    throw new NoSuchActivityAchievementException(msg.toString());
2046            }
2047    
2048            /**
2049             * Returns the last social activity achievement in the ordered set where groupId = &#63; and firstInGroup = &#63;.
2050             *
2051             * @param groupId the group ID
2052             * @param firstInGroup the first in group
2053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2054             * @return the last matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
2055             */
2056            @Override
2057            public SocialActivityAchievement fetchByG_F_Last(long groupId,
2058                    boolean firstInGroup,
2059                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
2060                    int count = countByG_F(groupId, firstInGroup);
2061    
2062                    if (count == 0) {
2063                            return null;
2064                    }
2065    
2066                    List<SocialActivityAchievement> list = findByG_F(groupId, firstInGroup,
2067                                    count - 1, count, orderByComparator);
2068    
2069                    if (!list.isEmpty()) {
2070                            return list.get(0);
2071                    }
2072    
2073                    return null;
2074            }
2075    
2076            /**
2077             * Returns the social activity achievements before and after the current social activity achievement in the ordered set where groupId = &#63; and firstInGroup = &#63;.
2078             *
2079             * @param activityAchievementId the primary key of the current social activity achievement
2080             * @param groupId the group ID
2081             * @param firstInGroup the first in group
2082             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2083             * @return the previous, current, and next social activity achievement
2084             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
2085             */
2086            @Override
2087            public SocialActivityAchievement[] findByG_F_PrevAndNext(
2088                    long activityAchievementId, long groupId, boolean firstInGroup,
2089                    OrderByComparator<SocialActivityAchievement> orderByComparator)
2090                    throws NoSuchActivityAchievementException {
2091                    SocialActivityAchievement socialActivityAchievement = findByPrimaryKey(activityAchievementId);
2092    
2093                    Session session = null;
2094    
2095                    try {
2096                            session = openSession();
2097    
2098                            SocialActivityAchievement[] array = new SocialActivityAchievementImpl[3];
2099    
2100                            array[0] = getByG_F_PrevAndNext(session, socialActivityAchievement,
2101                                            groupId, firstInGroup, orderByComparator, true);
2102    
2103                            array[1] = socialActivityAchievement;
2104    
2105                            array[2] = getByG_F_PrevAndNext(session, socialActivityAchievement,
2106                                            groupId, firstInGroup, orderByComparator, false);
2107    
2108                            return array;
2109                    }
2110                    catch (Exception e) {
2111                            throw processException(e);
2112                    }
2113                    finally {
2114                            closeSession(session);
2115                    }
2116            }
2117    
2118            protected SocialActivityAchievement getByG_F_PrevAndNext(Session session,
2119                    SocialActivityAchievement socialActivityAchievement, long groupId,
2120                    boolean firstInGroup,
2121                    OrderByComparator<SocialActivityAchievement> orderByComparator,
2122                    boolean previous) {
2123                    StringBundler query = null;
2124    
2125                    if (orderByComparator != null) {
2126                            query = new StringBundler(5 +
2127                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2128                                            (orderByComparator.getOrderByFields().length * 3));
2129                    }
2130                    else {
2131                            query = new StringBundler(4);
2132                    }
2133    
2134                    query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
2135    
2136                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2137    
2138                    query.append(_FINDER_COLUMN_G_F_FIRSTINGROUP_2);
2139    
2140                    if (orderByComparator != null) {
2141                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2142    
2143                            if (orderByConditionFields.length > 0) {
2144                                    query.append(WHERE_AND);
2145                            }
2146    
2147                            for (int i = 0; i < orderByConditionFields.length; i++) {
2148                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2149                                    query.append(orderByConditionFields[i]);
2150    
2151                                    if ((i + 1) < orderByConditionFields.length) {
2152                                            if (orderByComparator.isAscending() ^ previous) {
2153                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2154                                            }
2155                                            else {
2156                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2157                                            }
2158                                    }
2159                                    else {
2160                                            if (orderByComparator.isAscending() ^ previous) {
2161                                                    query.append(WHERE_GREATER_THAN);
2162                                            }
2163                                            else {
2164                                                    query.append(WHERE_LESSER_THAN);
2165                                            }
2166                                    }
2167                            }
2168    
2169                            query.append(ORDER_BY_CLAUSE);
2170    
2171                            String[] orderByFields = orderByComparator.getOrderByFields();
2172    
2173                            for (int i = 0; i < orderByFields.length; i++) {
2174                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2175                                    query.append(orderByFields[i]);
2176    
2177                                    if ((i + 1) < orderByFields.length) {
2178                                            if (orderByComparator.isAscending() ^ previous) {
2179                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2180                                            }
2181                                            else {
2182                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2183                                            }
2184                                    }
2185                                    else {
2186                                            if (orderByComparator.isAscending() ^ previous) {
2187                                                    query.append(ORDER_BY_ASC);
2188                                            }
2189                                            else {
2190                                                    query.append(ORDER_BY_DESC);
2191                                            }
2192                                    }
2193                            }
2194                    }
2195                    else {
2196                            query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
2197                    }
2198    
2199                    String sql = query.toString();
2200    
2201                    Query q = session.createQuery(sql);
2202    
2203                    q.setFirstResult(0);
2204                    q.setMaxResults(2);
2205    
2206                    QueryPos qPos = QueryPos.getInstance(q);
2207    
2208                    qPos.add(groupId);
2209    
2210                    qPos.add(firstInGroup);
2211    
2212                    if (orderByComparator != null) {
2213                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivityAchievement);
2214    
2215                            for (Object value : values) {
2216                                    qPos.add(value);
2217                            }
2218                    }
2219    
2220                    List<SocialActivityAchievement> list = q.list();
2221    
2222                    if (list.size() == 2) {
2223                            return list.get(1);
2224                    }
2225                    else {
2226                            return null;
2227                    }
2228            }
2229    
2230            /**
2231             * Removes all the social activity achievements where groupId = &#63; and firstInGroup = &#63; from the database.
2232             *
2233             * @param groupId the group ID
2234             * @param firstInGroup the first in group
2235             */
2236            @Override
2237            public void removeByG_F(long groupId, boolean firstInGroup) {
2238                    for (SocialActivityAchievement socialActivityAchievement : findByG_F(
2239                                    groupId, firstInGroup, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2240                                    null)) {
2241                            remove(socialActivityAchievement);
2242                    }
2243            }
2244    
2245            /**
2246             * Returns the number of social activity achievements where groupId = &#63; and firstInGroup = &#63;.
2247             *
2248             * @param groupId the group ID
2249             * @param firstInGroup the first in group
2250             * @return the number of matching social activity achievements
2251             */
2252            @Override
2253            public int countByG_F(long groupId, boolean firstInGroup) {
2254                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
2255    
2256                    Object[] finderArgs = new Object[] { groupId, firstInGroup };
2257    
2258                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2259    
2260                    if (count == null) {
2261                            StringBundler query = new StringBundler(3);
2262    
2263                            query.append(_SQL_COUNT_SOCIALACTIVITYACHIEVEMENT_WHERE);
2264    
2265                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2266    
2267                            query.append(_FINDER_COLUMN_G_F_FIRSTINGROUP_2);
2268    
2269                            String sql = query.toString();
2270    
2271                            Session session = null;
2272    
2273                            try {
2274                                    session = openSession();
2275    
2276                                    Query q = session.createQuery(sql);
2277    
2278                                    QueryPos qPos = QueryPos.getInstance(q);
2279    
2280                                    qPos.add(groupId);
2281    
2282                                    qPos.add(firstInGroup);
2283    
2284                                    count = (Long)q.uniqueResult();
2285    
2286                                    finderCache.putResult(finderPath, finderArgs, count);
2287                            }
2288                            catch (Exception e) {
2289                                    finderCache.removeResult(finderPath, finderArgs);
2290    
2291                                    throw processException(e);
2292                            }
2293                            finally {
2294                                    closeSession(session);
2295                            }
2296                    }
2297    
2298                    return count.intValue();
2299            }
2300    
2301            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "socialActivityAchievement.groupId = ? AND ";
2302            private static final String _FINDER_COLUMN_G_F_FIRSTINGROUP_2 = "socialActivityAchievement.firstInGroup = ?";
2303            public static final FinderPath FINDER_PATH_FETCH_BY_G_U_N = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
2304                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
2305                            SocialActivityAchievementImpl.class, FINDER_CLASS_NAME_ENTITY,
2306                            "fetchByG_U_N",
2307                            new String[] {
2308                                    Long.class.getName(), Long.class.getName(),
2309                                    String.class.getName()
2310                            },
2311                            SocialActivityAchievementModelImpl.GROUPID_COLUMN_BITMASK |
2312                            SocialActivityAchievementModelImpl.USERID_COLUMN_BITMASK |
2313                            SocialActivityAchievementModelImpl.NAME_COLUMN_BITMASK);
2314            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_N = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
2315                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
2316                            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2317                            "countByG_U_N",
2318                            new String[] {
2319                                    Long.class.getName(), Long.class.getName(),
2320                                    String.class.getName()
2321                            });
2322    
2323            /**
2324             * Returns the social activity achievement where groupId = &#63; and userId = &#63; and name = &#63; or throws a {@link NoSuchActivityAchievementException} if it could not be found.
2325             *
2326             * @param groupId the group ID
2327             * @param userId the user ID
2328             * @param name the name
2329             * @return the matching social activity achievement
2330             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
2331             */
2332            @Override
2333            public SocialActivityAchievement findByG_U_N(long groupId, long userId,
2334                    String name) throws NoSuchActivityAchievementException {
2335                    SocialActivityAchievement socialActivityAchievement = fetchByG_U_N(groupId,
2336                                    userId, name);
2337    
2338                    if (socialActivityAchievement == null) {
2339                            StringBundler msg = new StringBundler(8);
2340    
2341                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2342    
2343                            msg.append("groupId=");
2344                            msg.append(groupId);
2345    
2346                            msg.append(", userId=");
2347                            msg.append(userId);
2348    
2349                            msg.append(", name=");
2350                            msg.append(name);
2351    
2352                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2353    
2354                            if (_log.isWarnEnabled()) {
2355                                    _log.warn(msg.toString());
2356                            }
2357    
2358                            throw new NoSuchActivityAchievementException(msg.toString());
2359                    }
2360    
2361                    return socialActivityAchievement;
2362            }
2363    
2364            /**
2365             * Returns the social activity achievement where groupId = &#63; and userId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2366             *
2367             * @param groupId the group ID
2368             * @param userId the user ID
2369             * @param name the name
2370             * @return the matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
2371             */
2372            @Override
2373            public SocialActivityAchievement fetchByG_U_N(long groupId, long userId,
2374                    String name) {
2375                    return fetchByG_U_N(groupId, userId, name, true);
2376            }
2377    
2378            /**
2379             * Returns the social activity achievement where groupId = &#63; and userId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2380             *
2381             * @param groupId the group ID
2382             * @param userId the user ID
2383             * @param name the name
2384             * @param retrieveFromCache whether to retrieve from the finder cache
2385             * @return the matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
2386             */
2387            @Override
2388            public SocialActivityAchievement fetchByG_U_N(long groupId, long userId,
2389                    String name, boolean retrieveFromCache) {
2390                    Object[] finderArgs = new Object[] { groupId, userId, name };
2391    
2392                    Object result = null;
2393    
2394                    if (retrieveFromCache) {
2395                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_U_N,
2396                                            finderArgs, this);
2397                    }
2398    
2399                    if (result instanceof SocialActivityAchievement) {
2400                            SocialActivityAchievement socialActivityAchievement = (SocialActivityAchievement)result;
2401    
2402                            if ((groupId != socialActivityAchievement.getGroupId()) ||
2403                                            (userId != socialActivityAchievement.getUserId()) ||
2404                                            !Validator.equals(name, socialActivityAchievement.getName())) {
2405                                    result = null;
2406                            }
2407                    }
2408    
2409                    if (result == null) {
2410                            StringBundler query = new StringBundler(5);
2411    
2412                            query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
2413    
2414                            query.append(_FINDER_COLUMN_G_U_N_GROUPID_2);
2415    
2416                            query.append(_FINDER_COLUMN_G_U_N_USERID_2);
2417    
2418                            boolean bindName = false;
2419    
2420                            if (name == null) {
2421                                    query.append(_FINDER_COLUMN_G_U_N_NAME_1);
2422                            }
2423                            else if (name.equals(StringPool.BLANK)) {
2424                                    query.append(_FINDER_COLUMN_G_U_N_NAME_3);
2425                            }
2426                            else {
2427                                    bindName = true;
2428    
2429                                    query.append(_FINDER_COLUMN_G_U_N_NAME_2);
2430                            }
2431    
2432                            String sql = query.toString();
2433    
2434                            Session session = null;
2435    
2436                            try {
2437                                    session = openSession();
2438    
2439                                    Query q = session.createQuery(sql);
2440    
2441                                    QueryPos qPos = QueryPos.getInstance(q);
2442    
2443                                    qPos.add(groupId);
2444    
2445                                    qPos.add(userId);
2446    
2447                                    if (bindName) {
2448                                            qPos.add(name);
2449                                    }
2450    
2451                                    List<SocialActivityAchievement> list = q.list();
2452    
2453                                    if (list.isEmpty()) {
2454                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_U_N,
2455                                                    finderArgs, list);
2456                                    }
2457                                    else {
2458                                            SocialActivityAchievement socialActivityAchievement = list.get(0);
2459    
2460                                            result = socialActivityAchievement;
2461    
2462                                            cacheResult(socialActivityAchievement);
2463    
2464                                            if ((socialActivityAchievement.getGroupId() != groupId) ||
2465                                                            (socialActivityAchievement.getUserId() != userId) ||
2466                                                            (socialActivityAchievement.getName() == null) ||
2467                                                            !socialActivityAchievement.getName().equals(name)) {
2468                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_U_N,
2469                                                            finderArgs, socialActivityAchievement);
2470                                            }
2471                                    }
2472                            }
2473                            catch (Exception e) {
2474                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_U_N, finderArgs);
2475    
2476                                    throw processException(e);
2477                            }
2478                            finally {
2479                                    closeSession(session);
2480                            }
2481                    }
2482    
2483                    if (result instanceof List<?>) {
2484                            return null;
2485                    }
2486                    else {
2487                            return (SocialActivityAchievement)result;
2488                    }
2489            }
2490    
2491            /**
2492             * Removes the social activity achievement where groupId = &#63; and userId = &#63; and name = &#63; from the database.
2493             *
2494             * @param groupId the group ID
2495             * @param userId the user ID
2496             * @param name the name
2497             * @return the social activity achievement that was removed
2498             */
2499            @Override
2500            public SocialActivityAchievement removeByG_U_N(long groupId, long userId,
2501                    String name) throws NoSuchActivityAchievementException {
2502                    SocialActivityAchievement socialActivityAchievement = findByG_U_N(groupId,
2503                                    userId, name);
2504    
2505                    return remove(socialActivityAchievement);
2506            }
2507    
2508            /**
2509             * Returns the number of social activity achievements where groupId = &#63; and userId = &#63; and name = &#63;.
2510             *
2511             * @param groupId the group ID
2512             * @param userId the user ID
2513             * @param name the name
2514             * @return the number of matching social activity achievements
2515             */
2516            @Override
2517            public int countByG_U_N(long groupId, long userId, String name) {
2518                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_N;
2519    
2520                    Object[] finderArgs = new Object[] { groupId, userId, name };
2521    
2522                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2523    
2524                    if (count == null) {
2525                            StringBundler query = new StringBundler(4);
2526    
2527                            query.append(_SQL_COUNT_SOCIALACTIVITYACHIEVEMENT_WHERE);
2528    
2529                            query.append(_FINDER_COLUMN_G_U_N_GROUPID_2);
2530    
2531                            query.append(_FINDER_COLUMN_G_U_N_USERID_2);
2532    
2533                            boolean bindName = false;
2534    
2535                            if (name == null) {
2536                                    query.append(_FINDER_COLUMN_G_U_N_NAME_1);
2537                            }
2538                            else if (name.equals(StringPool.BLANK)) {
2539                                    query.append(_FINDER_COLUMN_G_U_N_NAME_3);
2540                            }
2541                            else {
2542                                    bindName = true;
2543    
2544                                    query.append(_FINDER_COLUMN_G_U_N_NAME_2);
2545                            }
2546    
2547                            String sql = query.toString();
2548    
2549                            Session session = null;
2550    
2551                            try {
2552                                    session = openSession();
2553    
2554                                    Query q = session.createQuery(sql);
2555    
2556                                    QueryPos qPos = QueryPos.getInstance(q);
2557    
2558                                    qPos.add(groupId);
2559    
2560                                    qPos.add(userId);
2561    
2562                                    if (bindName) {
2563                                            qPos.add(name);
2564                                    }
2565    
2566                                    count = (Long)q.uniqueResult();
2567    
2568                                    finderCache.putResult(finderPath, finderArgs, count);
2569                            }
2570                            catch (Exception e) {
2571                                    finderCache.removeResult(finderPath, finderArgs);
2572    
2573                                    throw processException(e);
2574                            }
2575                            finally {
2576                                    closeSession(session);
2577                            }
2578                    }
2579    
2580                    return count.intValue();
2581            }
2582    
2583            private static final String _FINDER_COLUMN_G_U_N_GROUPID_2 = "socialActivityAchievement.groupId = ? AND ";
2584            private static final String _FINDER_COLUMN_G_U_N_USERID_2 = "socialActivityAchievement.userId = ? AND ";
2585            private static final String _FINDER_COLUMN_G_U_N_NAME_1 = "socialActivityAchievement.name IS NULL";
2586            private static final String _FINDER_COLUMN_G_U_N_NAME_2 = "socialActivityAchievement.name = ?";
2587            private static final String _FINDER_COLUMN_G_U_N_NAME_3 = "(socialActivityAchievement.name IS NULL OR socialActivityAchievement.name = '')";
2588            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
2589                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
2590                            SocialActivityAchievementImpl.class,
2591                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_F",
2592                            new String[] {
2593                                    Long.class.getName(), Long.class.getName(),
2594                                    Boolean.class.getName(),
2595                                    
2596                            Integer.class.getName(), Integer.class.getName(),
2597                                    OrderByComparator.class.getName()
2598                            });
2599            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
2600                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
2601                            SocialActivityAchievementImpl.class,
2602                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F",
2603                            new String[] {
2604                                    Long.class.getName(), Long.class.getName(),
2605                                    Boolean.class.getName()
2606                            },
2607                            SocialActivityAchievementModelImpl.GROUPID_COLUMN_BITMASK |
2608                            SocialActivityAchievementModelImpl.USERID_COLUMN_BITMASK |
2609                            SocialActivityAchievementModelImpl.FIRSTINGROUP_COLUMN_BITMASK);
2610            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F = new FinderPath(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
2611                            SocialActivityAchievementModelImpl.FINDER_CACHE_ENABLED,
2612                            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2613                            "countByG_U_F",
2614                            new String[] {
2615                                    Long.class.getName(), Long.class.getName(),
2616                                    Boolean.class.getName()
2617                            });
2618    
2619            /**
2620             * Returns all the social activity achievements where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2621             *
2622             * @param groupId the group ID
2623             * @param userId the user ID
2624             * @param firstInGroup the first in group
2625             * @return the matching social activity achievements
2626             */
2627            @Override
2628            public List<SocialActivityAchievement> findByG_U_F(long groupId,
2629                    long userId, boolean firstInGroup) {
2630                    return findByG_U_F(groupId, userId, firstInGroup, QueryUtil.ALL_POS,
2631                            QueryUtil.ALL_POS, null);
2632            }
2633    
2634            /**
2635             * Returns a range of all the social activity achievements where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2636             *
2637             * <p>
2638             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2639             * </p>
2640             *
2641             * @param groupId the group ID
2642             * @param userId the user ID
2643             * @param firstInGroup the first in group
2644             * @param start the lower bound of the range of social activity achievements
2645             * @param end the upper bound of the range of social activity achievements (not inclusive)
2646             * @return the range of matching social activity achievements
2647             */
2648            @Override
2649            public List<SocialActivityAchievement> findByG_U_F(long groupId,
2650                    long userId, boolean firstInGroup, int start, int end) {
2651                    return findByG_U_F(groupId, userId, firstInGroup, start, end, null);
2652            }
2653    
2654            /**
2655             * Returns an ordered range of all the social activity achievements where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2656             *
2657             * <p>
2658             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2659             * </p>
2660             *
2661             * @param groupId the group ID
2662             * @param userId the user ID
2663             * @param firstInGroup the first in group
2664             * @param start the lower bound of the range of social activity achievements
2665             * @param end the upper bound of the range of social activity achievements (not inclusive)
2666             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2667             * @return the ordered range of matching social activity achievements
2668             */
2669            @Override
2670            public List<SocialActivityAchievement> findByG_U_F(long groupId,
2671                    long userId, boolean firstInGroup, int start, int end,
2672                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
2673                    return findByG_U_F(groupId, userId, firstInGroup, start, end,
2674                            orderByComparator, true);
2675            }
2676    
2677            /**
2678             * Returns an ordered range of all the social activity achievements where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2679             *
2680             * <p>
2681             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2682             * </p>
2683             *
2684             * @param groupId the group ID
2685             * @param userId the user ID
2686             * @param firstInGroup the first in group
2687             * @param start the lower bound of the range of social activity achievements
2688             * @param end the upper bound of the range of social activity achievements (not inclusive)
2689             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2690             * @param retrieveFromCache whether to retrieve from the finder cache
2691             * @return the ordered range of matching social activity achievements
2692             */
2693            @Override
2694            public List<SocialActivityAchievement> findByG_U_F(long groupId,
2695                    long userId, boolean firstInGroup, int start, int end,
2696                    OrderByComparator<SocialActivityAchievement> orderByComparator,
2697                    boolean retrieveFromCache) {
2698                    boolean pagination = true;
2699                    FinderPath finderPath = null;
2700                    Object[] finderArgs = null;
2701    
2702                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2703                                    (orderByComparator == null)) {
2704                            pagination = false;
2705                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F;
2706                            finderArgs = new Object[] { groupId, userId, firstInGroup };
2707                    }
2708                    else {
2709                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
2710                            finderArgs = new Object[] {
2711                                            groupId, userId, firstInGroup,
2712                                            
2713                                            start, end, orderByComparator
2714                                    };
2715                    }
2716    
2717                    List<SocialActivityAchievement> list = null;
2718    
2719                    if (retrieveFromCache) {
2720                            list = (List<SocialActivityAchievement>)finderCache.getResult(finderPath,
2721                                            finderArgs, this);
2722    
2723                            if ((list != null) && !list.isEmpty()) {
2724                                    for (SocialActivityAchievement socialActivityAchievement : list) {
2725                                            if ((groupId != socialActivityAchievement.getGroupId()) ||
2726                                                            (userId != socialActivityAchievement.getUserId()) ||
2727                                                            (firstInGroup != socialActivityAchievement.getFirstInGroup())) {
2728                                                    list = null;
2729    
2730                                                    break;
2731                                            }
2732                                    }
2733                            }
2734                    }
2735    
2736                    if (list == null) {
2737                            StringBundler query = null;
2738    
2739                            if (orderByComparator != null) {
2740                                    query = new StringBundler(5 +
2741                                                    (orderByComparator.getOrderByFields().length * 2));
2742                            }
2743                            else {
2744                                    query = new StringBundler(5);
2745                            }
2746    
2747                            query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
2748    
2749                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
2750    
2751                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
2752    
2753                            query.append(_FINDER_COLUMN_G_U_F_FIRSTINGROUP_2);
2754    
2755                            if (orderByComparator != null) {
2756                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2757                                            orderByComparator);
2758                            }
2759                            else
2760                             if (pagination) {
2761                                    query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
2762                            }
2763    
2764                            String sql = query.toString();
2765    
2766                            Session session = null;
2767    
2768                            try {
2769                                    session = openSession();
2770    
2771                                    Query q = session.createQuery(sql);
2772    
2773                                    QueryPos qPos = QueryPos.getInstance(q);
2774    
2775                                    qPos.add(groupId);
2776    
2777                                    qPos.add(userId);
2778    
2779                                    qPos.add(firstInGroup);
2780    
2781                                    if (!pagination) {
2782                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
2783                                                            getDialect(), start, end, false);
2784    
2785                                            Collections.sort(list);
2786    
2787                                            list = Collections.unmodifiableList(list);
2788                                    }
2789                                    else {
2790                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
2791                                                            getDialect(), start, end);
2792                                    }
2793    
2794                                    cacheResult(list);
2795    
2796                                    finderCache.putResult(finderPath, finderArgs, list);
2797                            }
2798                            catch (Exception e) {
2799                                    finderCache.removeResult(finderPath, finderArgs);
2800    
2801                                    throw processException(e);
2802                            }
2803                            finally {
2804                                    closeSession(session);
2805                            }
2806                    }
2807    
2808                    return list;
2809            }
2810    
2811            /**
2812             * Returns the first social activity achievement in the ordered set where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2813             *
2814             * @param groupId the group ID
2815             * @param userId the user ID
2816             * @param firstInGroup the first in group
2817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2818             * @return the first matching social activity achievement
2819             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
2820             */
2821            @Override
2822            public SocialActivityAchievement findByG_U_F_First(long groupId,
2823                    long userId, boolean firstInGroup,
2824                    OrderByComparator<SocialActivityAchievement> orderByComparator)
2825                    throws NoSuchActivityAchievementException {
2826                    SocialActivityAchievement socialActivityAchievement = fetchByG_U_F_First(groupId,
2827                                    userId, firstInGroup, orderByComparator);
2828    
2829                    if (socialActivityAchievement != null) {
2830                            return socialActivityAchievement;
2831                    }
2832    
2833                    StringBundler msg = new StringBundler(8);
2834    
2835                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2836    
2837                    msg.append("groupId=");
2838                    msg.append(groupId);
2839    
2840                    msg.append(", userId=");
2841                    msg.append(userId);
2842    
2843                    msg.append(", firstInGroup=");
2844                    msg.append(firstInGroup);
2845    
2846                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2847    
2848                    throw new NoSuchActivityAchievementException(msg.toString());
2849            }
2850    
2851            /**
2852             * Returns the first social activity achievement in the ordered set where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2853             *
2854             * @param groupId the group ID
2855             * @param userId the user ID
2856             * @param firstInGroup the first in group
2857             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2858             * @return the first matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
2859             */
2860            @Override
2861            public SocialActivityAchievement fetchByG_U_F_First(long groupId,
2862                    long userId, boolean firstInGroup,
2863                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
2864                    List<SocialActivityAchievement> list = findByG_U_F(groupId, userId,
2865                                    firstInGroup, 0, 1, orderByComparator);
2866    
2867                    if (!list.isEmpty()) {
2868                            return list.get(0);
2869                    }
2870    
2871                    return null;
2872            }
2873    
2874            /**
2875             * Returns the last social activity achievement in the ordered set where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2876             *
2877             * @param groupId the group ID
2878             * @param userId the user ID
2879             * @param firstInGroup the first in group
2880             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2881             * @return the last matching social activity achievement
2882             * @throws NoSuchActivityAchievementException if a matching social activity achievement could not be found
2883             */
2884            @Override
2885            public SocialActivityAchievement findByG_U_F_Last(long groupId,
2886                    long userId, boolean firstInGroup,
2887                    OrderByComparator<SocialActivityAchievement> orderByComparator)
2888                    throws NoSuchActivityAchievementException {
2889                    SocialActivityAchievement socialActivityAchievement = fetchByG_U_F_Last(groupId,
2890                                    userId, firstInGroup, orderByComparator);
2891    
2892                    if (socialActivityAchievement != null) {
2893                            return socialActivityAchievement;
2894                    }
2895    
2896                    StringBundler msg = new StringBundler(8);
2897    
2898                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2899    
2900                    msg.append("groupId=");
2901                    msg.append(groupId);
2902    
2903                    msg.append(", userId=");
2904                    msg.append(userId);
2905    
2906                    msg.append(", firstInGroup=");
2907                    msg.append(firstInGroup);
2908    
2909                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2910    
2911                    throw new NoSuchActivityAchievementException(msg.toString());
2912            }
2913    
2914            /**
2915             * Returns the last social activity achievement in the ordered set where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2916             *
2917             * @param groupId the group ID
2918             * @param userId the user ID
2919             * @param firstInGroup the first in group
2920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2921             * @return the last matching social activity achievement, or <code>null</code> if a matching social activity achievement could not be found
2922             */
2923            @Override
2924            public SocialActivityAchievement fetchByG_U_F_Last(long groupId,
2925                    long userId, boolean firstInGroup,
2926                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
2927                    int count = countByG_U_F(groupId, userId, firstInGroup);
2928    
2929                    if (count == 0) {
2930                            return null;
2931                    }
2932    
2933                    List<SocialActivityAchievement> list = findByG_U_F(groupId, userId,
2934                                    firstInGroup, count - 1, count, orderByComparator);
2935    
2936                    if (!list.isEmpty()) {
2937                            return list.get(0);
2938                    }
2939    
2940                    return null;
2941            }
2942    
2943            /**
2944             * Returns the social activity achievements before and after the current social activity achievement in the ordered set where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
2945             *
2946             * @param activityAchievementId the primary key of the current social activity achievement
2947             * @param groupId the group ID
2948             * @param userId the user ID
2949             * @param firstInGroup the first in group
2950             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2951             * @return the previous, current, and next social activity achievement
2952             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
2953             */
2954            @Override
2955            public SocialActivityAchievement[] findByG_U_F_PrevAndNext(
2956                    long activityAchievementId, long groupId, long userId,
2957                    boolean firstInGroup,
2958                    OrderByComparator<SocialActivityAchievement> orderByComparator)
2959                    throws NoSuchActivityAchievementException {
2960                    SocialActivityAchievement socialActivityAchievement = findByPrimaryKey(activityAchievementId);
2961    
2962                    Session session = null;
2963    
2964                    try {
2965                            session = openSession();
2966    
2967                            SocialActivityAchievement[] array = new SocialActivityAchievementImpl[3];
2968    
2969                            array[0] = getByG_U_F_PrevAndNext(session,
2970                                            socialActivityAchievement, groupId, userId, firstInGroup,
2971                                            orderByComparator, true);
2972    
2973                            array[1] = socialActivityAchievement;
2974    
2975                            array[2] = getByG_U_F_PrevAndNext(session,
2976                                            socialActivityAchievement, groupId, userId, firstInGroup,
2977                                            orderByComparator, false);
2978    
2979                            return array;
2980                    }
2981                    catch (Exception e) {
2982                            throw processException(e);
2983                    }
2984                    finally {
2985                            closeSession(session);
2986                    }
2987            }
2988    
2989            protected SocialActivityAchievement getByG_U_F_PrevAndNext(
2990                    Session session, SocialActivityAchievement socialActivityAchievement,
2991                    long groupId, long userId, boolean firstInGroup,
2992                    OrderByComparator<SocialActivityAchievement> orderByComparator,
2993                    boolean previous) {
2994                    StringBundler query = null;
2995    
2996                    if (orderByComparator != null) {
2997                            query = new StringBundler(6 +
2998                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2999                                            (orderByComparator.getOrderByFields().length * 3));
3000                    }
3001                    else {
3002                            query = new StringBundler(5);
3003                    }
3004    
3005                    query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE);
3006    
3007                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
3008    
3009                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
3010    
3011                    query.append(_FINDER_COLUMN_G_U_F_FIRSTINGROUP_2);
3012    
3013                    if (orderByComparator != null) {
3014                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3015    
3016                            if (orderByConditionFields.length > 0) {
3017                                    query.append(WHERE_AND);
3018                            }
3019    
3020                            for (int i = 0; i < orderByConditionFields.length; i++) {
3021                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3022                                    query.append(orderByConditionFields[i]);
3023    
3024                                    if ((i + 1) < orderByConditionFields.length) {
3025                                            if (orderByComparator.isAscending() ^ previous) {
3026                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3027                                            }
3028                                            else {
3029                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3030                                            }
3031                                    }
3032                                    else {
3033                                            if (orderByComparator.isAscending() ^ previous) {
3034                                                    query.append(WHERE_GREATER_THAN);
3035                                            }
3036                                            else {
3037                                                    query.append(WHERE_LESSER_THAN);
3038                                            }
3039                                    }
3040                            }
3041    
3042                            query.append(ORDER_BY_CLAUSE);
3043    
3044                            String[] orderByFields = orderByComparator.getOrderByFields();
3045    
3046                            for (int i = 0; i < orderByFields.length; i++) {
3047                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3048                                    query.append(orderByFields[i]);
3049    
3050                                    if ((i + 1) < orderByFields.length) {
3051                                            if (orderByComparator.isAscending() ^ previous) {
3052                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3053                                            }
3054                                            else {
3055                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3056                                            }
3057                                    }
3058                                    else {
3059                                            if (orderByComparator.isAscending() ^ previous) {
3060                                                    query.append(ORDER_BY_ASC);
3061                                            }
3062                                            else {
3063                                                    query.append(ORDER_BY_DESC);
3064                                            }
3065                                    }
3066                            }
3067                    }
3068                    else {
3069                            query.append(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
3070                    }
3071    
3072                    String sql = query.toString();
3073    
3074                    Query q = session.createQuery(sql);
3075    
3076                    q.setFirstResult(0);
3077                    q.setMaxResults(2);
3078    
3079                    QueryPos qPos = QueryPos.getInstance(q);
3080    
3081                    qPos.add(groupId);
3082    
3083                    qPos.add(userId);
3084    
3085                    qPos.add(firstInGroup);
3086    
3087                    if (orderByComparator != null) {
3088                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivityAchievement);
3089    
3090                            for (Object value : values) {
3091                                    qPos.add(value);
3092                            }
3093                    }
3094    
3095                    List<SocialActivityAchievement> list = q.list();
3096    
3097                    if (list.size() == 2) {
3098                            return list.get(1);
3099                    }
3100                    else {
3101                            return null;
3102                    }
3103            }
3104    
3105            /**
3106             * Removes all the social activity achievements where groupId = &#63; and userId = &#63; and firstInGroup = &#63; from the database.
3107             *
3108             * @param groupId the group ID
3109             * @param userId the user ID
3110             * @param firstInGroup the first in group
3111             */
3112            @Override
3113            public void removeByG_U_F(long groupId, long userId, boolean firstInGroup) {
3114                    for (SocialActivityAchievement socialActivityAchievement : findByG_U_F(
3115                                    groupId, userId, firstInGroup, QueryUtil.ALL_POS,
3116                                    QueryUtil.ALL_POS, null)) {
3117                            remove(socialActivityAchievement);
3118                    }
3119            }
3120    
3121            /**
3122             * Returns the number of social activity achievements where groupId = &#63; and userId = &#63; and firstInGroup = &#63;.
3123             *
3124             * @param groupId the group ID
3125             * @param userId the user ID
3126             * @param firstInGroup the first in group
3127             * @return the number of matching social activity achievements
3128             */
3129            @Override
3130            public int countByG_U_F(long groupId, long userId, boolean firstInGroup) {
3131                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_F;
3132    
3133                    Object[] finderArgs = new Object[] { groupId, userId, firstInGroup };
3134    
3135                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3136    
3137                    if (count == null) {
3138                            StringBundler query = new StringBundler(4);
3139    
3140                            query.append(_SQL_COUNT_SOCIALACTIVITYACHIEVEMENT_WHERE);
3141    
3142                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
3143    
3144                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
3145    
3146                            query.append(_FINDER_COLUMN_G_U_F_FIRSTINGROUP_2);
3147    
3148                            String sql = query.toString();
3149    
3150                            Session session = null;
3151    
3152                            try {
3153                                    session = openSession();
3154    
3155                                    Query q = session.createQuery(sql);
3156    
3157                                    QueryPos qPos = QueryPos.getInstance(q);
3158    
3159                                    qPos.add(groupId);
3160    
3161                                    qPos.add(userId);
3162    
3163                                    qPos.add(firstInGroup);
3164    
3165                                    count = (Long)q.uniqueResult();
3166    
3167                                    finderCache.putResult(finderPath, finderArgs, count);
3168                            }
3169                            catch (Exception e) {
3170                                    finderCache.removeResult(finderPath, finderArgs);
3171    
3172                                    throw processException(e);
3173                            }
3174                            finally {
3175                                    closeSession(session);
3176                            }
3177                    }
3178    
3179                    return count.intValue();
3180            }
3181    
3182            private static final String _FINDER_COLUMN_G_U_F_GROUPID_2 = "socialActivityAchievement.groupId = ? AND ";
3183            private static final String _FINDER_COLUMN_G_U_F_USERID_2 = "socialActivityAchievement.userId = ? AND ";
3184            private static final String _FINDER_COLUMN_G_U_F_FIRSTINGROUP_2 = "socialActivityAchievement.firstInGroup = ?";
3185    
3186            public SocialActivityAchievementPersistenceImpl() {
3187                    setModelClass(SocialActivityAchievement.class);
3188            }
3189    
3190            /**
3191             * Caches the social activity achievement in the entity cache if it is enabled.
3192             *
3193             * @param socialActivityAchievement the social activity achievement
3194             */
3195            @Override
3196            public void cacheResult(SocialActivityAchievement socialActivityAchievement) {
3197                    entityCache.putResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3198                            SocialActivityAchievementImpl.class,
3199                            socialActivityAchievement.getPrimaryKey(), socialActivityAchievement);
3200    
3201                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_U_N,
3202                            new Object[] {
3203                                    socialActivityAchievement.getGroupId(),
3204                                    socialActivityAchievement.getUserId(),
3205                                    socialActivityAchievement.getName()
3206                            }, socialActivityAchievement);
3207    
3208                    socialActivityAchievement.resetOriginalValues();
3209            }
3210    
3211            /**
3212             * Caches the social activity achievements in the entity cache if it is enabled.
3213             *
3214             * @param socialActivityAchievements the social activity achievements
3215             */
3216            @Override
3217            public void cacheResult(
3218                    List<SocialActivityAchievement> socialActivityAchievements) {
3219                    for (SocialActivityAchievement socialActivityAchievement : socialActivityAchievements) {
3220                            if (entityCache.getResult(
3221                                                    SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3222                                                    SocialActivityAchievementImpl.class,
3223                                                    socialActivityAchievement.getPrimaryKey()) == null) {
3224                                    cacheResult(socialActivityAchievement);
3225                            }
3226                            else {
3227                                    socialActivityAchievement.resetOriginalValues();
3228                            }
3229                    }
3230            }
3231    
3232            /**
3233             * Clears the cache for all social activity achievements.
3234             *
3235             * <p>
3236             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
3237             * </p>
3238             */
3239            @Override
3240            public void clearCache() {
3241                    entityCache.clearCache(SocialActivityAchievementImpl.class);
3242    
3243                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
3244                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3245                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3246            }
3247    
3248            /**
3249             * Clears the cache for the social activity achievement.
3250             *
3251             * <p>
3252             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
3253             * </p>
3254             */
3255            @Override
3256            public void clearCache(SocialActivityAchievement socialActivityAchievement) {
3257                    entityCache.removeResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3258                            SocialActivityAchievementImpl.class,
3259                            socialActivityAchievement.getPrimaryKey());
3260    
3261                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3262                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3263    
3264                    clearUniqueFindersCache((SocialActivityAchievementModelImpl)socialActivityAchievement);
3265            }
3266    
3267            @Override
3268            public void clearCache(
3269                    List<SocialActivityAchievement> socialActivityAchievements) {
3270                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3271                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3272    
3273                    for (SocialActivityAchievement socialActivityAchievement : socialActivityAchievements) {
3274                            entityCache.removeResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3275                                    SocialActivityAchievementImpl.class,
3276                                    socialActivityAchievement.getPrimaryKey());
3277    
3278                            clearUniqueFindersCache((SocialActivityAchievementModelImpl)socialActivityAchievement);
3279                    }
3280            }
3281    
3282            protected void cacheUniqueFindersCache(
3283                    SocialActivityAchievementModelImpl socialActivityAchievementModelImpl,
3284                    boolean isNew) {
3285                    if (isNew) {
3286                            Object[] args = new Object[] {
3287                                            socialActivityAchievementModelImpl.getGroupId(),
3288                                            socialActivityAchievementModelImpl.getUserId(),
3289                                            socialActivityAchievementModelImpl.getName()
3290                                    };
3291    
3292                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_U_N, args,
3293                                    Long.valueOf(1));
3294                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_U_N, args,
3295                                    socialActivityAchievementModelImpl);
3296                    }
3297                    else {
3298                            if ((socialActivityAchievementModelImpl.getColumnBitmask() &
3299                                            FINDER_PATH_FETCH_BY_G_U_N.getColumnBitmask()) != 0) {
3300                                    Object[] args = new Object[] {
3301                                                    socialActivityAchievementModelImpl.getGroupId(),
3302                                                    socialActivityAchievementModelImpl.getUserId(),
3303                                                    socialActivityAchievementModelImpl.getName()
3304                                            };
3305    
3306                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_U_N, args,
3307                                            Long.valueOf(1));
3308                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_U_N, args,
3309                                            socialActivityAchievementModelImpl);
3310                            }
3311                    }
3312            }
3313    
3314            protected void clearUniqueFindersCache(
3315                    SocialActivityAchievementModelImpl socialActivityAchievementModelImpl) {
3316                    Object[] args = new Object[] {
3317                                    socialActivityAchievementModelImpl.getGroupId(),
3318                                    socialActivityAchievementModelImpl.getUserId(),
3319                                    socialActivityAchievementModelImpl.getName()
3320                            };
3321    
3322                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_N, args);
3323                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_U_N, args);
3324    
3325                    if ((socialActivityAchievementModelImpl.getColumnBitmask() &
3326                                    FINDER_PATH_FETCH_BY_G_U_N.getColumnBitmask()) != 0) {
3327                            args = new Object[] {
3328                                            socialActivityAchievementModelImpl.getOriginalGroupId(),
3329                                            socialActivityAchievementModelImpl.getOriginalUserId(),
3330                                            socialActivityAchievementModelImpl.getOriginalName()
3331                                    };
3332    
3333                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_N, args);
3334                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_U_N, args);
3335                    }
3336            }
3337    
3338            /**
3339             * Creates a new social activity achievement with the primary key. Does not add the social activity achievement to the database.
3340             *
3341             * @param activityAchievementId the primary key for the new social activity achievement
3342             * @return the new social activity achievement
3343             */
3344            @Override
3345            public SocialActivityAchievement create(long activityAchievementId) {
3346                    SocialActivityAchievement socialActivityAchievement = new SocialActivityAchievementImpl();
3347    
3348                    socialActivityAchievement.setNew(true);
3349                    socialActivityAchievement.setPrimaryKey(activityAchievementId);
3350    
3351                    socialActivityAchievement.setCompanyId(companyProvider.getCompanyId());
3352    
3353                    return socialActivityAchievement;
3354            }
3355    
3356            /**
3357             * Removes the social activity achievement with the primary key from the database. Also notifies the appropriate model listeners.
3358             *
3359             * @param activityAchievementId the primary key of the social activity achievement
3360             * @return the social activity achievement that was removed
3361             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
3362             */
3363            @Override
3364            public SocialActivityAchievement remove(long activityAchievementId)
3365                    throws NoSuchActivityAchievementException {
3366                    return remove((Serializable)activityAchievementId);
3367            }
3368    
3369            /**
3370             * Removes the social activity achievement with the primary key from the database. Also notifies the appropriate model listeners.
3371             *
3372             * @param primaryKey the primary key of the social activity achievement
3373             * @return the social activity achievement that was removed
3374             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
3375             */
3376            @Override
3377            public SocialActivityAchievement remove(Serializable primaryKey)
3378                    throws NoSuchActivityAchievementException {
3379                    Session session = null;
3380    
3381                    try {
3382                            session = openSession();
3383    
3384                            SocialActivityAchievement socialActivityAchievement = (SocialActivityAchievement)session.get(SocialActivityAchievementImpl.class,
3385                                            primaryKey);
3386    
3387                            if (socialActivityAchievement == null) {
3388                                    if (_log.isWarnEnabled()) {
3389                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3390                                    }
3391    
3392                                    throw new NoSuchActivityAchievementException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3393                                            primaryKey);
3394                            }
3395    
3396                            return remove(socialActivityAchievement);
3397                    }
3398                    catch (NoSuchActivityAchievementException nsee) {
3399                            throw nsee;
3400                    }
3401                    catch (Exception e) {
3402                            throw processException(e);
3403                    }
3404                    finally {
3405                            closeSession(session);
3406                    }
3407            }
3408    
3409            @Override
3410            protected SocialActivityAchievement removeImpl(
3411                    SocialActivityAchievement socialActivityAchievement) {
3412                    socialActivityAchievement = toUnwrappedModel(socialActivityAchievement);
3413    
3414                    Session session = null;
3415    
3416                    try {
3417                            session = openSession();
3418    
3419                            if (!session.contains(socialActivityAchievement)) {
3420                                    socialActivityAchievement = (SocialActivityAchievement)session.get(SocialActivityAchievementImpl.class,
3421                                                    socialActivityAchievement.getPrimaryKeyObj());
3422                            }
3423    
3424                            if (socialActivityAchievement != null) {
3425                                    session.delete(socialActivityAchievement);
3426                            }
3427                    }
3428                    catch (Exception e) {
3429                            throw processException(e);
3430                    }
3431                    finally {
3432                            closeSession(session);
3433                    }
3434    
3435                    if (socialActivityAchievement != null) {
3436                            clearCache(socialActivityAchievement);
3437                    }
3438    
3439                    return socialActivityAchievement;
3440            }
3441    
3442            @Override
3443            public SocialActivityAchievement updateImpl(
3444                    SocialActivityAchievement socialActivityAchievement) {
3445                    socialActivityAchievement = toUnwrappedModel(socialActivityAchievement);
3446    
3447                    boolean isNew = socialActivityAchievement.isNew();
3448    
3449                    SocialActivityAchievementModelImpl socialActivityAchievementModelImpl = (SocialActivityAchievementModelImpl)socialActivityAchievement;
3450    
3451                    Session session = null;
3452    
3453                    try {
3454                            session = openSession();
3455    
3456                            if (socialActivityAchievement.isNew()) {
3457                                    session.save(socialActivityAchievement);
3458    
3459                                    socialActivityAchievement.setNew(false);
3460                            }
3461                            else {
3462                                    socialActivityAchievement = (SocialActivityAchievement)session.merge(socialActivityAchievement);
3463                            }
3464                    }
3465                    catch (Exception e) {
3466                            throw processException(e);
3467                    }
3468                    finally {
3469                            closeSession(session);
3470                    }
3471    
3472                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3473    
3474                    if (isNew ||
3475                                    !SocialActivityAchievementModelImpl.COLUMN_BITMASK_ENABLED) {
3476                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3477                    }
3478    
3479                    else {
3480                            if ((socialActivityAchievementModelImpl.getColumnBitmask() &
3481                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
3482                                    Object[] args = new Object[] {
3483                                                    socialActivityAchievementModelImpl.getOriginalGroupId()
3484                                            };
3485    
3486                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3487                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3488                                            args);
3489    
3490                                    args = new Object[] {
3491                                                    socialActivityAchievementModelImpl.getGroupId()
3492                                            };
3493    
3494                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3495                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3496                                            args);
3497                            }
3498    
3499                            if ((socialActivityAchievementModelImpl.getColumnBitmask() &
3500                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
3501                                    Object[] args = new Object[] {
3502                                                    socialActivityAchievementModelImpl.getOriginalGroupId(),
3503                                                    socialActivityAchievementModelImpl.getOriginalUserId()
3504                                            };
3505    
3506                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
3507                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
3508                                            args);
3509    
3510                                    args = new Object[] {
3511                                                    socialActivityAchievementModelImpl.getGroupId(),
3512                                                    socialActivityAchievementModelImpl.getUserId()
3513                                            };
3514    
3515                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
3516                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
3517                                            args);
3518                            }
3519    
3520                            if ((socialActivityAchievementModelImpl.getColumnBitmask() &
3521                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N.getColumnBitmask()) != 0) {
3522                                    Object[] args = new Object[] {
3523                                                    socialActivityAchievementModelImpl.getOriginalGroupId(),
3524                                                    socialActivityAchievementModelImpl.getOriginalName()
3525                                            };
3526    
3527                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
3528                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N,
3529                                            args);
3530    
3531                                    args = new Object[] {
3532                                                    socialActivityAchievementModelImpl.getGroupId(),
3533                                                    socialActivityAchievementModelImpl.getName()
3534                                            };
3535    
3536                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
3537                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N,
3538                                            args);
3539                            }
3540    
3541                            if ((socialActivityAchievementModelImpl.getColumnBitmask() &
3542                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
3543                                    Object[] args = new Object[] {
3544                                                    socialActivityAchievementModelImpl.getOriginalGroupId(),
3545                                                    socialActivityAchievementModelImpl.getOriginalFirstInGroup()
3546                                            };
3547    
3548                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
3549                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
3550                                            args);
3551    
3552                                    args = new Object[] {
3553                                                    socialActivityAchievementModelImpl.getGroupId(),
3554                                                    socialActivityAchievementModelImpl.getFirstInGroup()
3555                                            };
3556    
3557                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
3558                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
3559                                            args);
3560                            }
3561    
3562                            if ((socialActivityAchievementModelImpl.getColumnBitmask() &
3563                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F.getColumnBitmask()) != 0) {
3564                                    Object[] args = new Object[] {
3565                                                    socialActivityAchievementModelImpl.getOriginalGroupId(),
3566                                                    socialActivityAchievementModelImpl.getOriginalUserId(),
3567                                                    socialActivityAchievementModelImpl.getOriginalFirstInGroup()
3568                                            };
3569    
3570                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
3571                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
3572                                            args);
3573    
3574                                    args = new Object[] {
3575                                                    socialActivityAchievementModelImpl.getGroupId(),
3576                                                    socialActivityAchievementModelImpl.getUserId(),
3577                                                    socialActivityAchievementModelImpl.getFirstInGroup()
3578                                            };
3579    
3580                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
3581                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
3582                                            args);
3583                            }
3584                    }
3585    
3586                    entityCache.putResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3587                            SocialActivityAchievementImpl.class,
3588                            socialActivityAchievement.getPrimaryKey(),
3589                            socialActivityAchievement, false);
3590    
3591                    clearUniqueFindersCache(socialActivityAchievementModelImpl);
3592                    cacheUniqueFindersCache(socialActivityAchievementModelImpl, isNew);
3593    
3594                    socialActivityAchievement.resetOriginalValues();
3595    
3596                    return socialActivityAchievement;
3597            }
3598    
3599            protected SocialActivityAchievement toUnwrappedModel(
3600                    SocialActivityAchievement socialActivityAchievement) {
3601                    if (socialActivityAchievement instanceof SocialActivityAchievementImpl) {
3602                            return socialActivityAchievement;
3603                    }
3604    
3605                    SocialActivityAchievementImpl socialActivityAchievementImpl = new SocialActivityAchievementImpl();
3606    
3607                    socialActivityAchievementImpl.setNew(socialActivityAchievement.isNew());
3608                    socialActivityAchievementImpl.setPrimaryKey(socialActivityAchievement.getPrimaryKey());
3609    
3610                    socialActivityAchievementImpl.setActivityAchievementId(socialActivityAchievement.getActivityAchievementId());
3611                    socialActivityAchievementImpl.setGroupId(socialActivityAchievement.getGroupId());
3612                    socialActivityAchievementImpl.setCompanyId(socialActivityAchievement.getCompanyId());
3613                    socialActivityAchievementImpl.setUserId(socialActivityAchievement.getUserId());
3614                    socialActivityAchievementImpl.setCreateDate(socialActivityAchievement.getCreateDate());
3615                    socialActivityAchievementImpl.setName(socialActivityAchievement.getName());
3616                    socialActivityAchievementImpl.setFirstInGroup(socialActivityAchievement.isFirstInGroup());
3617    
3618                    return socialActivityAchievementImpl;
3619            }
3620    
3621            /**
3622             * Returns the social activity achievement with the primary key or throws a {@link com.liferay.portal.exception.NoSuchModelException} if it could not be found.
3623             *
3624             * @param primaryKey the primary key of the social activity achievement
3625             * @return the social activity achievement
3626             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
3627             */
3628            @Override
3629            public SocialActivityAchievement findByPrimaryKey(Serializable primaryKey)
3630                    throws NoSuchActivityAchievementException {
3631                    SocialActivityAchievement socialActivityAchievement = fetchByPrimaryKey(primaryKey);
3632    
3633                    if (socialActivityAchievement == null) {
3634                            if (_log.isWarnEnabled()) {
3635                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3636                            }
3637    
3638                            throw new NoSuchActivityAchievementException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3639                                    primaryKey);
3640                    }
3641    
3642                    return socialActivityAchievement;
3643            }
3644    
3645            /**
3646             * Returns the social activity achievement with the primary key or throws a {@link NoSuchActivityAchievementException} if it could not be found.
3647             *
3648             * @param activityAchievementId the primary key of the social activity achievement
3649             * @return the social activity achievement
3650             * @throws NoSuchActivityAchievementException if a social activity achievement with the primary key could not be found
3651             */
3652            @Override
3653            public SocialActivityAchievement findByPrimaryKey(
3654                    long activityAchievementId) throws NoSuchActivityAchievementException {
3655                    return findByPrimaryKey((Serializable)activityAchievementId);
3656            }
3657    
3658            /**
3659             * Returns the social activity achievement with the primary key or returns <code>null</code> if it could not be found.
3660             *
3661             * @param primaryKey the primary key of the social activity achievement
3662             * @return the social activity achievement, or <code>null</code> if a social activity achievement with the primary key could not be found
3663             */
3664            @Override
3665            public SocialActivityAchievement fetchByPrimaryKey(Serializable primaryKey) {
3666                    SocialActivityAchievement socialActivityAchievement = (SocialActivityAchievement)entityCache.getResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3667                                    SocialActivityAchievementImpl.class, primaryKey);
3668    
3669                    if (socialActivityAchievement == _nullSocialActivityAchievement) {
3670                            return null;
3671                    }
3672    
3673                    if (socialActivityAchievement == null) {
3674                            Session session = null;
3675    
3676                            try {
3677                                    session = openSession();
3678    
3679                                    socialActivityAchievement = (SocialActivityAchievement)session.get(SocialActivityAchievementImpl.class,
3680                                                    primaryKey);
3681    
3682                                    if (socialActivityAchievement != null) {
3683                                            cacheResult(socialActivityAchievement);
3684                                    }
3685                                    else {
3686                                            entityCache.putResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3687                                                    SocialActivityAchievementImpl.class, primaryKey,
3688                                                    _nullSocialActivityAchievement);
3689                                    }
3690                            }
3691                            catch (Exception e) {
3692                                    entityCache.removeResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3693                                            SocialActivityAchievementImpl.class, primaryKey);
3694    
3695                                    throw processException(e);
3696                            }
3697                            finally {
3698                                    closeSession(session);
3699                            }
3700                    }
3701    
3702                    return socialActivityAchievement;
3703            }
3704    
3705            /**
3706             * Returns the social activity achievement with the primary key or returns <code>null</code> if it could not be found.
3707             *
3708             * @param activityAchievementId the primary key of the social activity achievement
3709             * @return the social activity achievement, or <code>null</code> if a social activity achievement with the primary key could not be found
3710             */
3711            @Override
3712            public SocialActivityAchievement fetchByPrimaryKey(
3713                    long activityAchievementId) {
3714                    return fetchByPrimaryKey((Serializable)activityAchievementId);
3715            }
3716    
3717            @Override
3718            public Map<Serializable, SocialActivityAchievement> fetchByPrimaryKeys(
3719                    Set<Serializable> primaryKeys) {
3720                    if (primaryKeys.isEmpty()) {
3721                            return Collections.emptyMap();
3722                    }
3723    
3724                    Map<Serializable, SocialActivityAchievement> map = new HashMap<Serializable, SocialActivityAchievement>();
3725    
3726                    if (primaryKeys.size() == 1) {
3727                            Iterator<Serializable> iterator = primaryKeys.iterator();
3728    
3729                            Serializable primaryKey = iterator.next();
3730    
3731                            SocialActivityAchievement socialActivityAchievement = fetchByPrimaryKey(primaryKey);
3732    
3733                            if (socialActivityAchievement != null) {
3734                                    map.put(primaryKey, socialActivityAchievement);
3735                            }
3736    
3737                            return map;
3738                    }
3739    
3740                    Set<Serializable> uncachedPrimaryKeys = null;
3741    
3742                    for (Serializable primaryKey : primaryKeys) {
3743                            SocialActivityAchievement socialActivityAchievement = (SocialActivityAchievement)entityCache.getResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3744                                            SocialActivityAchievementImpl.class, primaryKey);
3745    
3746                            if (socialActivityAchievement == null) {
3747                                    if (uncachedPrimaryKeys == null) {
3748                                            uncachedPrimaryKeys = new HashSet<Serializable>();
3749                                    }
3750    
3751                                    uncachedPrimaryKeys.add(primaryKey);
3752                            }
3753                            else {
3754                                    map.put(primaryKey, socialActivityAchievement);
3755                            }
3756                    }
3757    
3758                    if (uncachedPrimaryKeys == null) {
3759                            return map;
3760                    }
3761    
3762                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3763                                    1);
3764    
3765                    query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE_PKS_IN);
3766    
3767                    for (Serializable primaryKey : uncachedPrimaryKeys) {
3768                            query.append(String.valueOf(primaryKey));
3769    
3770                            query.append(StringPool.COMMA);
3771                    }
3772    
3773                    query.setIndex(query.index() - 1);
3774    
3775                    query.append(StringPool.CLOSE_PARENTHESIS);
3776    
3777                    String sql = query.toString();
3778    
3779                    Session session = null;
3780    
3781                    try {
3782                            session = openSession();
3783    
3784                            Query q = session.createQuery(sql);
3785    
3786                            for (SocialActivityAchievement socialActivityAchievement : (List<SocialActivityAchievement>)q.list()) {
3787                                    map.put(socialActivityAchievement.getPrimaryKeyObj(),
3788                                            socialActivityAchievement);
3789    
3790                                    cacheResult(socialActivityAchievement);
3791    
3792                                    uncachedPrimaryKeys.remove(socialActivityAchievement.getPrimaryKeyObj());
3793                            }
3794    
3795                            for (Serializable primaryKey : uncachedPrimaryKeys) {
3796                                    entityCache.putResult(SocialActivityAchievementModelImpl.ENTITY_CACHE_ENABLED,
3797                                            SocialActivityAchievementImpl.class, primaryKey,
3798                                            _nullSocialActivityAchievement);
3799                            }
3800                    }
3801                    catch (Exception e) {
3802                            throw processException(e);
3803                    }
3804                    finally {
3805                            closeSession(session);
3806                    }
3807    
3808                    return map;
3809            }
3810    
3811            /**
3812             * Returns all the social activity achievements.
3813             *
3814             * @return the social activity achievements
3815             */
3816            @Override
3817            public List<SocialActivityAchievement> findAll() {
3818                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3819            }
3820    
3821            /**
3822             * Returns a range of all the social activity achievements.
3823             *
3824             * <p>
3825             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3826             * </p>
3827             *
3828             * @param start the lower bound of the range of social activity achievements
3829             * @param end the upper bound of the range of social activity achievements (not inclusive)
3830             * @return the range of social activity achievements
3831             */
3832            @Override
3833            public List<SocialActivityAchievement> findAll(int start, int end) {
3834                    return findAll(start, end, null);
3835            }
3836    
3837            /**
3838             * Returns an ordered range of all the social activity achievements.
3839             *
3840             * <p>
3841             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3842             * </p>
3843             *
3844             * @param start the lower bound of the range of social activity achievements
3845             * @param end the upper bound of the range of social activity achievements (not inclusive)
3846             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3847             * @return the ordered range of social activity achievements
3848             */
3849            @Override
3850            public List<SocialActivityAchievement> findAll(int start, int end,
3851                    OrderByComparator<SocialActivityAchievement> orderByComparator) {
3852                    return findAll(start, end, orderByComparator, true);
3853            }
3854    
3855            /**
3856             * Returns an ordered range of all the social activity achievements.
3857             *
3858             * <p>
3859             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialActivityAchievementModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3860             * </p>
3861             *
3862             * @param start the lower bound of the range of social activity achievements
3863             * @param end the upper bound of the range of social activity achievements (not inclusive)
3864             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3865             * @param retrieveFromCache whether to retrieve from the finder cache
3866             * @return the ordered range of social activity achievements
3867             */
3868            @Override
3869            public List<SocialActivityAchievement> findAll(int start, int end,
3870                    OrderByComparator<SocialActivityAchievement> orderByComparator,
3871                    boolean retrieveFromCache) {
3872                    boolean pagination = true;
3873                    FinderPath finderPath = null;
3874                    Object[] finderArgs = null;
3875    
3876                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3877                                    (orderByComparator == null)) {
3878                            pagination = false;
3879                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3880                            finderArgs = FINDER_ARGS_EMPTY;
3881                    }
3882                    else {
3883                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3884                            finderArgs = new Object[] { start, end, orderByComparator };
3885                    }
3886    
3887                    List<SocialActivityAchievement> list = null;
3888    
3889                    if (retrieveFromCache) {
3890                            list = (List<SocialActivityAchievement>)finderCache.getResult(finderPath,
3891                                            finderArgs, this);
3892                    }
3893    
3894                    if (list == null) {
3895                            StringBundler query = null;
3896                            String sql = null;
3897    
3898                            if (orderByComparator != null) {
3899                                    query = new StringBundler(2 +
3900                                                    (orderByComparator.getOrderByFields().length * 2));
3901    
3902                                    query.append(_SQL_SELECT_SOCIALACTIVITYACHIEVEMENT);
3903    
3904                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3905                                            orderByComparator);
3906    
3907                                    sql = query.toString();
3908                            }
3909                            else {
3910                                    sql = _SQL_SELECT_SOCIALACTIVITYACHIEVEMENT;
3911    
3912                                    if (pagination) {
3913                                            sql = sql.concat(SocialActivityAchievementModelImpl.ORDER_BY_JPQL);
3914                                    }
3915                            }
3916    
3917                            Session session = null;
3918    
3919                            try {
3920                                    session = openSession();
3921    
3922                                    Query q = session.createQuery(sql);
3923    
3924                                    if (!pagination) {
3925                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
3926                                                            getDialect(), start, end, false);
3927    
3928                                            Collections.sort(list);
3929    
3930                                            list = Collections.unmodifiableList(list);
3931                                    }
3932                                    else {
3933                                            list = (List<SocialActivityAchievement>)QueryUtil.list(q,
3934                                                            getDialect(), start, end);
3935                                    }
3936    
3937                                    cacheResult(list);
3938    
3939                                    finderCache.putResult(finderPath, finderArgs, list);
3940                            }
3941                            catch (Exception e) {
3942                                    finderCache.removeResult(finderPath, finderArgs);
3943    
3944                                    throw processException(e);
3945                            }
3946                            finally {
3947                                    closeSession(session);
3948                            }
3949                    }
3950    
3951                    return list;
3952            }
3953    
3954            /**
3955             * Removes all the social activity achievements from the database.
3956             *
3957             */
3958            @Override
3959            public void removeAll() {
3960                    for (SocialActivityAchievement socialActivityAchievement : findAll()) {
3961                            remove(socialActivityAchievement);
3962                    }
3963            }
3964    
3965            /**
3966             * Returns the number of social activity achievements.
3967             *
3968             * @return the number of social activity achievements
3969             */
3970            @Override
3971            public int countAll() {
3972                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
3973                                    FINDER_ARGS_EMPTY, this);
3974    
3975                    if (count == null) {
3976                            Session session = null;
3977    
3978                            try {
3979                                    session = openSession();
3980    
3981                                    Query q = session.createQuery(_SQL_COUNT_SOCIALACTIVITYACHIEVEMENT);
3982    
3983                                    count = (Long)q.uniqueResult();
3984    
3985                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
3986                                            count);
3987                            }
3988                            catch (Exception e) {
3989                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
3990                                            FINDER_ARGS_EMPTY);
3991    
3992                                    throw processException(e);
3993                            }
3994                            finally {
3995                                    closeSession(session);
3996                            }
3997                    }
3998    
3999                    return count.intValue();
4000            }
4001    
4002            @Override
4003            protected Map<String, Integer> getTableColumnsMap() {
4004                    return SocialActivityAchievementModelImpl.TABLE_COLUMNS_MAP;
4005            }
4006    
4007            /**
4008             * Initializes the social activity achievement persistence.
4009             */
4010            public void afterPropertiesSet() {
4011            }
4012    
4013            public void destroy() {
4014                    entityCache.removeCache(SocialActivityAchievementImpl.class.getName());
4015                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
4016                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4017                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4018            }
4019    
4020            @BeanReference(type = CompanyProviderWrapper.class)
4021            protected CompanyProvider companyProvider;
4022            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
4023            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
4024            private static final String _SQL_SELECT_SOCIALACTIVITYACHIEVEMENT = "SELECT socialActivityAchievement FROM SocialActivityAchievement socialActivityAchievement";
4025            private static final String _SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE_PKS_IN =
4026                    "SELECT socialActivityAchievement FROM SocialActivityAchievement socialActivityAchievement WHERE activityAchievementId IN (";
4027            private static final String _SQL_SELECT_SOCIALACTIVITYACHIEVEMENT_WHERE = "SELECT socialActivityAchievement FROM SocialActivityAchievement socialActivityAchievement WHERE ";
4028            private static final String _SQL_COUNT_SOCIALACTIVITYACHIEVEMENT = "SELECT COUNT(socialActivityAchievement) FROM SocialActivityAchievement socialActivityAchievement";
4029            private static final String _SQL_COUNT_SOCIALACTIVITYACHIEVEMENT_WHERE = "SELECT COUNT(socialActivityAchievement) FROM SocialActivityAchievement socialActivityAchievement WHERE ";
4030            private static final String _ORDER_BY_ENTITY_ALIAS = "socialActivityAchievement.";
4031            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialActivityAchievement exists with the primary key ";
4032            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialActivityAchievement exists with the key {";
4033            private static final Log _log = LogFactoryUtil.getLog(SocialActivityAchievementPersistenceImpl.class);
4034            private static final SocialActivityAchievement _nullSocialActivityAchievement =
4035                    new SocialActivityAchievementImpl() {
4036                            @Override
4037                            public Object clone() {
4038                                    return this;
4039                            }
4040    
4041                            @Override
4042                            public CacheModel<SocialActivityAchievement> toCacheModel() {
4043                                    return _nullSocialActivityAchievementCacheModel;
4044                            }
4045                    };
4046    
4047            private static final CacheModel<SocialActivityAchievement> _nullSocialActivityAchievementCacheModel =
4048                    new CacheModel<SocialActivityAchievement>() {
4049                            @Override
4050                            public SocialActivityAchievement toEntityModel() {
4051                                    return _nullSocialActivityAchievement;
4052                            }
4053                    };
4054    }