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