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