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