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