001
014
015 package com.liferay.portlet.social.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.service.persistence.BatchSessionUtil;
041 import com.liferay.portal.service.persistence.ResourcePersistence;
042 import com.liferay.portal.service.persistence.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.social.NoSuchRelationException;
046 import com.liferay.portlet.social.model.SocialRelation;
047 import com.liferay.portlet.social.model.impl.SocialRelationImpl;
048 import com.liferay.portlet.social.model.impl.SocialRelationModelImpl;
049
050 import java.io.Serializable;
051
052 import java.util.ArrayList;
053 import java.util.Collections;
054 import java.util.List;
055
056
068 public class SocialRelationPersistenceImpl extends BasePersistenceImpl<SocialRelation>
069 implements SocialRelationPersistence {
070
075 public static final String FINDER_CLASS_NAME_ENTITY = SocialRelationImpl.class.getName();
076 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List1";
078 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List2";
080 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
081 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
082 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
083 "findByUuid",
084 new String[] {
085 String.class.getName(),
086
087 "java.lang.Integer", "java.lang.Integer",
088 "com.liferay.portal.kernel.util.OrderByComparator"
089 });
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
091 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
092 SocialRelationImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
094 new String[] { String.class.getName() },
095 SocialRelationModelImpl.UUID_COLUMN_BITMASK);
096 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
097 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
099 new String[] { String.class.getName() });
100 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
101 new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
102 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
103 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
104 "findByCompanyId",
105 new String[] {
106 Long.class.getName(),
107
108 "java.lang.Integer", "java.lang.Integer",
109 "com.liferay.portal.kernel.util.OrderByComparator"
110 });
111 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
112 new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
113 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
114 SocialRelationImpl.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
116 new String[] { Long.class.getName() },
117 SocialRelationModelImpl.COMPANYID_COLUMN_BITMASK);
118 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
119 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
121 new String[] { Long.class.getName() });
122 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID1 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
123 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
124 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
125 "findByUserId1",
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_WITHOUT_PAGINATION_FIND_BY_USERID1 =
133 new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
134 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
135 SocialRelationImpl.class,
136 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId1",
137 new String[] { Long.class.getName() },
138 SocialRelationModelImpl.USERID1_COLUMN_BITMASK);
139 public static final FinderPath FINDER_PATH_COUNT_BY_USERID1 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
140 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId1",
142 new String[] { Long.class.getName() });
143 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
144 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
145 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
146 "findByUserId2",
147 new String[] {
148 Long.class.getName(),
149
150 "java.lang.Integer", "java.lang.Integer",
151 "com.liferay.portal.kernel.util.OrderByComparator"
152 });
153 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2 =
154 new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
155 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
156 SocialRelationImpl.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId2",
158 new String[] { Long.class.getName() },
159 SocialRelationModelImpl.USERID2_COLUMN_BITMASK);
160 public static final FinderPath FINDER_PATH_COUNT_BY_USERID2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
161 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
162 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId2",
163 new String[] { Long.class.getName() });
164 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
165 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
166 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
167 "findByType",
168 new String[] {
169 Integer.class.getName(),
170
171 "java.lang.Integer", "java.lang.Integer",
172 "com.liferay.portal.kernel.util.OrderByComparator"
173 });
174 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
175 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
176 SocialRelationImpl.class,
177 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByType",
178 new String[] { Integer.class.getName() },
179 SocialRelationModelImpl.TYPE_COLUMN_BITMASK);
180 public static final FinderPath FINDER_PATH_COUNT_BY_TYPE = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
181 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
182 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByType",
183 new String[] { Integer.class.getName() });
184 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
185 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
186 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
187 "findByC_T",
188 new String[] {
189 Long.class.getName(), Integer.class.getName(),
190
191 "java.lang.Integer", "java.lang.Integer",
192 "com.liferay.portal.kernel.util.OrderByComparator"
193 });
194 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
195 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
196 SocialRelationImpl.class,
197 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T",
198 new String[] { Long.class.getName(), Integer.class.getName() },
199 SocialRelationModelImpl.COMPANYID_COLUMN_BITMASK |
200 SocialRelationModelImpl.TYPE_COLUMN_BITMASK);
201 public static final FinderPath FINDER_PATH_COUNT_BY_C_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
202 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
203 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T",
204 new String[] { Long.class.getName(), Integer.class.getName() });
205 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U1_U2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
206 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
207 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
208 "findByU1_U2",
209 new String[] {
210 Long.class.getName(), Long.class.getName(),
211
212 "java.lang.Integer", "java.lang.Integer",
213 "com.liferay.portal.kernel.util.OrderByComparator"
214 });
215 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
216 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
217 SocialRelationImpl.class,
218 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU1_U2",
219 new String[] { Long.class.getName(), Long.class.getName() },
220 SocialRelationModelImpl.USERID1_COLUMN_BITMASK |
221 SocialRelationModelImpl.USERID2_COLUMN_BITMASK);
222 public static final FinderPath FINDER_PATH_COUNT_BY_U1_U2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
223 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
224 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU1_U2",
225 new String[] { Long.class.getName(), Long.class.getName() });
226 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U1_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
227 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
228 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
229 "findByU1_T",
230 new String[] {
231 Long.class.getName(), Integer.class.getName(),
232
233 "java.lang.Integer", "java.lang.Integer",
234 "com.liferay.portal.kernel.util.OrderByComparator"
235 });
236 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
237 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
238 SocialRelationImpl.class,
239 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU1_T",
240 new String[] { Long.class.getName(), Integer.class.getName() },
241 SocialRelationModelImpl.USERID1_COLUMN_BITMASK |
242 SocialRelationModelImpl.TYPE_COLUMN_BITMASK);
243 public static final FinderPath FINDER_PATH_COUNT_BY_U1_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
244 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
245 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU1_T",
246 new String[] { Long.class.getName(), Integer.class.getName() });
247 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
248 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
249 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
250 "findByU2_T",
251 new String[] {
252 Long.class.getName(), Integer.class.getName(),
253
254 "java.lang.Integer", "java.lang.Integer",
255 "com.liferay.portal.kernel.util.OrderByComparator"
256 });
257 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
258 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
259 SocialRelationImpl.class,
260 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU2_T",
261 new String[] { Long.class.getName(), Integer.class.getName() },
262 SocialRelationModelImpl.USERID2_COLUMN_BITMASK |
263 SocialRelationModelImpl.TYPE_COLUMN_BITMASK);
264 public static final FinderPath FINDER_PATH_COUNT_BY_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
265 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
266 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU2_T",
267 new String[] { Long.class.getName(), Integer.class.getName() });
268 public static final FinderPath FINDER_PATH_FETCH_BY_U1_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
269 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
270 SocialRelationImpl.class, FINDER_CLASS_NAME_ENTITY,
271 "fetchByU1_U2_T",
272 new String[] {
273 Long.class.getName(), Long.class.getName(),
274 Integer.class.getName()
275 },
276 SocialRelationModelImpl.USERID1_COLUMN_BITMASK |
277 SocialRelationModelImpl.USERID2_COLUMN_BITMASK |
278 SocialRelationModelImpl.TYPE_COLUMN_BITMASK);
279 public static final FinderPath FINDER_PATH_COUNT_BY_U1_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
280 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
281 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU1_U2_T",
282 new String[] {
283 Long.class.getName(), Long.class.getName(),
284 Integer.class.getName()
285 });
286 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
287 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
288 SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
289 "findAll", new String[0]);
290 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
291 SocialRelationModelImpl.FINDER_CACHE_ENABLED,
292 SocialRelationImpl.class,
293 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
294 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
295 SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class,
296 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
297
298
303 public void cacheResult(SocialRelation socialRelation) {
304 EntityCacheUtil.putResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
305 SocialRelationImpl.class, socialRelation.getPrimaryKey(),
306 socialRelation);
307
308 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U1_U2_T,
309 new Object[] {
310 Long.valueOf(socialRelation.getUserId1()),
311 Long.valueOf(socialRelation.getUserId2()),
312 Integer.valueOf(socialRelation.getType())
313 }, socialRelation);
314
315 socialRelation.resetOriginalValues();
316 }
317
318
323 public void cacheResult(List<SocialRelation> socialRelations) {
324 for (SocialRelation socialRelation : socialRelations) {
325 if (EntityCacheUtil.getResult(
326 SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
327 SocialRelationImpl.class, socialRelation.getPrimaryKey()) == null) {
328 cacheResult(socialRelation);
329 }
330 else {
331 socialRelation.resetOriginalValues();
332 }
333 }
334 }
335
336
343 @Override
344 public void clearCache() {
345 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
346 CacheRegistryUtil.clear(SocialRelationImpl.class.getName());
347 }
348
349 EntityCacheUtil.clearCache(SocialRelationImpl.class.getName());
350
351 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
352 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
353 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
354 }
355
356
363 @Override
364 public void clearCache(SocialRelation socialRelation) {
365 EntityCacheUtil.removeResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
366 SocialRelationImpl.class, socialRelation.getPrimaryKey());
367
368 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
369 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
370
371 clearUniqueFindersCache(socialRelation);
372 }
373
374 @Override
375 public void clearCache(List<SocialRelation> socialRelations) {
376 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
377 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
378
379 for (SocialRelation socialRelation : socialRelations) {
380 EntityCacheUtil.removeResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
381 SocialRelationImpl.class, socialRelation.getPrimaryKey());
382
383 clearUniqueFindersCache(socialRelation);
384 }
385 }
386
387 protected void clearUniqueFindersCache(SocialRelation socialRelation) {
388 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U1_U2_T,
389 new Object[] {
390 Long.valueOf(socialRelation.getUserId1()),
391 Long.valueOf(socialRelation.getUserId2()),
392 Integer.valueOf(socialRelation.getType())
393 });
394 }
395
396
402 public SocialRelation create(long relationId) {
403 SocialRelation socialRelation = new SocialRelationImpl();
404
405 socialRelation.setNew(true);
406 socialRelation.setPrimaryKey(relationId);
407
408 String uuid = PortalUUIDUtil.generate();
409
410 socialRelation.setUuid(uuid);
411
412 return socialRelation;
413 }
414
415
423 public SocialRelation remove(long relationId)
424 throws NoSuchRelationException, SystemException {
425 return remove(Long.valueOf(relationId));
426 }
427
428
436 @Override
437 public SocialRelation remove(Serializable primaryKey)
438 throws NoSuchRelationException, SystemException {
439 Session session = null;
440
441 try {
442 session = openSession();
443
444 SocialRelation socialRelation = (SocialRelation)session.get(SocialRelationImpl.class,
445 primaryKey);
446
447 if (socialRelation == null) {
448 if (_log.isWarnEnabled()) {
449 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
450 }
451
452 throw new NoSuchRelationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
453 primaryKey);
454 }
455
456 return remove(socialRelation);
457 }
458 catch (NoSuchRelationException nsee) {
459 throw nsee;
460 }
461 catch (Exception e) {
462 throw processException(e);
463 }
464 finally {
465 closeSession(session);
466 }
467 }
468
469 @Override
470 protected SocialRelation removeImpl(SocialRelation socialRelation)
471 throws SystemException {
472 socialRelation = toUnwrappedModel(socialRelation);
473
474 Session session = null;
475
476 try {
477 session = openSession();
478
479 BatchSessionUtil.delete(session, socialRelation);
480 }
481 catch (Exception e) {
482 throw processException(e);
483 }
484 finally {
485 closeSession(session);
486 }
487
488 clearCache(socialRelation);
489
490 return socialRelation;
491 }
492
493 @Override
494 public SocialRelation updateImpl(
495 com.liferay.portlet.social.model.SocialRelation socialRelation,
496 boolean merge) throws SystemException {
497 socialRelation = toUnwrappedModel(socialRelation);
498
499 boolean isNew = socialRelation.isNew();
500
501 SocialRelationModelImpl socialRelationModelImpl = (SocialRelationModelImpl)socialRelation;
502
503 if (Validator.isNull(socialRelation.getUuid())) {
504 String uuid = PortalUUIDUtil.generate();
505
506 socialRelation.setUuid(uuid);
507 }
508
509 Session session = null;
510
511 try {
512 session = openSession();
513
514 BatchSessionUtil.update(session, socialRelation, merge);
515
516 socialRelation.setNew(false);
517 }
518 catch (Exception e) {
519 throw processException(e);
520 }
521 finally {
522 closeSession(session);
523 }
524
525 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
526
527 if (isNew || !SocialRelationModelImpl.COLUMN_BITMASK_ENABLED) {
528 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
529 }
530 else {
531 if ((socialRelationModelImpl.getColumnBitmask() &
532 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
533 Object[] args = new Object[] {
534 socialRelationModelImpl.getOriginalUuid()
535 };
536
537 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
538 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
539 args);
540
541 args = new Object[] { socialRelationModelImpl.getUuid() };
542
543 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
544 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
545 args);
546 }
547
548 if ((socialRelationModelImpl.getColumnBitmask() &
549 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
550 Object[] args = new Object[] {
551 Long.valueOf(socialRelationModelImpl.getOriginalCompanyId())
552 };
553
554 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
555 args);
556 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
557 args);
558
559 args = new Object[] {
560 Long.valueOf(socialRelationModelImpl.getCompanyId())
561 };
562
563 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
564 args);
565 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
566 args);
567 }
568
569 if ((socialRelationModelImpl.getColumnBitmask() &
570 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1.getColumnBitmask()) != 0) {
571 Object[] args = new Object[] {
572 Long.valueOf(socialRelationModelImpl.getOriginalUserId1())
573 };
574
575 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID1, args);
576 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1,
577 args);
578
579 args = new Object[] {
580 Long.valueOf(socialRelationModelImpl.getUserId1())
581 };
582
583 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID1, args);
584 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1,
585 args);
586 }
587
588 if ((socialRelationModelImpl.getColumnBitmask() &
589 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2.getColumnBitmask()) != 0) {
590 Object[] args = new Object[] {
591 Long.valueOf(socialRelationModelImpl.getOriginalUserId2())
592 };
593
594 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID2, args);
595 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2,
596 args);
597
598 args = new Object[] {
599 Long.valueOf(socialRelationModelImpl.getUserId2())
600 };
601
602 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID2, args);
603 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2,
604 args);
605 }
606
607 if ((socialRelationModelImpl.getColumnBitmask() &
608 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE.getColumnBitmask()) != 0) {
609 Object[] args = new Object[] {
610 Integer.valueOf(socialRelationModelImpl.getOriginalType())
611 };
612
613 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
614 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE,
615 args);
616
617 args = new Object[] {
618 Integer.valueOf(socialRelationModelImpl.getType())
619 };
620
621 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
622 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE,
623 args);
624 }
625
626 if ((socialRelationModelImpl.getColumnBitmask() &
627 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T.getColumnBitmask()) != 0) {
628 Object[] args = new Object[] {
629 Long.valueOf(socialRelationModelImpl.getOriginalCompanyId()),
630 Integer.valueOf(socialRelationModelImpl.getOriginalType())
631 };
632
633 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
634 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
635 args);
636
637 args = new Object[] {
638 Long.valueOf(socialRelationModelImpl.getCompanyId()),
639 Integer.valueOf(socialRelationModelImpl.getType())
640 };
641
642 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
643 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
644 args);
645 }
646
647 if ((socialRelationModelImpl.getColumnBitmask() &
648 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2.getColumnBitmask()) != 0) {
649 Object[] args = new Object[] {
650 Long.valueOf(socialRelationModelImpl.getOriginalUserId1()),
651 Long.valueOf(socialRelationModelImpl.getOriginalUserId2())
652 };
653
654 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U1_U2, args);
655 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2,
656 args);
657
658 args = new Object[] {
659 Long.valueOf(socialRelationModelImpl.getUserId1()),
660 Long.valueOf(socialRelationModelImpl.getUserId2())
661 };
662
663 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U1_U2, args);
664 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2,
665 args);
666 }
667
668 if ((socialRelationModelImpl.getColumnBitmask() &
669 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T.getColumnBitmask()) != 0) {
670 Object[] args = new Object[] {
671 Long.valueOf(socialRelationModelImpl.getOriginalUserId1()),
672 Integer.valueOf(socialRelationModelImpl.getOriginalType())
673 };
674
675 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U1_T, args);
676 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T,
677 args);
678
679 args = new Object[] {
680 Long.valueOf(socialRelationModelImpl.getUserId1()),
681 Integer.valueOf(socialRelationModelImpl.getType())
682 };
683
684 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U1_T, args);
685 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T,
686 args);
687 }
688
689 if ((socialRelationModelImpl.getColumnBitmask() &
690 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T.getColumnBitmask()) != 0) {
691 Object[] args = new Object[] {
692 Long.valueOf(socialRelationModelImpl.getOriginalUserId2()),
693 Integer.valueOf(socialRelationModelImpl.getOriginalType())
694 };
695
696 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U2_T, args);
697 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T,
698 args);
699
700 args = new Object[] {
701 Long.valueOf(socialRelationModelImpl.getUserId2()),
702 Integer.valueOf(socialRelationModelImpl.getType())
703 };
704
705 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U2_T, args);
706 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T,
707 args);
708 }
709 }
710
711 EntityCacheUtil.putResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
712 SocialRelationImpl.class, socialRelation.getPrimaryKey(),
713 socialRelation);
714
715 if (isNew) {
716 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U1_U2_T,
717 new Object[] {
718 Long.valueOf(socialRelation.getUserId1()),
719 Long.valueOf(socialRelation.getUserId2()),
720 Integer.valueOf(socialRelation.getType())
721 }, socialRelation);
722 }
723 else {
724 if ((socialRelationModelImpl.getColumnBitmask() &
725 FINDER_PATH_FETCH_BY_U1_U2_T.getColumnBitmask()) != 0) {
726 Object[] args = new Object[] {
727 Long.valueOf(socialRelationModelImpl.getOriginalUserId1()),
728 Long.valueOf(socialRelationModelImpl.getOriginalUserId2()),
729 Integer.valueOf(socialRelationModelImpl.getOriginalType())
730 };
731
732 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U1_U2_T, args);
733 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U1_U2_T, args);
734
735 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U1_U2_T,
736 new Object[] {
737 Long.valueOf(socialRelation.getUserId1()),
738 Long.valueOf(socialRelation.getUserId2()),
739 Integer.valueOf(socialRelation.getType())
740 }, socialRelation);
741 }
742 }
743
744 return socialRelation;
745 }
746
747 protected SocialRelation toUnwrappedModel(SocialRelation socialRelation) {
748 if (socialRelation instanceof SocialRelationImpl) {
749 return socialRelation;
750 }
751
752 SocialRelationImpl socialRelationImpl = new SocialRelationImpl();
753
754 socialRelationImpl.setNew(socialRelation.isNew());
755 socialRelationImpl.setPrimaryKey(socialRelation.getPrimaryKey());
756
757 socialRelationImpl.setUuid(socialRelation.getUuid());
758 socialRelationImpl.setRelationId(socialRelation.getRelationId());
759 socialRelationImpl.setCompanyId(socialRelation.getCompanyId());
760 socialRelationImpl.setCreateDate(socialRelation.getCreateDate());
761 socialRelationImpl.setUserId1(socialRelation.getUserId1());
762 socialRelationImpl.setUserId2(socialRelation.getUserId2());
763 socialRelationImpl.setType(socialRelation.getType());
764
765 return socialRelationImpl;
766 }
767
768
776 @Override
777 public SocialRelation findByPrimaryKey(Serializable primaryKey)
778 throws NoSuchModelException, SystemException {
779 return findByPrimaryKey(((Long)primaryKey).longValue());
780 }
781
782
790 public SocialRelation findByPrimaryKey(long relationId)
791 throws NoSuchRelationException, SystemException {
792 SocialRelation socialRelation = fetchByPrimaryKey(relationId);
793
794 if (socialRelation == null) {
795 if (_log.isWarnEnabled()) {
796 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + relationId);
797 }
798
799 throw new NoSuchRelationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
800 relationId);
801 }
802
803 return socialRelation;
804 }
805
806
813 @Override
814 public SocialRelation fetchByPrimaryKey(Serializable primaryKey)
815 throws SystemException {
816 return fetchByPrimaryKey(((Long)primaryKey).longValue());
817 }
818
819
826 public SocialRelation fetchByPrimaryKey(long relationId)
827 throws SystemException {
828 SocialRelation socialRelation = (SocialRelation)EntityCacheUtil.getResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
829 SocialRelationImpl.class, relationId);
830
831 if (socialRelation == _nullSocialRelation) {
832 return null;
833 }
834
835 if (socialRelation == null) {
836 Session session = null;
837
838 boolean hasException = false;
839
840 try {
841 session = openSession();
842
843 socialRelation = (SocialRelation)session.get(SocialRelationImpl.class,
844 Long.valueOf(relationId));
845 }
846 catch (Exception e) {
847 hasException = true;
848
849 throw processException(e);
850 }
851 finally {
852 if (socialRelation != null) {
853 cacheResult(socialRelation);
854 }
855 else if (!hasException) {
856 EntityCacheUtil.putResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED,
857 SocialRelationImpl.class, relationId,
858 _nullSocialRelation);
859 }
860
861 closeSession(session);
862 }
863 }
864
865 return socialRelation;
866 }
867
868
875 public List<SocialRelation> findByUuid(String uuid)
876 throws SystemException {
877 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
878 }
879
880
893 public List<SocialRelation> findByUuid(String uuid, int start, int end)
894 throws SystemException {
895 return findByUuid(uuid, start, end, null);
896 }
897
898
912 public List<SocialRelation> findByUuid(String uuid, int start, int end,
913 OrderByComparator orderByComparator) throws SystemException {
914 FinderPath finderPath = null;
915 Object[] finderArgs = null;
916
917 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
918 (orderByComparator == null)) {
919 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
920 finderArgs = new Object[] { uuid };
921 }
922 else {
923 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
924 finderArgs = new Object[] { uuid, start, end, orderByComparator };
925 }
926
927 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
928 finderArgs, this);
929
930 if ((list != null) && !list.isEmpty()) {
931 for (SocialRelation socialRelation : list) {
932 if (!Validator.equals(uuid, socialRelation.getUuid())) {
933 list = null;
934
935 break;
936 }
937 }
938 }
939
940 if (list == null) {
941 StringBundler query = null;
942
943 if (orderByComparator != null) {
944 query = new StringBundler(3 +
945 (orderByComparator.getOrderByFields().length * 3));
946 }
947 else {
948 query = new StringBundler(2);
949 }
950
951 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
952
953 if (uuid == null) {
954 query.append(_FINDER_COLUMN_UUID_UUID_1);
955 }
956 else {
957 if (uuid.equals(StringPool.BLANK)) {
958 query.append(_FINDER_COLUMN_UUID_UUID_3);
959 }
960 else {
961 query.append(_FINDER_COLUMN_UUID_UUID_2);
962 }
963 }
964
965 if (orderByComparator != null) {
966 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
967 orderByComparator);
968 }
969
970 String sql = query.toString();
971
972 Session session = null;
973
974 try {
975 session = openSession();
976
977 Query q = session.createQuery(sql);
978
979 QueryPos qPos = QueryPos.getInstance(q);
980
981 if (uuid != null) {
982 qPos.add(uuid);
983 }
984
985 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
986 start, end);
987 }
988 catch (Exception e) {
989 throw processException(e);
990 }
991 finally {
992 if (list == null) {
993 FinderCacheUtil.removeResult(finderPath, finderArgs);
994 }
995 else {
996 cacheResult(list);
997
998 FinderCacheUtil.putResult(finderPath, finderArgs, list);
999 }
1000
1001 closeSession(session);
1002 }
1003 }
1004
1005 return list;
1006 }
1007
1008
1021 public SocialRelation findByUuid_First(String uuid,
1022 OrderByComparator orderByComparator)
1023 throws NoSuchRelationException, SystemException {
1024 List<SocialRelation> list = findByUuid(uuid, 0, 1, orderByComparator);
1025
1026 if (list.isEmpty()) {
1027 StringBundler msg = new StringBundler(4);
1028
1029 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1030
1031 msg.append("uuid=");
1032 msg.append(uuid);
1033
1034 msg.append(StringPool.CLOSE_CURLY_BRACE);
1035
1036 throw new NoSuchRelationException(msg.toString());
1037 }
1038 else {
1039 return list.get(0);
1040 }
1041 }
1042
1043
1056 public SocialRelation findByUuid_Last(String uuid,
1057 OrderByComparator orderByComparator)
1058 throws NoSuchRelationException, SystemException {
1059 int count = countByUuid(uuid);
1060
1061 List<SocialRelation> list = findByUuid(uuid, count - 1, count,
1062 orderByComparator);
1063
1064 if (list.isEmpty()) {
1065 StringBundler msg = new StringBundler(4);
1066
1067 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1068
1069 msg.append("uuid=");
1070 msg.append(uuid);
1071
1072 msg.append(StringPool.CLOSE_CURLY_BRACE);
1073
1074 throw new NoSuchRelationException(msg.toString());
1075 }
1076 else {
1077 return list.get(0);
1078 }
1079 }
1080
1081
1095 public SocialRelation[] findByUuid_PrevAndNext(long relationId,
1096 String uuid, OrderByComparator orderByComparator)
1097 throws NoSuchRelationException, SystemException {
1098 SocialRelation socialRelation = findByPrimaryKey(relationId);
1099
1100 Session session = null;
1101
1102 try {
1103 session = openSession();
1104
1105 SocialRelation[] array = new SocialRelationImpl[3];
1106
1107 array[0] = getByUuid_PrevAndNext(session, socialRelation, uuid,
1108 orderByComparator, true);
1109
1110 array[1] = socialRelation;
1111
1112 array[2] = getByUuid_PrevAndNext(session, socialRelation, uuid,
1113 orderByComparator, false);
1114
1115 return array;
1116 }
1117 catch (Exception e) {
1118 throw processException(e);
1119 }
1120 finally {
1121 closeSession(session);
1122 }
1123 }
1124
1125 protected SocialRelation getByUuid_PrevAndNext(Session session,
1126 SocialRelation socialRelation, String uuid,
1127 OrderByComparator orderByComparator, boolean previous) {
1128 StringBundler query = null;
1129
1130 if (orderByComparator != null) {
1131 query = new StringBundler(6 +
1132 (orderByComparator.getOrderByFields().length * 6));
1133 }
1134 else {
1135 query = new StringBundler(3);
1136 }
1137
1138 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
1139
1140 if (uuid == null) {
1141 query.append(_FINDER_COLUMN_UUID_UUID_1);
1142 }
1143 else {
1144 if (uuid.equals(StringPool.BLANK)) {
1145 query.append(_FINDER_COLUMN_UUID_UUID_3);
1146 }
1147 else {
1148 query.append(_FINDER_COLUMN_UUID_UUID_2);
1149 }
1150 }
1151
1152 if (orderByComparator != null) {
1153 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1154
1155 if (orderByConditionFields.length > 0) {
1156 query.append(WHERE_AND);
1157 }
1158
1159 for (int i = 0; i < orderByConditionFields.length; i++) {
1160 query.append(_ORDER_BY_ENTITY_ALIAS);
1161 query.append(orderByConditionFields[i]);
1162
1163 if ((i + 1) < orderByConditionFields.length) {
1164 if (orderByComparator.isAscending() ^ previous) {
1165 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1166 }
1167 else {
1168 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1169 }
1170 }
1171 else {
1172 if (orderByComparator.isAscending() ^ previous) {
1173 query.append(WHERE_GREATER_THAN);
1174 }
1175 else {
1176 query.append(WHERE_LESSER_THAN);
1177 }
1178 }
1179 }
1180
1181 query.append(ORDER_BY_CLAUSE);
1182
1183 String[] orderByFields = orderByComparator.getOrderByFields();
1184
1185 for (int i = 0; i < orderByFields.length; i++) {
1186 query.append(_ORDER_BY_ENTITY_ALIAS);
1187 query.append(orderByFields[i]);
1188
1189 if ((i + 1) < orderByFields.length) {
1190 if (orderByComparator.isAscending() ^ previous) {
1191 query.append(ORDER_BY_ASC_HAS_NEXT);
1192 }
1193 else {
1194 query.append(ORDER_BY_DESC_HAS_NEXT);
1195 }
1196 }
1197 else {
1198 if (orderByComparator.isAscending() ^ previous) {
1199 query.append(ORDER_BY_ASC);
1200 }
1201 else {
1202 query.append(ORDER_BY_DESC);
1203 }
1204 }
1205 }
1206 }
1207
1208 String sql = query.toString();
1209
1210 Query q = session.createQuery(sql);
1211
1212 q.setFirstResult(0);
1213 q.setMaxResults(2);
1214
1215 QueryPos qPos = QueryPos.getInstance(q);
1216
1217 if (uuid != null) {
1218 qPos.add(uuid);
1219 }
1220
1221 if (orderByComparator != null) {
1222 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
1223
1224 for (Object value : values) {
1225 qPos.add(value);
1226 }
1227 }
1228
1229 List<SocialRelation> list = q.list();
1230
1231 if (list.size() == 2) {
1232 return list.get(1);
1233 }
1234 else {
1235 return null;
1236 }
1237 }
1238
1239
1246 public List<SocialRelation> findByCompanyId(long companyId)
1247 throws SystemException {
1248 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1249 null);
1250 }
1251
1252
1265 public List<SocialRelation> findByCompanyId(long companyId, int start,
1266 int end) throws SystemException {
1267 return findByCompanyId(companyId, start, end, null);
1268 }
1269
1270
1284 public List<SocialRelation> findByCompanyId(long companyId, int start,
1285 int end, OrderByComparator orderByComparator) throws SystemException {
1286 FinderPath finderPath = null;
1287 Object[] finderArgs = null;
1288
1289 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1290 (orderByComparator == null)) {
1291 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1292 finderArgs = new Object[] { companyId };
1293 }
1294 else {
1295 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1296 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1297 }
1298
1299 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
1300 finderArgs, this);
1301
1302 if ((list != null) && !list.isEmpty()) {
1303 for (SocialRelation socialRelation : list) {
1304 if ((companyId != socialRelation.getCompanyId())) {
1305 list = null;
1306
1307 break;
1308 }
1309 }
1310 }
1311
1312 if (list == null) {
1313 StringBundler query = null;
1314
1315 if (orderByComparator != null) {
1316 query = new StringBundler(3 +
1317 (orderByComparator.getOrderByFields().length * 3));
1318 }
1319 else {
1320 query = new StringBundler(2);
1321 }
1322
1323 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
1324
1325 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1326
1327 if (orderByComparator != null) {
1328 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1329 orderByComparator);
1330 }
1331
1332 String sql = query.toString();
1333
1334 Session session = null;
1335
1336 try {
1337 session = openSession();
1338
1339 Query q = session.createQuery(sql);
1340
1341 QueryPos qPos = QueryPos.getInstance(q);
1342
1343 qPos.add(companyId);
1344
1345 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
1346 start, end);
1347 }
1348 catch (Exception e) {
1349 throw processException(e);
1350 }
1351 finally {
1352 if (list == null) {
1353 FinderCacheUtil.removeResult(finderPath, finderArgs);
1354 }
1355 else {
1356 cacheResult(list);
1357
1358 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1359 }
1360
1361 closeSession(session);
1362 }
1363 }
1364
1365 return list;
1366 }
1367
1368
1381 public SocialRelation findByCompanyId_First(long companyId,
1382 OrderByComparator orderByComparator)
1383 throws NoSuchRelationException, SystemException {
1384 List<SocialRelation> list = findByCompanyId(companyId, 0, 1,
1385 orderByComparator);
1386
1387 if (list.isEmpty()) {
1388 StringBundler msg = new StringBundler(4);
1389
1390 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1391
1392 msg.append("companyId=");
1393 msg.append(companyId);
1394
1395 msg.append(StringPool.CLOSE_CURLY_BRACE);
1396
1397 throw new NoSuchRelationException(msg.toString());
1398 }
1399 else {
1400 return list.get(0);
1401 }
1402 }
1403
1404
1417 public SocialRelation findByCompanyId_Last(long companyId,
1418 OrderByComparator orderByComparator)
1419 throws NoSuchRelationException, SystemException {
1420 int count = countByCompanyId(companyId);
1421
1422 List<SocialRelation> list = findByCompanyId(companyId, count - 1,
1423 count, orderByComparator);
1424
1425 if (list.isEmpty()) {
1426 StringBundler msg = new StringBundler(4);
1427
1428 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1429
1430 msg.append("companyId=");
1431 msg.append(companyId);
1432
1433 msg.append(StringPool.CLOSE_CURLY_BRACE);
1434
1435 throw new NoSuchRelationException(msg.toString());
1436 }
1437 else {
1438 return list.get(0);
1439 }
1440 }
1441
1442
1456 public SocialRelation[] findByCompanyId_PrevAndNext(long relationId,
1457 long companyId, OrderByComparator orderByComparator)
1458 throws NoSuchRelationException, SystemException {
1459 SocialRelation socialRelation = findByPrimaryKey(relationId);
1460
1461 Session session = null;
1462
1463 try {
1464 session = openSession();
1465
1466 SocialRelation[] array = new SocialRelationImpl[3];
1467
1468 array[0] = getByCompanyId_PrevAndNext(session, socialRelation,
1469 companyId, orderByComparator, true);
1470
1471 array[1] = socialRelation;
1472
1473 array[2] = getByCompanyId_PrevAndNext(session, socialRelation,
1474 companyId, orderByComparator, false);
1475
1476 return array;
1477 }
1478 catch (Exception e) {
1479 throw processException(e);
1480 }
1481 finally {
1482 closeSession(session);
1483 }
1484 }
1485
1486 protected SocialRelation getByCompanyId_PrevAndNext(Session session,
1487 SocialRelation socialRelation, long companyId,
1488 OrderByComparator orderByComparator, boolean previous) {
1489 StringBundler query = null;
1490
1491 if (orderByComparator != null) {
1492 query = new StringBundler(6 +
1493 (orderByComparator.getOrderByFields().length * 6));
1494 }
1495 else {
1496 query = new StringBundler(3);
1497 }
1498
1499 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
1500
1501 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1502
1503 if (orderByComparator != null) {
1504 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1505
1506 if (orderByConditionFields.length > 0) {
1507 query.append(WHERE_AND);
1508 }
1509
1510 for (int i = 0; i < orderByConditionFields.length; i++) {
1511 query.append(_ORDER_BY_ENTITY_ALIAS);
1512 query.append(orderByConditionFields[i]);
1513
1514 if ((i + 1) < orderByConditionFields.length) {
1515 if (orderByComparator.isAscending() ^ previous) {
1516 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1517 }
1518 else {
1519 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1520 }
1521 }
1522 else {
1523 if (orderByComparator.isAscending() ^ previous) {
1524 query.append(WHERE_GREATER_THAN);
1525 }
1526 else {
1527 query.append(WHERE_LESSER_THAN);
1528 }
1529 }
1530 }
1531
1532 query.append(ORDER_BY_CLAUSE);
1533
1534 String[] orderByFields = orderByComparator.getOrderByFields();
1535
1536 for (int i = 0; i < orderByFields.length; i++) {
1537 query.append(_ORDER_BY_ENTITY_ALIAS);
1538 query.append(orderByFields[i]);
1539
1540 if ((i + 1) < orderByFields.length) {
1541 if (orderByComparator.isAscending() ^ previous) {
1542 query.append(ORDER_BY_ASC_HAS_NEXT);
1543 }
1544 else {
1545 query.append(ORDER_BY_DESC_HAS_NEXT);
1546 }
1547 }
1548 else {
1549 if (orderByComparator.isAscending() ^ previous) {
1550 query.append(ORDER_BY_ASC);
1551 }
1552 else {
1553 query.append(ORDER_BY_DESC);
1554 }
1555 }
1556 }
1557 }
1558
1559 String sql = query.toString();
1560
1561 Query q = session.createQuery(sql);
1562
1563 q.setFirstResult(0);
1564 q.setMaxResults(2);
1565
1566 QueryPos qPos = QueryPos.getInstance(q);
1567
1568 qPos.add(companyId);
1569
1570 if (orderByComparator != null) {
1571 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
1572
1573 for (Object value : values) {
1574 qPos.add(value);
1575 }
1576 }
1577
1578 List<SocialRelation> list = q.list();
1579
1580 if (list.size() == 2) {
1581 return list.get(1);
1582 }
1583 else {
1584 return null;
1585 }
1586 }
1587
1588
1595 public List<SocialRelation> findByUserId1(long userId1)
1596 throws SystemException {
1597 return findByUserId1(userId1, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1598 }
1599
1600
1613 public List<SocialRelation> findByUserId1(long userId1, int start, int end)
1614 throws SystemException {
1615 return findByUserId1(userId1, start, end, null);
1616 }
1617
1618
1632 public List<SocialRelation> findByUserId1(long userId1, int start, int end,
1633 OrderByComparator orderByComparator) throws SystemException {
1634 FinderPath finderPath = null;
1635 Object[] finderArgs = null;
1636
1637 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1638 (orderByComparator == null)) {
1639 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1;
1640 finderArgs = new Object[] { userId1 };
1641 }
1642 else {
1643 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID1;
1644 finderArgs = new Object[] { userId1, start, end, orderByComparator };
1645 }
1646
1647 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
1648 finderArgs, this);
1649
1650 if ((list != null) && !list.isEmpty()) {
1651 for (SocialRelation socialRelation : list) {
1652 if ((userId1 != socialRelation.getUserId1())) {
1653 list = null;
1654
1655 break;
1656 }
1657 }
1658 }
1659
1660 if (list == null) {
1661 StringBundler query = null;
1662
1663 if (orderByComparator != null) {
1664 query = new StringBundler(3 +
1665 (orderByComparator.getOrderByFields().length * 3));
1666 }
1667 else {
1668 query = new StringBundler(2);
1669 }
1670
1671 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
1672
1673 query.append(_FINDER_COLUMN_USERID1_USERID1_2);
1674
1675 if (orderByComparator != null) {
1676 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1677 orderByComparator);
1678 }
1679
1680 String sql = query.toString();
1681
1682 Session session = null;
1683
1684 try {
1685 session = openSession();
1686
1687 Query q = session.createQuery(sql);
1688
1689 QueryPos qPos = QueryPos.getInstance(q);
1690
1691 qPos.add(userId1);
1692
1693 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
1694 start, end);
1695 }
1696 catch (Exception e) {
1697 throw processException(e);
1698 }
1699 finally {
1700 if (list == null) {
1701 FinderCacheUtil.removeResult(finderPath, finderArgs);
1702 }
1703 else {
1704 cacheResult(list);
1705
1706 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1707 }
1708
1709 closeSession(session);
1710 }
1711 }
1712
1713 return list;
1714 }
1715
1716
1729 public SocialRelation findByUserId1_First(long userId1,
1730 OrderByComparator orderByComparator)
1731 throws NoSuchRelationException, SystemException {
1732 List<SocialRelation> list = findByUserId1(userId1, 0, 1,
1733 orderByComparator);
1734
1735 if (list.isEmpty()) {
1736 StringBundler msg = new StringBundler(4);
1737
1738 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1739
1740 msg.append("userId1=");
1741 msg.append(userId1);
1742
1743 msg.append(StringPool.CLOSE_CURLY_BRACE);
1744
1745 throw new NoSuchRelationException(msg.toString());
1746 }
1747 else {
1748 return list.get(0);
1749 }
1750 }
1751
1752
1765 public SocialRelation findByUserId1_Last(long userId1,
1766 OrderByComparator orderByComparator)
1767 throws NoSuchRelationException, SystemException {
1768 int count = countByUserId1(userId1);
1769
1770 List<SocialRelation> list = findByUserId1(userId1, count - 1, count,
1771 orderByComparator);
1772
1773 if (list.isEmpty()) {
1774 StringBundler msg = new StringBundler(4);
1775
1776 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1777
1778 msg.append("userId1=");
1779 msg.append(userId1);
1780
1781 msg.append(StringPool.CLOSE_CURLY_BRACE);
1782
1783 throw new NoSuchRelationException(msg.toString());
1784 }
1785 else {
1786 return list.get(0);
1787 }
1788 }
1789
1790
1804 public SocialRelation[] findByUserId1_PrevAndNext(long relationId,
1805 long userId1, OrderByComparator orderByComparator)
1806 throws NoSuchRelationException, SystemException {
1807 SocialRelation socialRelation = findByPrimaryKey(relationId);
1808
1809 Session session = null;
1810
1811 try {
1812 session = openSession();
1813
1814 SocialRelation[] array = new SocialRelationImpl[3];
1815
1816 array[0] = getByUserId1_PrevAndNext(session, socialRelation,
1817 userId1, orderByComparator, true);
1818
1819 array[1] = socialRelation;
1820
1821 array[2] = getByUserId1_PrevAndNext(session, socialRelation,
1822 userId1, orderByComparator, false);
1823
1824 return array;
1825 }
1826 catch (Exception e) {
1827 throw processException(e);
1828 }
1829 finally {
1830 closeSession(session);
1831 }
1832 }
1833
1834 protected SocialRelation getByUserId1_PrevAndNext(Session session,
1835 SocialRelation socialRelation, long userId1,
1836 OrderByComparator orderByComparator, boolean previous) {
1837 StringBundler query = null;
1838
1839 if (orderByComparator != null) {
1840 query = new StringBundler(6 +
1841 (orderByComparator.getOrderByFields().length * 6));
1842 }
1843 else {
1844 query = new StringBundler(3);
1845 }
1846
1847 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
1848
1849 query.append(_FINDER_COLUMN_USERID1_USERID1_2);
1850
1851 if (orderByComparator != null) {
1852 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1853
1854 if (orderByConditionFields.length > 0) {
1855 query.append(WHERE_AND);
1856 }
1857
1858 for (int i = 0; i < orderByConditionFields.length; i++) {
1859 query.append(_ORDER_BY_ENTITY_ALIAS);
1860 query.append(orderByConditionFields[i]);
1861
1862 if ((i + 1) < orderByConditionFields.length) {
1863 if (orderByComparator.isAscending() ^ previous) {
1864 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1865 }
1866 else {
1867 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1868 }
1869 }
1870 else {
1871 if (orderByComparator.isAscending() ^ previous) {
1872 query.append(WHERE_GREATER_THAN);
1873 }
1874 else {
1875 query.append(WHERE_LESSER_THAN);
1876 }
1877 }
1878 }
1879
1880 query.append(ORDER_BY_CLAUSE);
1881
1882 String[] orderByFields = orderByComparator.getOrderByFields();
1883
1884 for (int i = 0; i < orderByFields.length; i++) {
1885 query.append(_ORDER_BY_ENTITY_ALIAS);
1886 query.append(orderByFields[i]);
1887
1888 if ((i + 1) < orderByFields.length) {
1889 if (orderByComparator.isAscending() ^ previous) {
1890 query.append(ORDER_BY_ASC_HAS_NEXT);
1891 }
1892 else {
1893 query.append(ORDER_BY_DESC_HAS_NEXT);
1894 }
1895 }
1896 else {
1897 if (orderByComparator.isAscending() ^ previous) {
1898 query.append(ORDER_BY_ASC);
1899 }
1900 else {
1901 query.append(ORDER_BY_DESC);
1902 }
1903 }
1904 }
1905 }
1906
1907 String sql = query.toString();
1908
1909 Query q = session.createQuery(sql);
1910
1911 q.setFirstResult(0);
1912 q.setMaxResults(2);
1913
1914 QueryPos qPos = QueryPos.getInstance(q);
1915
1916 qPos.add(userId1);
1917
1918 if (orderByComparator != null) {
1919 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
1920
1921 for (Object value : values) {
1922 qPos.add(value);
1923 }
1924 }
1925
1926 List<SocialRelation> list = q.list();
1927
1928 if (list.size() == 2) {
1929 return list.get(1);
1930 }
1931 else {
1932 return null;
1933 }
1934 }
1935
1936
1943 public List<SocialRelation> findByUserId2(long userId2)
1944 throws SystemException {
1945 return findByUserId2(userId2, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1946 }
1947
1948
1961 public List<SocialRelation> findByUserId2(long userId2, int start, int end)
1962 throws SystemException {
1963 return findByUserId2(userId2, start, end, null);
1964 }
1965
1966
1980 public List<SocialRelation> findByUserId2(long userId2, int start, int end,
1981 OrderByComparator orderByComparator) throws SystemException {
1982 FinderPath finderPath = null;
1983 Object[] finderArgs = null;
1984
1985 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1986 (orderByComparator == null)) {
1987 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2;
1988 finderArgs = new Object[] { userId2 };
1989 }
1990 else {
1991 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID2;
1992 finderArgs = new Object[] { userId2, start, end, orderByComparator };
1993 }
1994
1995 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
1996 finderArgs, this);
1997
1998 if ((list != null) && !list.isEmpty()) {
1999 for (SocialRelation socialRelation : list) {
2000 if ((userId2 != socialRelation.getUserId2())) {
2001 list = null;
2002
2003 break;
2004 }
2005 }
2006 }
2007
2008 if (list == null) {
2009 StringBundler query = null;
2010
2011 if (orderByComparator != null) {
2012 query = new StringBundler(3 +
2013 (orderByComparator.getOrderByFields().length * 3));
2014 }
2015 else {
2016 query = new StringBundler(2);
2017 }
2018
2019 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
2020
2021 query.append(_FINDER_COLUMN_USERID2_USERID2_2);
2022
2023 if (orderByComparator != null) {
2024 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2025 orderByComparator);
2026 }
2027
2028 String sql = query.toString();
2029
2030 Session session = null;
2031
2032 try {
2033 session = openSession();
2034
2035 Query q = session.createQuery(sql);
2036
2037 QueryPos qPos = QueryPos.getInstance(q);
2038
2039 qPos.add(userId2);
2040
2041 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
2042 start, end);
2043 }
2044 catch (Exception e) {
2045 throw processException(e);
2046 }
2047 finally {
2048 if (list == null) {
2049 FinderCacheUtil.removeResult(finderPath, finderArgs);
2050 }
2051 else {
2052 cacheResult(list);
2053
2054 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2055 }
2056
2057 closeSession(session);
2058 }
2059 }
2060
2061 return list;
2062 }
2063
2064
2077 public SocialRelation findByUserId2_First(long userId2,
2078 OrderByComparator orderByComparator)
2079 throws NoSuchRelationException, SystemException {
2080 List<SocialRelation> list = findByUserId2(userId2, 0, 1,
2081 orderByComparator);
2082
2083 if (list.isEmpty()) {
2084 StringBundler msg = new StringBundler(4);
2085
2086 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2087
2088 msg.append("userId2=");
2089 msg.append(userId2);
2090
2091 msg.append(StringPool.CLOSE_CURLY_BRACE);
2092
2093 throw new NoSuchRelationException(msg.toString());
2094 }
2095 else {
2096 return list.get(0);
2097 }
2098 }
2099
2100
2113 public SocialRelation findByUserId2_Last(long userId2,
2114 OrderByComparator orderByComparator)
2115 throws NoSuchRelationException, SystemException {
2116 int count = countByUserId2(userId2);
2117
2118 List<SocialRelation> list = findByUserId2(userId2, count - 1, count,
2119 orderByComparator);
2120
2121 if (list.isEmpty()) {
2122 StringBundler msg = new StringBundler(4);
2123
2124 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2125
2126 msg.append("userId2=");
2127 msg.append(userId2);
2128
2129 msg.append(StringPool.CLOSE_CURLY_BRACE);
2130
2131 throw new NoSuchRelationException(msg.toString());
2132 }
2133 else {
2134 return list.get(0);
2135 }
2136 }
2137
2138
2152 public SocialRelation[] findByUserId2_PrevAndNext(long relationId,
2153 long userId2, OrderByComparator orderByComparator)
2154 throws NoSuchRelationException, SystemException {
2155 SocialRelation socialRelation = findByPrimaryKey(relationId);
2156
2157 Session session = null;
2158
2159 try {
2160 session = openSession();
2161
2162 SocialRelation[] array = new SocialRelationImpl[3];
2163
2164 array[0] = getByUserId2_PrevAndNext(session, socialRelation,
2165 userId2, orderByComparator, true);
2166
2167 array[1] = socialRelation;
2168
2169 array[2] = getByUserId2_PrevAndNext(session, socialRelation,
2170 userId2, orderByComparator, false);
2171
2172 return array;
2173 }
2174 catch (Exception e) {
2175 throw processException(e);
2176 }
2177 finally {
2178 closeSession(session);
2179 }
2180 }
2181
2182 protected SocialRelation getByUserId2_PrevAndNext(Session session,
2183 SocialRelation socialRelation, long userId2,
2184 OrderByComparator orderByComparator, boolean previous) {
2185 StringBundler query = null;
2186
2187 if (orderByComparator != null) {
2188 query = new StringBundler(6 +
2189 (orderByComparator.getOrderByFields().length * 6));
2190 }
2191 else {
2192 query = new StringBundler(3);
2193 }
2194
2195 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
2196
2197 query.append(_FINDER_COLUMN_USERID2_USERID2_2);
2198
2199 if (orderByComparator != null) {
2200 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2201
2202 if (orderByConditionFields.length > 0) {
2203 query.append(WHERE_AND);
2204 }
2205
2206 for (int i = 0; i < orderByConditionFields.length; i++) {
2207 query.append(_ORDER_BY_ENTITY_ALIAS);
2208 query.append(orderByConditionFields[i]);
2209
2210 if ((i + 1) < orderByConditionFields.length) {
2211 if (orderByComparator.isAscending() ^ previous) {
2212 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2213 }
2214 else {
2215 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2216 }
2217 }
2218 else {
2219 if (orderByComparator.isAscending() ^ previous) {
2220 query.append(WHERE_GREATER_THAN);
2221 }
2222 else {
2223 query.append(WHERE_LESSER_THAN);
2224 }
2225 }
2226 }
2227
2228 query.append(ORDER_BY_CLAUSE);
2229
2230 String[] orderByFields = orderByComparator.getOrderByFields();
2231
2232 for (int i = 0; i < orderByFields.length; i++) {
2233 query.append(_ORDER_BY_ENTITY_ALIAS);
2234 query.append(orderByFields[i]);
2235
2236 if ((i + 1) < orderByFields.length) {
2237 if (orderByComparator.isAscending() ^ previous) {
2238 query.append(ORDER_BY_ASC_HAS_NEXT);
2239 }
2240 else {
2241 query.append(ORDER_BY_DESC_HAS_NEXT);
2242 }
2243 }
2244 else {
2245 if (orderByComparator.isAscending() ^ previous) {
2246 query.append(ORDER_BY_ASC);
2247 }
2248 else {
2249 query.append(ORDER_BY_DESC);
2250 }
2251 }
2252 }
2253 }
2254
2255 String sql = query.toString();
2256
2257 Query q = session.createQuery(sql);
2258
2259 q.setFirstResult(0);
2260 q.setMaxResults(2);
2261
2262 QueryPos qPos = QueryPos.getInstance(q);
2263
2264 qPos.add(userId2);
2265
2266 if (orderByComparator != null) {
2267 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
2268
2269 for (Object value : values) {
2270 qPos.add(value);
2271 }
2272 }
2273
2274 List<SocialRelation> list = q.list();
2275
2276 if (list.size() == 2) {
2277 return list.get(1);
2278 }
2279 else {
2280 return null;
2281 }
2282 }
2283
2284
2291 public List<SocialRelation> findByType(int type) throws SystemException {
2292 return findByType(type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2293 }
2294
2295
2308 public List<SocialRelation> findByType(int type, int start, int end)
2309 throws SystemException {
2310 return findByType(type, start, end, null);
2311 }
2312
2313
2327 public List<SocialRelation> findByType(int type, int start, int end,
2328 OrderByComparator orderByComparator) throws SystemException {
2329 FinderPath finderPath = null;
2330 Object[] finderArgs = null;
2331
2332 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2333 (orderByComparator == null)) {
2334 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE;
2335 finderArgs = new Object[] { type };
2336 }
2337 else {
2338 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE;
2339 finderArgs = new Object[] { type, start, end, orderByComparator };
2340 }
2341
2342 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
2343 finderArgs, this);
2344
2345 if ((list != null) && !list.isEmpty()) {
2346 for (SocialRelation socialRelation : list) {
2347 if ((type != socialRelation.getType())) {
2348 list = null;
2349
2350 break;
2351 }
2352 }
2353 }
2354
2355 if (list == null) {
2356 StringBundler query = null;
2357
2358 if (orderByComparator != null) {
2359 query = new StringBundler(3 +
2360 (orderByComparator.getOrderByFields().length * 3));
2361 }
2362 else {
2363 query = new StringBundler(2);
2364 }
2365
2366 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
2367
2368 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
2369
2370 if (orderByComparator != null) {
2371 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2372 orderByComparator);
2373 }
2374
2375 String sql = query.toString();
2376
2377 Session session = null;
2378
2379 try {
2380 session = openSession();
2381
2382 Query q = session.createQuery(sql);
2383
2384 QueryPos qPos = QueryPos.getInstance(q);
2385
2386 qPos.add(type);
2387
2388 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
2389 start, end);
2390 }
2391 catch (Exception e) {
2392 throw processException(e);
2393 }
2394 finally {
2395 if (list == null) {
2396 FinderCacheUtil.removeResult(finderPath, finderArgs);
2397 }
2398 else {
2399 cacheResult(list);
2400
2401 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2402 }
2403
2404 closeSession(session);
2405 }
2406 }
2407
2408 return list;
2409 }
2410
2411
2424 public SocialRelation findByType_First(int type,
2425 OrderByComparator orderByComparator)
2426 throws NoSuchRelationException, SystemException {
2427 List<SocialRelation> list = findByType(type, 0, 1, orderByComparator);
2428
2429 if (list.isEmpty()) {
2430 StringBundler msg = new StringBundler(4);
2431
2432 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2433
2434 msg.append("type=");
2435 msg.append(type);
2436
2437 msg.append(StringPool.CLOSE_CURLY_BRACE);
2438
2439 throw new NoSuchRelationException(msg.toString());
2440 }
2441 else {
2442 return list.get(0);
2443 }
2444 }
2445
2446
2459 public SocialRelation findByType_Last(int type,
2460 OrderByComparator orderByComparator)
2461 throws NoSuchRelationException, SystemException {
2462 int count = countByType(type);
2463
2464 List<SocialRelation> list = findByType(type, count - 1, count,
2465 orderByComparator);
2466
2467 if (list.isEmpty()) {
2468 StringBundler msg = new StringBundler(4);
2469
2470 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2471
2472 msg.append("type=");
2473 msg.append(type);
2474
2475 msg.append(StringPool.CLOSE_CURLY_BRACE);
2476
2477 throw new NoSuchRelationException(msg.toString());
2478 }
2479 else {
2480 return list.get(0);
2481 }
2482 }
2483
2484
2498 public SocialRelation[] findByType_PrevAndNext(long relationId, int type,
2499 OrderByComparator orderByComparator)
2500 throws NoSuchRelationException, SystemException {
2501 SocialRelation socialRelation = findByPrimaryKey(relationId);
2502
2503 Session session = null;
2504
2505 try {
2506 session = openSession();
2507
2508 SocialRelation[] array = new SocialRelationImpl[3];
2509
2510 array[0] = getByType_PrevAndNext(session, socialRelation, type,
2511 orderByComparator, true);
2512
2513 array[1] = socialRelation;
2514
2515 array[2] = getByType_PrevAndNext(session, socialRelation, type,
2516 orderByComparator, false);
2517
2518 return array;
2519 }
2520 catch (Exception e) {
2521 throw processException(e);
2522 }
2523 finally {
2524 closeSession(session);
2525 }
2526 }
2527
2528 protected SocialRelation getByType_PrevAndNext(Session session,
2529 SocialRelation socialRelation, int type,
2530 OrderByComparator orderByComparator, boolean previous) {
2531 StringBundler query = null;
2532
2533 if (orderByComparator != null) {
2534 query = new StringBundler(6 +
2535 (orderByComparator.getOrderByFields().length * 6));
2536 }
2537 else {
2538 query = new StringBundler(3);
2539 }
2540
2541 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
2542
2543 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
2544
2545 if (orderByComparator != null) {
2546 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2547
2548 if (orderByConditionFields.length > 0) {
2549 query.append(WHERE_AND);
2550 }
2551
2552 for (int i = 0; i < orderByConditionFields.length; i++) {
2553 query.append(_ORDER_BY_ENTITY_ALIAS);
2554 query.append(orderByConditionFields[i]);
2555
2556 if ((i + 1) < orderByConditionFields.length) {
2557 if (orderByComparator.isAscending() ^ previous) {
2558 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2559 }
2560 else {
2561 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2562 }
2563 }
2564 else {
2565 if (orderByComparator.isAscending() ^ previous) {
2566 query.append(WHERE_GREATER_THAN);
2567 }
2568 else {
2569 query.append(WHERE_LESSER_THAN);
2570 }
2571 }
2572 }
2573
2574 query.append(ORDER_BY_CLAUSE);
2575
2576 String[] orderByFields = orderByComparator.getOrderByFields();
2577
2578 for (int i = 0; i < orderByFields.length; i++) {
2579 query.append(_ORDER_BY_ENTITY_ALIAS);
2580 query.append(orderByFields[i]);
2581
2582 if ((i + 1) < orderByFields.length) {
2583 if (orderByComparator.isAscending() ^ previous) {
2584 query.append(ORDER_BY_ASC_HAS_NEXT);
2585 }
2586 else {
2587 query.append(ORDER_BY_DESC_HAS_NEXT);
2588 }
2589 }
2590 else {
2591 if (orderByComparator.isAscending() ^ previous) {
2592 query.append(ORDER_BY_ASC);
2593 }
2594 else {
2595 query.append(ORDER_BY_DESC);
2596 }
2597 }
2598 }
2599 }
2600
2601 String sql = query.toString();
2602
2603 Query q = session.createQuery(sql);
2604
2605 q.setFirstResult(0);
2606 q.setMaxResults(2);
2607
2608 QueryPos qPos = QueryPos.getInstance(q);
2609
2610 qPos.add(type);
2611
2612 if (orderByComparator != null) {
2613 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
2614
2615 for (Object value : values) {
2616 qPos.add(value);
2617 }
2618 }
2619
2620 List<SocialRelation> list = q.list();
2621
2622 if (list.size() == 2) {
2623 return list.get(1);
2624 }
2625 else {
2626 return null;
2627 }
2628 }
2629
2630
2638 public List<SocialRelation> findByC_T(long companyId, int type)
2639 throws SystemException {
2640 return findByC_T(companyId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2641 null);
2642 }
2643
2644
2658 public List<SocialRelation> findByC_T(long companyId, int type, int start,
2659 int end) throws SystemException {
2660 return findByC_T(companyId, type, start, end, null);
2661 }
2662
2663
2678 public List<SocialRelation> findByC_T(long companyId, int type, int start,
2679 int end, OrderByComparator orderByComparator) throws SystemException {
2680 FinderPath finderPath = null;
2681 Object[] finderArgs = null;
2682
2683 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2684 (orderByComparator == null)) {
2685 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T;
2686 finderArgs = new Object[] { companyId, type };
2687 }
2688 else {
2689 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T;
2690 finderArgs = new Object[] {
2691 companyId, type,
2692
2693 start, end, orderByComparator
2694 };
2695 }
2696
2697 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
2698 finderArgs, this);
2699
2700 if ((list != null) && !list.isEmpty()) {
2701 for (SocialRelation socialRelation : list) {
2702 if ((companyId != socialRelation.getCompanyId()) ||
2703 (type != socialRelation.getType())) {
2704 list = null;
2705
2706 break;
2707 }
2708 }
2709 }
2710
2711 if (list == null) {
2712 StringBundler query = null;
2713
2714 if (orderByComparator != null) {
2715 query = new StringBundler(4 +
2716 (orderByComparator.getOrderByFields().length * 3));
2717 }
2718 else {
2719 query = new StringBundler(3);
2720 }
2721
2722 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
2723
2724 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
2725
2726 query.append(_FINDER_COLUMN_C_T_TYPE_2);
2727
2728 if (orderByComparator != null) {
2729 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2730 orderByComparator);
2731 }
2732
2733 String sql = query.toString();
2734
2735 Session session = null;
2736
2737 try {
2738 session = openSession();
2739
2740 Query q = session.createQuery(sql);
2741
2742 QueryPos qPos = QueryPos.getInstance(q);
2743
2744 qPos.add(companyId);
2745
2746 qPos.add(type);
2747
2748 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
2749 start, end);
2750 }
2751 catch (Exception e) {
2752 throw processException(e);
2753 }
2754 finally {
2755 if (list == null) {
2756 FinderCacheUtil.removeResult(finderPath, finderArgs);
2757 }
2758 else {
2759 cacheResult(list);
2760
2761 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2762 }
2763
2764 closeSession(session);
2765 }
2766 }
2767
2768 return list;
2769 }
2770
2771
2785 public SocialRelation findByC_T_First(long companyId, int type,
2786 OrderByComparator orderByComparator)
2787 throws NoSuchRelationException, SystemException {
2788 List<SocialRelation> list = findByC_T(companyId, type, 0, 1,
2789 orderByComparator);
2790
2791 if (list.isEmpty()) {
2792 StringBundler msg = new StringBundler(6);
2793
2794 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2795
2796 msg.append("companyId=");
2797 msg.append(companyId);
2798
2799 msg.append(", type=");
2800 msg.append(type);
2801
2802 msg.append(StringPool.CLOSE_CURLY_BRACE);
2803
2804 throw new NoSuchRelationException(msg.toString());
2805 }
2806 else {
2807 return list.get(0);
2808 }
2809 }
2810
2811
2825 public SocialRelation findByC_T_Last(long companyId, int type,
2826 OrderByComparator orderByComparator)
2827 throws NoSuchRelationException, SystemException {
2828 int count = countByC_T(companyId, type);
2829
2830 List<SocialRelation> list = findByC_T(companyId, type, count - 1,
2831 count, orderByComparator);
2832
2833 if (list.isEmpty()) {
2834 StringBundler msg = new StringBundler(6);
2835
2836 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2837
2838 msg.append("companyId=");
2839 msg.append(companyId);
2840
2841 msg.append(", type=");
2842 msg.append(type);
2843
2844 msg.append(StringPool.CLOSE_CURLY_BRACE);
2845
2846 throw new NoSuchRelationException(msg.toString());
2847 }
2848 else {
2849 return list.get(0);
2850 }
2851 }
2852
2853
2868 public SocialRelation[] findByC_T_PrevAndNext(long relationId,
2869 long companyId, int type, OrderByComparator orderByComparator)
2870 throws NoSuchRelationException, SystemException {
2871 SocialRelation socialRelation = findByPrimaryKey(relationId);
2872
2873 Session session = null;
2874
2875 try {
2876 session = openSession();
2877
2878 SocialRelation[] array = new SocialRelationImpl[3];
2879
2880 array[0] = getByC_T_PrevAndNext(session, socialRelation, companyId,
2881 type, orderByComparator, true);
2882
2883 array[1] = socialRelation;
2884
2885 array[2] = getByC_T_PrevAndNext(session, socialRelation, companyId,
2886 type, orderByComparator, false);
2887
2888 return array;
2889 }
2890 catch (Exception e) {
2891 throw processException(e);
2892 }
2893 finally {
2894 closeSession(session);
2895 }
2896 }
2897
2898 protected SocialRelation getByC_T_PrevAndNext(Session session,
2899 SocialRelation socialRelation, long companyId, int type,
2900 OrderByComparator orderByComparator, boolean previous) {
2901 StringBundler query = null;
2902
2903 if (orderByComparator != null) {
2904 query = new StringBundler(6 +
2905 (orderByComparator.getOrderByFields().length * 6));
2906 }
2907 else {
2908 query = new StringBundler(3);
2909 }
2910
2911 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
2912
2913 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
2914
2915 query.append(_FINDER_COLUMN_C_T_TYPE_2);
2916
2917 if (orderByComparator != null) {
2918 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2919
2920 if (orderByConditionFields.length > 0) {
2921 query.append(WHERE_AND);
2922 }
2923
2924 for (int i = 0; i < orderByConditionFields.length; i++) {
2925 query.append(_ORDER_BY_ENTITY_ALIAS);
2926 query.append(orderByConditionFields[i]);
2927
2928 if ((i + 1) < orderByConditionFields.length) {
2929 if (orderByComparator.isAscending() ^ previous) {
2930 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2931 }
2932 else {
2933 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2934 }
2935 }
2936 else {
2937 if (orderByComparator.isAscending() ^ previous) {
2938 query.append(WHERE_GREATER_THAN);
2939 }
2940 else {
2941 query.append(WHERE_LESSER_THAN);
2942 }
2943 }
2944 }
2945
2946 query.append(ORDER_BY_CLAUSE);
2947
2948 String[] orderByFields = orderByComparator.getOrderByFields();
2949
2950 for (int i = 0; i < orderByFields.length; i++) {
2951 query.append(_ORDER_BY_ENTITY_ALIAS);
2952 query.append(orderByFields[i]);
2953
2954 if ((i + 1) < orderByFields.length) {
2955 if (orderByComparator.isAscending() ^ previous) {
2956 query.append(ORDER_BY_ASC_HAS_NEXT);
2957 }
2958 else {
2959 query.append(ORDER_BY_DESC_HAS_NEXT);
2960 }
2961 }
2962 else {
2963 if (orderByComparator.isAscending() ^ previous) {
2964 query.append(ORDER_BY_ASC);
2965 }
2966 else {
2967 query.append(ORDER_BY_DESC);
2968 }
2969 }
2970 }
2971 }
2972
2973 String sql = query.toString();
2974
2975 Query q = session.createQuery(sql);
2976
2977 q.setFirstResult(0);
2978 q.setMaxResults(2);
2979
2980 QueryPos qPos = QueryPos.getInstance(q);
2981
2982 qPos.add(companyId);
2983
2984 qPos.add(type);
2985
2986 if (orderByComparator != null) {
2987 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
2988
2989 for (Object value : values) {
2990 qPos.add(value);
2991 }
2992 }
2993
2994 List<SocialRelation> list = q.list();
2995
2996 if (list.size() == 2) {
2997 return list.get(1);
2998 }
2999 else {
3000 return null;
3001 }
3002 }
3003
3004
3012 public List<SocialRelation> findByU1_U2(long userId1, long userId2)
3013 throws SystemException {
3014 return findByU1_U2(userId1, userId2, QueryUtil.ALL_POS,
3015 QueryUtil.ALL_POS, null);
3016 }
3017
3018
3032 public List<SocialRelation> findByU1_U2(long userId1, long userId2,
3033 int start, int end) throws SystemException {
3034 return findByU1_U2(userId1, userId2, start, end, null);
3035 }
3036
3037
3052 public List<SocialRelation> findByU1_U2(long userId1, long userId2,
3053 int start, int end, OrderByComparator orderByComparator)
3054 throws SystemException {
3055 FinderPath finderPath = null;
3056 Object[] finderArgs = null;
3057
3058 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3059 (orderByComparator == null)) {
3060 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2;
3061 finderArgs = new Object[] { userId1, userId2 };
3062 }
3063 else {
3064 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U1_U2;
3065 finderArgs = new Object[] {
3066 userId1, userId2,
3067
3068 start, end, orderByComparator
3069 };
3070 }
3071
3072 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
3073 finderArgs, this);
3074
3075 if ((list != null) && !list.isEmpty()) {
3076 for (SocialRelation socialRelation : list) {
3077 if ((userId1 != socialRelation.getUserId1()) ||
3078 (userId2 != socialRelation.getUserId2())) {
3079 list = null;
3080
3081 break;
3082 }
3083 }
3084 }
3085
3086 if (list == null) {
3087 StringBundler query = null;
3088
3089 if (orderByComparator != null) {
3090 query = new StringBundler(4 +
3091 (orderByComparator.getOrderByFields().length * 3));
3092 }
3093 else {
3094 query = new StringBundler(3);
3095 }
3096
3097 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
3098
3099 query.append(_FINDER_COLUMN_U1_U2_USERID1_2);
3100
3101 query.append(_FINDER_COLUMN_U1_U2_USERID2_2);
3102
3103 if (orderByComparator != null) {
3104 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3105 orderByComparator);
3106 }
3107
3108 String sql = query.toString();
3109
3110 Session session = null;
3111
3112 try {
3113 session = openSession();
3114
3115 Query q = session.createQuery(sql);
3116
3117 QueryPos qPos = QueryPos.getInstance(q);
3118
3119 qPos.add(userId1);
3120
3121 qPos.add(userId2);
3122
3123 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
3124 start, end);
3125 }
3126 catch (Exception e) {
3127 throw processException(e);
3128 }
3129 finally {
3130 if (list == null) {
3131 FinderCacheUtil.removeResult(finderPath, finderArgs);
3132 }
3133 else {
3134 cacheResult(list);
3135
3136 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3137 }
3138
3139 closeSession(session);
3140 }
3141 }
3142
3143 return list;
3144 }
3145
3146
3160 public SocialRelation findByU1_U2_First(long userId1, long userId2,
3161 OrderByComparator orderByComparator)
3162 throws NoSuchRelationException, SystemException {
3163 List<SocialRelation> list = findByU1_U2(userId1, userId2, 0, 1,
3164 orderByComparator);
3165
3166 if (list.isEmpty()) {
3167 StringBundler msg = new StringBundler(6);
3168
3169 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3170
3171 msg.append("userId1=");
3172 msg.append(userId1);
3173
3174 msg.append(", userId2=");
3175 msg.append(userId2);
3176
3177 msg.append(StringPool.CLOSE_CURLY_BRACE);
3178
3179 throw new NoSuchRelationException(msg.toString());
3180 }
3181 else {
3182 return list.get(0);
3183 }
3184 }
3185
3186
3200 public SocialRelation findByU1_U2_Last(long userId1, long userId2,
3201 OrderByComparator orderByComparator)
3202 throws NoSuchRelationException, SystemException {
3203 int count = countByU1_U2(userId1, userId2);
3204
3205 List<SocialRelation> list = findByU1_U2(userId1, userId2, count - 1,
3206 count, orderByComparator);
3207
3208 if (list.isEmpty()) {
3209 StringBundler msg = new StringBundler(6);
3210
3211 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3212
3213 msg.append("userId1=");
3214 msg.append(userId1);
3215
3216 msg.append(", userId2=");
3217 msg.append(userId2);
3218
3219 msg.append(StringPool.CLOSE_CURLY_BRACE);
3220
3221 throw new NoSuchRelationException(msg.toString());
3222 }
3223 else {
3224 return list.get(0);
3225 }
3226 }
3227
3228
3243 public SocialRelation[] findByU1_U2_PrevAndNext(long relationId,
3244 long userId1, long userId2, OrderByComparator orderByComparator)
3245 throws NoSuchRelationException, SystemException {
3246 SocialRelation socialRelation = findByPrimaryKey(relationId);
3247
3248 Session session = null;
3249
3250 try {
3251 session = openSession();
3252
3253 SocialRelation[] array = new SocialRelationImpl[3];
3254
3255 array[0] = getByU1_U2_PrevAndNext(session, socialRelation, userId1,
3256 userId2, orderByComparator, true);
3257
3258 array[1] = socialRelation;
3259
3260 array[2] = getByU1_U2_PrevAndNext(session, socialRelation, userId1,
3261 userId2, orderByComparator, false);
3262
3263 return array;
3264 }
3265 catch (Exception e) {
3266 throw processException(e);
3267 }
3268 finally {
3269 closeSession(session);
3270 }
3271 }
3272
3273 protected SocialRelation getByU1_U2_PrevAndNext(Session session,
3274 SocialRelation socialRelation, long userId1, long userId2,
3275 OrderByComparator orderByComparator, boolean previous) {
3276 StringBundler query = null;
3277
3278 if (orderByComparator != null) {
3279 query = new StringBundler(6 +
3280 (orderByComparator.getOrderByFields().length * 6));
3281 }
3282 else {
3283 query = new StringBundler(3);
3284 }
3285
3286 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
3287
3288 query.append(_FINDER_COLUMN_U1_U2_USERID1_2);
3289
3290 query.append(_FINDER_COLUMN_U1_U2_USERID2_2);
3291
3292 if (orderByComparator != null) {
3293 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3294
3295 if (orderByConditionFields.length > 0) {
3296 query.append(WHERE_AND);
3297 }
3298
3299 for (int i = 0; i < orderByConditionFields.length; i++) {
3300 query.append(_ORDER_BY_ENTITY_ALIAS);
3301 query.append(orderByConditionFields[i]);
3302
3303 if ((i + 1) < orderByConditionFields.length) {
3304 if (orderByComparator.isAscending() ^ previous) {
3305 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3306 }
3307 else {
3308 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3309 }
3310 }
3311 else {
3312 if (orderByComparator.isAscending() ^ previous) {
3313 query.append(WHERE_GREATER_THAN);
3314 }
3315 else {
3316 query.append(WHERE_LESSER_THAN);
3317 }
3318 }
3319 }
3320
3321 query.append(ORDER_BY_CLAUSE);
3322
3323 String[] orderByFields = orderByComparator.getOrderByFields();
3324
3325 for (int i = 0; i < orderByFields.length; i++) {
3326 query.append(_ORDER_BY_ENTITY_ALIAS);
3327 query.append(orderByFields[i]);
3328
3329 if ((i + 1) < orderByFields.length) {
3330 if (orderByComparator.isAscending() ^ previous) {
3331 query.append(ORDER_BY_ASC_HAS_NEXT);
3332 }
3333 else {
3334 query.append(ORDER_BY_DESC_HAS_NEXT);
3335 }
3336 }
3337 else {
3338 if (orderByComparator.isAscending() ^ previous) {
3339 query.append(ORDER_BY_ASC);
3340 }
3341 else {
3342 query.append(ORDER_BY_DESC);
3343 }
3344 }
3345 }
3346 }
3347
3348 String sql = query.toString();
3349
3350 Query q = session.createQuery(sql);
3351
3352 q.setFirstResult(0);
3353 q.setMaxResults(2);
3354
3355 QueryPos qPos = QueryPos.getInstance(q);
3356
3357 qPos.add(userId1);
3358
3359 qPos.add(userId2);
3360
3361 if (orderByComparator != null) {
3362 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
3363
3364 for (Object value : values) {
3365 qPos.add(value);
3366 }
3367 }
3368
3369 List<SocialRelation> list = q.list();
3370
3371 if (list.size() == 2) {
3372 return list.get(1);
3373 }
3374 else {
3375 return null;
3376 }
3377 }
3378
3379
3387 public List<SocialRelation> findByU1_T(long userId1, int type)
3388 throws SystemException {
3389 return findByU1_T(userId1, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3390 null);
3391 }
3392
3393
3407 public List<SocialRelation> findByU1_T(long userId1, int type, int start,
3408 int end) throws SystemException {
3409 return findByU1_T(userId1, type, start, end, null);
3410 }
3411
3412
3427 public List<SocialRelation> findByU1_T(long userId1, int type, int start,
3428 int end, OrderByComparator orderByComparator) throws SystemException {
3429 FinderPath finderPath = null;
3430 Object[] finderArgs = null;
3431
3432 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3433 (orderByComparator == null)) {
3434 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T;
3435 finderArgs = new Object[] { userId1, type };
3436 }
3437 else {
3438 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U1_T;
3439 finderArgs = new Object[] {
3440 userId1, type,
3441
3442 start, end, orderByComparator
3443 };
3444 }
3445
3446 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
3447 finderArgs, this);
3448
3449 if ((list != null) && !list.isEmpty()) {
3450 for (SocialRelation socialRelation : list) {
3451 if ((userId1 != socialRelation.getUserId1()) ||
3452 (type != socialRelation.getType())) {
3453 list = null;
3454
3455 break;
3456 }
3457 }
3458 }
3459
3460 if (list == null) {
3461 StringBundler query = null;
3462
3463 if (orderByComparator != null) {
3464 query = new StringBundler(4 +
3465 (orderByComparator.getOrderByFields().length * 3));
3466 }
3467 else {
3468 query = new StringBundler(3);
3469 }
3470
3471 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
3472
3473 query.append(_FINDER_COLUMN_U1_T_USERID1_2);
3474
3475 query.append(_FINDER_COLUMN_U1_T_TYPE_2);
3476
3477 if (orderByComparator != null) {
3478 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3479 orderByComparator);
3480 }
3481
3482 String sql = query.toString();
3483
3484 Session session = null;
3485
3486 try {
3487 session = openSession();
3488
3489 Query q = session.createQuery(sql);
3490
3491 QueryPos qPos = QueryPos.getInstance(q);
3492
3493 qPos.add(userId1);
3494
3495 qPos.add(type);
3496
3497 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
3498 start, end);
3499 }
3500 catch (Exception e) {
3501 throw processException(e);
3502 }
3503 finally {
3504 if (list == null) {
3505 FinderCacheUtil.removeResult(finderPath, finderArgs);
3506 }
3507 else {
3508 cacheResult(list);
3509
3510 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3511 }
3512
3513 closeSession(session);
3514 }
3515 }
3516
3517 return list;
3518 }
3519
3520
3534 public SocialRelation findByU1_T_First(long userId1, int type,
3535 OrderByComparator orderByComparator)
3536 throws NoSuchRelationException, SystemException {
3537 List<SocialRelation> list = findByU1_T(userId1, type, 0, 1,
3538 orderByComparator);
3539
3540 if (list.isEmpty()) {
3541 StringBundler msg = new StringBundler(6);
3542
3543 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3544
3545 msg.append("userId1=");
3546 msg.append(userId1);
3547
3548 msg.append(", type=");
3549 msg.append(type);
3550
3551 msg.append(StringPool.CLOSE_CURLY_BRACE);
3552
3553 throw new NoSuchRelationException(msg.toString());
3554 }
3555 else {
3556 return list.get(0);
3557 }
3558 }
3559
3560
3574 public SocialRelation findByU1_T_Last(long userId1, int type,
3575 OrderByComparator orderByComparator)
3576 throws NoSuchRelationException, SystemException {
3577 int count = countByU1_T(userId1, type);
3578
3579 List<SocialRelation> list = findByU1_T(userId1, type, count - 1, count,
3580 orderByComparator);
3581
3582 if (list.isEmpty()) {
3583 StringBundler msg = new StringBundler(6);
3584
3585 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3586
3587 msg.append("userId1=");
3588 msg.append(userId1);
3589
3590 msg.append(", type=");
3591 msg.append(type);
3592
3593 msg.append(StringPool.CLOSE_CURLY_BRACE);
3594
3595 throw new NoSuchRelationException(msg.toString());
3596 }
3597 else {
3598 return list.get(0);
3599 }
3600 }
3601
3602
3617 public SocialRelation[] findByU1_T_PrevAndNext(long relationId,
3618 long userId1, int type, OrderByComparator orderByComparator)
3619 throws NoSuchRelationException, SystemException {
3620 SocialRelation socialRelation = findByPrimaryKey(relationId);
3621
3622 Session session = null;
3623
3624 try {
3625 session = openSession();
3626
3627 SocialRelation[] array = new SocialRelationImpl[3];
3628
3629 array[0] = getByU1_T_PrevAndNext(session, socialRelation, userId1,
3630 type, orderByComparator, true);
3631
3632 array[1] = socialRelation;
3633
3634 array[2] = getByU1_T_PrevAndNext(session, socialRelation, userId1,
3635 type, orderByComparator, false);
3636
3637 return array;
3638 }
3639 catch (Exception e) {
3640 throw processException(e);
3641 }
3642 finally {
3643 closeSession(session);
3644 }
3645 }
3646
3647 protected SocialRelation getByU1_T_PrevAndNext(Session session,
3648 SocialRelation socialRelation, long userId1, int type,
3649 OrderByComparator orderByComparator, boolean previous) {
3650 StringBundler query = null;
3651
3652 if (orderByComparator != null) {
3653 query = new StringBundler(6 +
3654 (orderByComparator.getOrderByFields().length * 6));
3655 }
3656 else {
3657 query = new StringBundler(3);
3658 }
3659
3660 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
3661
3662 query.append(_FINDER_COLUMN_U1_T_USERID1_2);
3663
3664 query.append(_FINDER_COLUMN_U1_T_TYPE_2);
3665
3666 if (orderByComparator != null) {
3667 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3668
3669 if (orderByConditionFields.length > 0) {
3670 query.append(WHERE_AND);
3671 }
3672
3673 for (int i = 0; i < orderByConditionFields.length; i++) {
3674 query.append(_ORDER_BY_ENTITY_ALIAS);
3675 query.append(orderByConditionFields[i]);
3676
3677 if ((i + 1) < orderByConditionFields.length) {
3678 if (orderByComparator.isAscending() ^ previous) {
3679 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3680 }
3681 else {
3682 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3683 }
3684 }
3685 else {
3686 if (orderByComparator.isAscending() ^ previous) {
3687 query.append(WHERE_GREATER_THAN);
3688 }
3689 else {
3690 query.append(WHERE_LESSER_THAN);
3691 }
3692 }
3693 }
3694
3695 query.append(ORDER_BY_CLAUSE);
3696
3697 String[] orderByFields = orderByComparator.getOrderByFields();
3698
3699 for (int i = 0; i < orderByFields.length; i++) {
3700 query.append(_ORDER_BY_ENTITY_ALIAS);
3701 query.append(orderByFields[i]);
3702
3703 if ((i + 1) < orderByFields.length) {
3704 if (orderByComparator.isAscending() ^ previous) {
3705 query.append(ORDER_BY_ASC_HAS_NEXT);
3706 }
3707 else {
3708 query.append(ORDER_BY_DESC_HAS_NEXT);
3709 }
3710 }
3711 else {
3712 if (orderByComparator.isAscending() ^ previous) {
3713 query.append(ORDER_BY_ASC);
3714 }
3715 else {
3716 query.append(ORDER_BY_DESC);
3717 }
3718 }
3719 }
3720 }
3721
3722 String sql = query.toString();
3723
3724 Query q = session.createQuery(sql);
3725
3726 q.setFirstResult(0);
3727 q.setMaxResults(2);
3728
3729 QueryPos qPos = QueryPos.getInstance(q);
3730
3731 qPos.add(userId1);
3732
3733 qPos.add(type);
3734
3735 if (orderByComparator != null) {
3736 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
3737
3738 for (Object value : values) {
3739 qPos.add(value);
3740 }
3741 }
3742
3743 List<SocialRelation> list = q.list();
3744
3745 if (list.size() == 2) {
3746 return list.get(1);
3747 }
3748 else {
3749 return null;
3750 }
3751 }
3752
3753
3761 public List<SocialRelation> findByU2_T(long userId2, int type)
3762 throws SystemException {
3763 return findByU2_T(userId2, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3764 null);
3765 }
3766
3767
3781 public List<SocialRelation> findByU2_T(long userId2, int type, int start,
3782 int end) throws SystemException {
3783 return findByU2_T(userId2, type, start, end, null);
3784 }
3785
3786
3801 public List<SocialRelation> findByU2_T(long userId2, int type, int start,
3802 int end, OrderByComparator orderByComparator) throws SystemException {
3803 FinderPath finderPath = null;
3804 Object[] finderArgs = null;
3805
3806 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3807 (orderByComparator == null)) {
3808 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T;
3809 finderArgs = new Object[] { userId2, type };
3810 }
3811 else {
3812 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U2_T;
3813 finderArgs = new Object[] {
3814 userId2, type,
3815
3816 start, end, orderByComparator
3817 };
3818 }
3819
3820 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
3821 finderArgs, this);
3822
3823 if ((list != null) && !list.isEmpty()) {
3824 for (SocialRelation socialRelation : list) {
3825 if ((userId2 != socialRelation.getUserId2()) ||
3826 (type != socialRelation.getType())) {
3827 list = null;
3828
3829 break;
3830 }
3831 }
3832 }
3833
3834 if (list == null) {
3835 StringBundler query = null;
3836
3837 if (orderByComparator != null) {
3838 query = new StringBundler(4 +
3839 (orderByComparator.getOrderByFields().length * 3));
3840 }
3841 else {
3842 query = new StringBundler(3);
3843 }
3844
3845 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
3846
3847 query.append(_FINDER_COLUMN_U2_T_USERID2_2);
3848
3849 query.append(_FINDER_COLUMN_U2_T_TYPE_2);
3850
3851 if (orderByComparator != null) {
3852 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3853 orderByComparator);
3854 }
3855
3856 String sql = query.toString();
3857
3858 Session session = null;
3859
3860 try {
3861 session = openSession();
3862
3863 Query q = session.createQuery(sql);
3864
3865 QueryPos qPos = QueryPos.getInstance(q);
3866
3867 qPos.add(userId2);
3868
3869 qPos.add(type);
3870
3871 list = (List<SocialRelation>)QueryUtil.list(q, getDialect(),
3872 start, end);
3873 }
3874 catch (Exception e) {
3875 throw processException(e);
3876 }
3877 finally {
3878 if (list == null) {
3879 FinderCacheUtil.removeResult(finderPath, finderArgs);
3880 }
3881 else {
3882 cacheResult(list);
3883
3884 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3885 }
3886
3887 closeSession(session);
3888 }
3889 }
3890
3891 return list;
3892 }
3893
3894
3908 public SocialRelation findByU2_T_First(long userId2, int type,
3909 OrderByComparator orderByComparator)
3910 throws NoSuchRelationException, SystemException {
3911 List<SocialRelation> list = findByU2_T(userId2, type, 0, 1,
3912 orderByComparator);
3913
3914 if (list.isEmpty()) {
3915 StringBundler msg = new StringBundler(6);
3916
3917 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3918
3919 msg.append("userId2=");
3920 msg.append(userId2);
3921
3922 msg.append(", type=");
3923 msg.append(type);
3924
3925 msg.append(StringPool.CLOSE_CURLY_BRACE);
3926
3927 throw new NoSuchRelationException(msg.toString());
3928 }
3929 else {
3930 return list.get(0);
3931 }
3932 }
3933
3934
3948 public SocialRelation findByU2_T_Last(long userId2, int type,
3949 OrderByComparator orderByComparator)
3950 throws NoSuchRelationException, SystemException {
3951 int count = countByU2_T(userId2, type);
3952
3953 List<SocialRelation> list = findByU2_T(userId2, type, count - 1, count,
3954 orderByComparator);
3955
3956 if (list.isEmpty()) {
3957 StringBundler msg = new StringBundler(6);
3958
3959 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3960
3961 msg.append("userId2=");
3962 msg.append(userId2);
3963
3964 msg.append(", type=");
3965 msg.append(type);
3966
3967 msg.append(StringPool.CLOSE_CURLY_BRACE);
3968
3969 throw new NoSuchRelationException(msg.toString());
3970 }
3971 else {
3972 return list.get(0);
3973 }
3974 }
3975
3976
3991 public SocialRelation[] findByU2_T_PrevAndNext(long relationId,
3992 long userId2, int type, OrderByComparator orderByComparator)
3993 throws NoSuchRelationException, SystemException {
3994 SocialRelation socialRelation = findByPrimaryKey(relationId);
3995
3996 Session session = null;
3997
3998 try {
3999 session = openSession();
4000
4001 SocialRelation[] array = new SocialRelationImpl[3];
4002
4003 array[0] = getByU2_T_PrevAndNext(session, socialRelation, userId2,
4004 type, orderByComparator, true);
4005
4006 array[1] = socialRelation;
4007
4008 array[2] = getByU2_T_PrevAndNext(session, socialRelation, userId2,
4009 type, orderByComparator, false);
4010
4011 return array;
4012 }
4013 catch (Exception e) {
4014 throw processException(e);
4015 }
4016 finally {
4017 closeSession(session);
4018 }
4019 }
4020
4021 protected SocialRelation getByU2_T_PrevAndNext(Session session,
4022 SocialRelation socialRelation, long userId2, int type,
4023 OrderByComparator orderByComparator, boolean previous) {
4024 StringBundler query = null;
4025
4026 if (orderByComparator != null) {
4027 query = new StringBundler(6 +
4028 (orderByComparator.getOrderByFields().length * 6));
4029 }
4030 else {
4031 query = new StringBundler(3);
4032 }
4033
4034 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
4035
4036 query.append(_FINDER_COLUMN_U2_T_USERID2_2);
4037
4038 query.append(_FINDER_COLUMN_U2_T_TYPE_2);
4039
4040 if (orderByComparator != null) {
4041 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4042
4043 if (orderByConditionFields.length > 0) {
4044 query.append(WHERE_AND);
4045 }
4046
4047 for (int i = 0; i < orderByConditionFields.length; i++) {
4048 query.append(_ORDER_BY_ENTITY_ALIAS);
4049 query.append(orderByConditionFields[i]);
4050
4051 if ((i + 1) < orderByConditionFields.length) {
4052 if (orderByComparator.isAscending() ^ previous) {
4053 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4054 }
4055 else {
4056 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4057 }
4058 }
4059 else {
4060 if (orderByComparator.isAscending() ^ previous) {
4061 query.append(WHERE_GREATER_THAN);
4062 }
4063 else {
4064 query.append(WHERE_LESSER_THAN);
4065 }
4066 }
4067 }
4068
4069 query.append(ORDER_BY_CLAUSE);
4070
4071 String[] orderByFields = orderByComparator.getOrderByFields();
4072
4073 for (int i = 0; i < orderByFields.length; i++) {
4074 query.append(_ORDER_BY_ENTITY_ALIAS);
4075 query.append(orderByFields[i]);
4076
4077 if ((i + 1) < orderByFields.length) {
4078 if (orderByComparator.isAscending() ^ previous) {
4079 query.append(ORDER_BY_ASC_HAS_NEXT);
4080 }
4081 else {
4082 query.append(ORDER_BY_DESC_HAS_NEXT);
4083 }
4084 }
4085 else {
4086 if (orderByComparator.isAscending() ^ previous) {
4087 query.append(ORDER_BY_ASC);
4088 }
4089 else {
4090 query.append(ORDER_BY_DESC);
4091 }
4092 }
4093 }
4094 }
4095
4096 String sql = query.toString();
4097
4098 Query q = session.createQuery(sql);
4099
4100 q.setFirstResult(0);
4101 q.setMaxResults(2);
4102
4103 QueryPos qPos = QueryPos.getInstance(q);
4104
4105 qPos.add(userId2);
4106
4107 qPos.add(type);
4108
4109 if (orderByComparator != null) {
4110 Object[] values = orderByComparator.getOrderByConditionValues(socialRelation);
4111
4112 for (Object value : values) {
4113 qPos.add(value);
4114 }
4115 }
4116
4117 List<SocialRelation> list = q.list();
4118
4119 if (list.size() == 2) {
4120 return list.get(1);
4121 }
4122 else {
4123 return null;
4124 }
4125 }
4126
4127
4137 public SocialRelation findByU1_U2_T(long userId1, long userId2, int type)
4138 throws NoSuchRelationException, SystemException {
4139 SocialRelation socialRelation = fetchByU1_U2_T(userId1, userId2, type);
4140
4141 if (socialRelation == null) {
4142 StringBundler msg = new StringBundler(8);
4143
4144 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4145
4146 msg.append("userId1=");
4147 msg.append(userId1);
4148
4149 msg.append(", userId2=");
4150 msg.append(userId2);
4151
4152 msg.append(", type=");
4153 msg.append(type);
4154
4155 msg.append(StringPool.CLOSE_CURLY_BRACE);
4156
4157 if (_log.isWarnEnabled()) {
4158 _log.warn(msg.toString());
4159 }
4160
4161 throw new NoSuchRelationException(msg.toString());
4162 }
4163
4164 return socialRelation;
4165 }
4166
4167
4176 public SocialRelation fetchByU1_U2_T(long userId1, long userId2, int type)
4177 throws SystemException {
4178 return fetchByU1_U2_T(userId1, userId2, type, true);
4179 }
4180
4181
4191 public SocialRelation fetchByU1_U2_T(long userId1, long userId2, int type,
4192 boolean retrieveFromCache) throws SystemException {
4193 Object[] finderArgs = new Object[] { userId1, userId2, type };
4194
4195 Object result = null;
4196
4197 if (retrieveFromCache) {
4198 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U1_U2_T,
4199 finderArgs, this);
4200 }
4201
4202 if (result instanceof SocialRelation) {
4203 SocialRelation socialRelation = (SocialRelation)result;
4204
4205 if ((userId1 != socialRelation.getUserId1()) ||
4206 (userId2 != socialRelation.getUserId2()) ||
4207 (type != socialRelation.getType())) {
4208 result = null;
4209 }
4210 }
4211
4212 if (result == null) {
4213 StringBundler query = new StringBundler(4);
4214
4215 query.append(_SQL_SELECT_SOCIALRELATION_WHERE);
4216
4217 query.append(_FINDER_COLUMN_U1_U2_T_USERID1_2);
4218
4219 query.append(_FINDER_COLUMN_U1_U2_T_USERID2_2);
4220
4221 query.append(_FINDER_COLUMN_U1_U2_T_TYPE_2);
4222
4223 String sql = query.toString();
4224
4225 Session session = null;
4226
4227 try {
4228 session = openSession();
4229
4230 Query q = session.createQuery(sql);
4231
4232 QueryPos qPos = QueryPos.getInstance(q);
4233
4234 qPos.add(userId1);
4235
4236 qPos.add(userId2);
4237
4238 qPos.add(type);
4239
4240 List<SocialRelation> list = q.list();
4241
4242 result = list;
4243
4244 SocialRelation socialRelation = null;
4245
4246 if (list.isEmpty()) {
4247 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U1_U2_T,
4248 finderArgs, list);
4249 }
4250 else {
4251 socialRelation = list.get(0);
4252
4253 cacheResult(socialRelation);
4254
4255 if ((socialRelation.getUserId1() != userId1) ||
4256 (socialRelation.getUserId2() != userId2) ||
4257 (socialRelation.getType() != type)) {
4258 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U1_U2_T,
4259 finderArgs, socialRelation);
4260 }
4261 }
4262
4263 return socialRelation;
4264 }
4265 catch (Exception e) {
4266 throw processException(e);
4267 }
4268 finally {
4269 if (result == null) {
4270 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U1_U2_T,
4271 finderArgs);
4272 }
4273
4274 closeSession(session);
4275 }
4276 }
4277 else {
4278 if (result instanceof List<?>) {
4279 return null;
4280 }
4281 else {
4282 return (SocialRelation)result;
4283 }
4284 }
4285 }
4286
4287
4293 public List<SocialRelation> findAll() throws SystemException {
4294 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4295 }
4296
4297
4309 public List<SocialRelation> findAll(int start, int end)
4310 throws SystemException {
4311 return findAll(start, end, null);
4312 }
4313
4314
4327 public List<SocialRelation> findAll(int start, int end,
4328 OrderByComparator orderByComparator) throws SystemException {
4329 FinderPath finderPath = null;
4330 Object[] finderArgs = new Object[] { start, end, orderByComparator };
4331
4332 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4333 (orderByComparator == null)) {
4334 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4335 finderArgs = FINDER_ARGS_EMPTY;
4336 }
4337 else {
4338 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4339 finderArgs = new Object[] { start, end, orderByComparator };
4340 }
4341
4342 List<SocialRelation> list = (List<SocialRelation>)FinderCacheUtil.getResult(finderPath,
4343 finderArgs, this);
4344
4345 if (list == null) {
4346 StringBundler query = null;
4347 String sql = null;
4348
4349 if (orderByComparator != null) {
4350 query = new StringBundler(2 +
4351 (orderByComparator.getOrderByFields().length * 3));
4352
4353 query.append(_SQL_SELECT_SOCIALRELATION);
4354
4355 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4356 orderByComparator);
4357
4358 sql = query.toString();
4359 }
4360 else {
4361 sql = _SQL_SELECT_SOCIALRELATION;
4362 }
4363
4364 Session session = null;
4365
4366 try {
4367 session = openSession();
4368
4369 Query q = session.createQuery(sql);
4370
4371 if (orderByComparator == null) {
4372 list = (List<SocialRelation>)QueryUtil.list(q,
4373 getDialect(), start, end, false);
4374
4375 Collections.sort(list);
4376 }
4377 else {
4378 list = (List<SocialRelation>)QueryUtil.list(q,
4379 getDialect(), start, end);
4380 }
4381 }
4382 catch (Exception e) {
4383 throw processException(e);
4384 }
4385 finally {
4386 if (list == null) {
4387 FinderCacheUtil.removeResult(finderPath, finderArgs);
4388 }
4389 else {
4390 cacheResult(list);
4391
4392 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4393 }
4394
4395 closeSession(session);
4396 }
4397 }
4398
4399 return list;
4400 }
4401
4402
4408 public void removeByUuid(String uuid) throws SystemException {
4409 for (SocialRelation socialRelation : findByUuid(uuid)) {
4410 remove(socialRelation);
4411 }
4412 }
4413
4414
4420 public void removeByCompanyId(long companyId) throws SystemException {
4421 for (SocialRelation socialRelation : findByCompanyId(companyId)) {
4422 remove(socialRelation);
4423 }
4424 }
4425
4426
4432 public void removeByUserId1(long userId1) throws SystemException {
4433 for (SocialRelation socialRelation : findByUserId1(userId1)) {
4434 remove(socialRelation);
4435 }
4436 }
4437
4438
4444 public void removeByUserId2(long userId2) throws SystemException {
4445 for (SocialRelation socialRelation : findByUserId2(userId2)) {
4446 remove(socialRelation);
4447 }
4448 }
4449
4450
4456 public void removeByType(int type) throws SystemException {
4457 for (SocialRelation socialRelation : findByType(type)) {
4458 remove(socialRelation);
4459 }
4460 }
4461
4462
4469 public void removeByC_T(long companyId, int type) throws SystemException {
4470 for (SocialRelation socialRelation : findByC_T(companyId, type)) {
4471 remove(socialRelation);
4472 }
4473 }
4474
4475
4482 public void removeByU1_U2(long userId1, long userId2)
4483 throws SystemException {
4484 for (SocialRelation socialRelation : findByU1_U2(userId1, userId2)) {
4485 remove(socialRelation);
4486 }
4487 }
4488
4489
4496 public void removeByU1_T(long userId1, int type) throws SystemException {
4497 for (SocialRelation socialRelation : findByU1_T(userId1, type)) {
4498 remove(socialRelation);
4499 }
4500 }
4501
4502
4509 public void removeByU2_T(long userId2, int type) throws SystemException {
4510 for (SocialRelation socialRelation : findByU2_T(userId2, type)) {
4511 remove(socialRelation);
4512 }
4513 }
4514
4515
4523 public void removeByU1_U2_T(long userId1, long userId2, int type)
4524 throws NoSuchRelationException, SystemException {
4525 SocialRelation socialRelation = findByU1_U2_T(userId1, userId2, type);
4526
4527 remove(socialRelation);
4528 }
4529
4530
4535 public void removeAll() throws SystemException {
4536 for (SocialRelation socialRelation : findAll()) {
4537 remove(socialRelation);
4538 }
4539 }
4540
4541
4548 public int countByUuid(String uuid) throws SystemException {
4549 Object[] finderArgs = new Object[] { uuid };
4550
4551 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4552 finderArgs, this);
4553
4554 if (count == null) {
4555 StringBundler query = new StringBundler(2);
4556
4557 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
4558
4559 if (uuid == null) {
4560 query.append(_FINDER_COLUMN_UUID_UUID_1);
4561 }
4562 else {
4563 if (uuid.equals(StringPool.BLANK)) {
4564 query.append(_FINDER_COLUMN_UUID_UUID_3);
4565 }
4566 else {
4567 query.append(_FINDER_COLUMN_UUID_UUID_2);
4568 }
4569 }
4570
4571 String sql = query.toString();
4572
4573 Session session = null;
4574
4575 try {
4576 session = openSession();
4577
4578 Query q = session.createQuery(sql);
4579
4580 QueryPos qPos = QueryPos.getInstance(q);
4581
4582 if (uuid != null) {
4583 qPos.add(uuid);
4584 }
4585
4586 count = (Long)q.uniqueResult();
4587 }
4588 catch (Exception e) {
4589 throw processException(e);
4590 }
4591 finally {
4592 if (count == null) {
4593 count = Long.valueOf(0);
4594 }
4595
4596 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4597 finderArgs, count);
4598
4599 closeSession(session);
4600 }
4601 }
4602
4603 return count.intValue();
4604 }
4605
4606
4613 public int countByCompanyId(long companyId) throws SystemException {
4614 Object[] finderArgs = new Object[] { companyId };
4615
4616 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4617 finderArgs, this);
4618
4619 if (count == null) {
4620 StringBundler query = new StringBundler(2);
4621
4622 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
4623
4624 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4625
4626 String sql = query.toString();
4627
4628 Session session = null;
4629
4630 try {
4631 session = openSession();
4632
4633 Query q = session.createQuery(sql);
4634
4635 QueryPos qPos = QueryPos.getInstance(q);
4636
4637 qPos.add(companyId);
4638
4639 count = (Long)q.uniqueResult();
4640 }
4641 catch (Exception e) {
4642 throw processException(e);
4643 }
4644 finally {
4645 if (count == null) {
4646 count = Long.valueOf(0);
4647 }
4648
4649 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4650 finderArgs, count);
4651
4652 closeSession(session);
4653 }
4654 }
4655
4656 return count.intValue();
4657 }
4658
4659
4666 public int countByUserId1(long userId1) throws SystemException {
4667 Object[] finderArgs = new Object[] { userId1 };
4668
4669 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID1,
4670 finderArgs, this);
4671
4672 if (count == null) {
4673 StringBundler query = new StringBundler(2);
4674
4675 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
4676
4677 query.append(_FINDER_COLUMN_USERID1_USERID1_2);
4678
4679 String sql = query.toString();
4680
4681 Session session = null;
4682
4683 try {
4684 session = openSession();
4685
4686 Query q = session.createQuery(sql);
4687
4688 QueryPos qPos = QueryPos.getInstance(q);
4689
4690 qPos.add(userId1);
4691
4692 count = (Long)q.uniqueResult();
4693 }
4694 catch (Exception e) {
4695 throw processException(e);
4696 }
4697 finally {
4698 if (count == null) {
4699 count = Long.valueOf(0);
4700 }
4701
4702 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID1,
4703 finderArgs, count);
4704
4705 closeSession(session);
4706 }
4707 }
4708
4709 return count.intValue();
4710 }
4711
4712
4719 public int countByUserId2(long userId2) throws SystemException {
4720 Object[] finderArgs = new Object[] { userId2 };
4721
4722 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID2,
4723 finderArgs, this);
4724
4725 if (count == null) {
4726 StringBundler query = new StringBundler(2);
4727
4728 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
4729
4730 query.append(_FINDER_COLUMN_USERID2_USERID2_2);
4731
4732 String sql = query.toString();
4733
4734 Session session = null;
4735
4736 try {
4737 session = openSession();
4738
4739 Query q = session.createQuery(sql);
4740
4741 QueryPos qPos = QueryPos.getInstance(q);
4742
4743 qPos.add(userId2);
4744
4745 count = (Long)q.uniqueResult();
4746 }
4747 catch (Exception e) {
4748 throw processException(e);
4749 }
4750 finally {
4751 if (count == null) {
4752 count = Long.valueOf(0);
4753 }
4754
4755 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID2,
4756 finderArgs, count);
4757
4758 closeSession(session);
4759 }
4760 }
4761
4762 return count.intValue();
4763 }
4764
4765
4772 public int countByType(int type) throws SystemException {
4773 Object[] finderArgs = new Object[] { type };
4774
4775 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TYPE,
4776 finderArgs, this);
4777
4778 if (count == null) {
4779 StringBundler query = new StringBundler(2);
4780
4781 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
4782
4783 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
4784
4785 String sql = query.toString();
4786
4787 Session session = null;
4788
4789 try {
4790 session = openSession();
4791
4792 Query q = session.createQuery(sql);
4793
4794 QueryPos qPos = QueryPos.getInstance(q);
4795
4796 qPos.add(type);
4797
4798 count = (Long)q.uniqueResult();
4799 }
4800 catch (Exception e) {
4801 throw processException(e);
4802 }
4803 finally {
4804 if (count == null) {
4805 count = Long.valueOf(0);
4806 }
4807
4808 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TYPE,
4809 finderArgs, count);
4810
4811 closeSession(session);
4812 }
4813 }
4814
4815 return count.intValue();
4816 }
4817
4818
4826 public int countByC_T(long companyId, int type) throws SystemException {
4827 Object[] finderArgs = new Object[] { companyId, type };
4828
4829 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_T,
4830 finderArgs, this);
4831
4832 if (count == null) {
4833 StringBundler query = new StringBundler(3);
4834
4835 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
4836
4837 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
4838
4839 query.append(_FINDER_COLUMN_C_T_TYPE_2);
4840
4841 String sql = query.toString();
4842
4843 Session session = null;
4844
4845 try {
4846 session = openSession();
4847
4848 Query q = session.createQuery(sql);
4849
4850 QueryPos qPos = QueryPos.getInstance(q);
4851
4852 qPos.add(companyId);
4853
4854 qPos.add(type);
4855
4856 count = (Long)q.uniqueResult();
4857 }
4858 catch (Exception e) {
4859 throw processException(e);
4860 }
4861 finally {
4862 if (count == null) {
4863 count = Long.valueOf(0);
4864 }
4865
4866 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_T, finderArgs,
4867 count);
4868
4869 closeSession(session);
4870 }
4871 }
4872
4873 return count.intValue();
4874 }
4875
4876
4884 public int countByU1_U2(long userId1, long userId2)
4885 throws SystemException {
4886 Object[] finderArgs = new Object[] { userId1, userId2 };
4887
4888 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U1_U2,
4889 finderArgs, this);
4890
4891 if (count == null) {
4892 StringBundler query = new StringBundler(3);
4893
4894 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
4895
4896 query.append(_FINDER_COLUMN_U1_U2_USERID1_2);
4897
4898 query.append(_FINDER_COLUMN_U1_U2_USERID2_2);
4899
4900 String sql = query.toString();
4901
4902 Session session = null;
4903
4904 try {
4905 session = openSession();
4906
4907 Query q = session.createQuery(sql);
4908
4909 QueryPos qPos = QueryPos.getInstance(q);
4910
4911 qPos.add(userId1);
4912
4913 qPos.add(userId2);
4914
4915 count = (Long)q.uniqueResult();
4916 }
4917 catch (Exception e) {
4918 throw processException(e);
4919 }
4920 finally {
4921 if (count == null) {
4922 count = Long.valueOf(0);
4923 }
4924
4925 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U1_U2,
4926 finderArgs, count);
4927
4928 closeSession(session);
4929 }
4930 }
4931
4932 return count.intValue();
4933 }
4934
4935
4943 public int countByU1_T(long userId1, int type) throws SystemException {
4944 Object[] finderArgs = new Object[] { userId1, type };
4945
4946 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U1_T,
4947 finderArgs, this);
4948
4949 if (count == null) {
4950 StringBundler query = new StringBundler(3);
4951
4952 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
4953
4954 query.append(_FINDER_COLUMN_U1_T_USERID1_2);
4955
4956 query.append(_FINDER_COLUMN_U1_T_TYPE_2);
4957
4958 String sql = query.toString();
4959
4960 Session session = null;
4961
4962 try {
4963 session = openSession();
4964
4965 Query q = session.createQuery(sql);
4966
4967 QueryPos qPos = QueryPos.getInstance(q);
4968
4969 qPos.add(userId1);
4970
4971 qPos.add(type);
4972
4973 count = (Long)q.uniqueResult();
4974 }
4975 catch (Exception e) {
4976 throw processException(e);
4977 }
4978 finally {
4979 if (count == null) {
4980 count = Long.valueOf(0);
4981 }
4982
4983 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U1_T,
4984 finderArgs, count);
4985
4986 closeSession(session);
4987 }
4988 }
4989
4990 return count.intValue();
4991 }
4992
4993
5001 public int countByU2_T(long userId2, int type) throws SystemException {
5002 Object[] finderArgs = new Object[] { userId2, type };
5003
5004 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U2_T,
5005 finderArgs, this);
5006
5007 if (count == null) {
5008 StringBundler query = new StringBundler(3);
5009
5010 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
5011
5012 query.append(_FINDER_COLUMN_U2_T_USERID2_2);
5013
5014 query.append(_FINDER_COLUMN_U2_T_TYPE_2);
5015
5016 String sql = query.toString();
5017
5018 Session session = null;
5019
5020 try {
5021 session = openSession();
5022
5023 Query q = session.createQuery(sql);
5024
5025 QueryPos qPos = QueryPos.getInstance(q);
5026
5027 qPos.add(userId2);
5028
5029 qPos.add(type);
5030
5031 count = (Long)q.uniqueResult();
5032 }
5033 catch (Exception e) {
5034 throw processException(e);
5035 }
5036 finally {
5037 if (count == null) {
5038 count = Long.valueOf(0);
5039 }
5040
5041 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U2_T,
5042 finderArgs, count);
5043
5044 closeSession(session);
5045 }
5046 }
5047
5048 return count.intValue();
5049 }
5050
5051
5060 public int countByU1_U2_T(long userId1, long userId2, int type)
5061 throws SystemException {
5062 Object[] finderArgs = new Object[] { userId1, userId2, type };
5063
5064 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U1_U2_T,
5065 finderArgs, this);
5066
5067 if (count == null) {
5068 StringBundler query = new StringBundler(4);
5069
5070 query.append(_SQL_COUNT_SOCIALRELATION_WHERE);
5071
5072 query.append(_FINDER_COLUMN_U1_U2_T_USERID1_2);
5073
5074 query.append(_FINDER_COLUMN_U1_U2_T_USERID2_2);
5075
5076 query.append(_FINDER_COLUMN_U1_U2_T_TYPE_2);
5077
5078 String sql = query.toString();
5079
5080 Session session = null;
5081
5082 try {
5083 session = openSession();
5084
5085 Query q = session.createQuery(sql);
5086
5087 QueryPos qPos = QueryPos.getInstance(q);
5088
5089 qPos.add(userId1);
5090
5091 qPos.add(userId2);
5092
5093 qPos.add(type);
5094
5095 count = (Long)q.uniqueResult();
5096 }
5097 catch (Exception e) {
5098 throw processException(e);
5099 }
5100 finally {
5101 if (count == null) {
5102 count = Long.valueOf(0);
5103 }
5104
5105 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U1_U2_T,
5106 finderArgs, count);
5107
5108 closeSession(session);
5109 }
5110 }
5111
5112 return count.intValue();
5113 }
5114
5115
5121 public int countAll() throws SystemException {
5122 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5123 FINDER_ARGS_EMPTY, this);
5124
5125 if (count == null) {
5126 Session session = null;
5127
5128 try {
5129 session = openSession();
5130
5131 Query q = session.createQuery(_SQL_COUNT_SOCIALRELATION);
5132
5133 count = (Long)q.uniqueResult();
5134 }
5135 catch (Exception e) {
5136 throw processException(e);
5137 }
5138 finally {
5139 if (count == null) {
5140 count = Long.valueOf(0);
5141 }
5142
5143 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5144 FINDER_ARGS_EMPTY, count);
5145
5146 closeSession(session);
5147 }
5148 }
5149
5150 return count.intValue();
5151 }
5152
5153
5156 public void afterPropertiesSet() {
5157 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5158 com.liferay.portal.util.PropsUtil.get(
5159 "value.object.listener.com.liferay.portlet.social.model.SocialRelation")));
5160
5161 if (listenerClassNames.length > 0) {
5162 try {
5163 List<ModelListener<SocialRelation>> listenersList = new ArrayList<ModelListener<SocialRelation>>();
5164
5165 for (String listenerClassName : listenerClassNames) {
5166 listenersList.add((ModelListener<SocialRelation>)InstanceFactory.newInstance(
5167 listenerClassName));
5168 }
5169
5170 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5171 }
5172 catch (Exception e) {
5173 _log.error(e);
5174 }
5175 }
5176 }
5177
5178 public void destroy() {
5179 EntityCacheUtil.removeCache(SocialRelationImpl.class.getName());
5180 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5181 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5182 }
5183
5184 @BeanReference(type = SocialActivityPersistence.class)
5185 protected SocialActivityPersistence socialActivityPersistence;
5186 @BeanReference(type = SocialActivityAchievementPersistence.class)
5187 protected SocialActivityAchievementPersistence socialActivityAchievementPersistence;
5188 @BeanReference(type = SocialActivityCounterPersistence.class)
5189 protected SocialActivityCounterPersistence socialActivityCounterPersistence;
5190 @BeanReference(type = SocialActivityLimitPersistence.class)
5191 protected SocialActivityLimitPersistence socialActivityLimitPersistence;
5192 @BeanReference(type = SocialActivitySettingPersistence.class)
5193 protected SocialActivitySettingPersistence socialActivitySettingPersistence;
5194 @BeanReference(type = SocialRelationPersistence.class)
5195 protected SocialRelationPersistence socialRelationPersistence;
5196 @BeanReference(type = SocialRequestPersistence.class)
5197 protected SocialRequestPersistence socialRequestPersistence;
5198 @BeanReference(type = ResourcePersistence.class)
5199 protected ResourcePersistence resourcePersistence;
5200 @BeanReference(type = UserPersistence.class)
5201 protected UserPersistence userPersistence;
5202 private static final String _SQL_SELECT_SOCIALRELATION = "SELECT socialRelation FROM SocialRelation socialRelation";
5203 private static final String _SQL_SELECT_SOCIALRELATION_WHERE = "SELECT socialRelation FROM SocialRelation socialRelation WHERE ";
5204 private static final String _SQL_COUNT_SOCIALRELATION = "SELECT COUNT(socialRelation) FROM SocialRelation socialRelation";
5205 private static final String _SQL_COUNT_SOCIALRELATION_WHERE = "SELECT COUNT(socialRelation) FROM SocialRelation socialRelation WHERE ";
5206 private static final String _FINDER_COLUMN_UUID_UUID_1 = "socialRelation.uuid IS NULL";
5207 private static final String _FINDER_COLUMN_UUID_UUID_2 = "socialRelation.uuid = ?";
5208 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(socialRelation.uuid IS NULL OR socialRelation.uuid = ?)";
5209 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "socialRelation.companyId = ?";
5210 private static final String _FINDER_COLUMN_USERID1_USERID1_2 = "socialRelation.userId1 = ?";
5211 private static final String _FINDER_COLUMN_USERID2_USERID2_2 = "socialRelation.userId2 = ?";
5212 private static final String _FINDER_COLUMN_TYPE_TYPE_2 = "socialRelation.type = ?";
5213 private static final String _FINDER_COLUMN_C_T_COMPANYID_2 = "socialRelation.companyId = ? AND ";
5214 private static final String _FINDER_COLUMN_C_T_TYPE_2 = "socialRelation.type = ?";
5215 private static final String _FINDER_COLUMN_U1_U2_USERID1_2 = "socialRelation.userId1 = ? AND ";
5216 private static final String _FINDER_COLUMN_U1_U2_USERID2_2 = "socialRelation.userId2 = ?";
5217 private static final String _FINDER_COLUMN_U1_T_USERID1_2 = "socialRelation.userId1 = ? AND ";
5218 private static final String _FINDER_COLUMN_U1_T_TYPE_2 = "socialRelation.type = ?";
5219 private static final String _FINDER_COLUMN_U2_T_USERID2_2 = "socialRelation.userId2 = ? AND ";
5220 private static final String _FINDER_COLUMN_U2_T_TYPE_2 = "socialRelation.type = ?";
5221 private static final String _FINDER_COLUMN_U1_U2_T_USERID1_2 = "socialRelation.userId1 = ? AND ";
5222 private static final String _FINDER_COLUMN_U1_U2_T_USERID2_2 = "socialRelation.userId2 = ? AND ";
5223 private static final String _FINDER_COLUMN_U1_U2_T_TYPE_2 = "socialRelation.type = ?";
5224 private static final String _ORDER_BY_ENTITY_ALIAS = "socialRelation.";
5225 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialRelation exists with the primary key ";
5226 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialRelation exists with the key {";
5227 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5228 private static Log _log = LogFactoryUtil.getLog(SocialRelationPersistenceImpl.class);
5229 private static SocialRelation _nullSocialRelation = new SocialRelationImpl() {
5230 @Override
5231 public Object clone() {
5232 return this;
5233 }
5234
5235 @Override
5236 public CacheModel<SocialRelation> toCacheModel() {
5237 return _nullSocialRelationCacheModel;
5238 }
5239 };
5240
5241 private static CacheModel<SocialRelation> _nullSocialRelationCacheModel = new CacheModel<SocialRelation>() {
5242 public SocialRelation toEntityModel() {
5243 return _nullSocialRelation;
5244 }
5245 };
5246 }