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