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