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