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