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