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