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