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