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