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