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