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