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