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