1
14
15 package com.liferay.portlet.blogs.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
22 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24 import com.liferay.portal.kernel.dao.orm.FinderPath;
25 import com.liferay.portal.kernel.dao.orm.Query;
26 import com.liferay.portal.kernel.dao.orm.QueryPos;
27 import com.liferay.portal.kernel.dao.orm.QueryUtil;
28 import com.liferay.portal.kernel.dao.orm.Session;
29 import com.liferay.portal.kernel.log.Log;
30 import com.liferay.portal.kernel.log.LogFactoryUtil;
31 import com.liferay.portal.kernel.util.GetterUtil;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringBundler;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.model.ModelListener;
37 import com.liferay.portal.service.persistence.BatchSessionUtil;
38 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
39
40 import com.liferay.portlet.blogs.NoSuchStatsUserException;
41 import com.liferay.portlet.blogs.model.BlogsStatsUser;
42 import com.liferay.portlet.blogs.model.impl.BlogsStatsUserImpl;
43 import com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl;
44
45 import java.io.Serializable;
46
47 import java.util.ArrayList;
48 import java.util.Collections;
49 import java.util.List;
50
51
64 public class BlogsStatsUserPersistenceImpl extends BasePersistenceImpl<BlogsStatsUser>
65 implements BlogsStatsUserPersistence {
66 public static final String FINDER_CLASS_NAME_ENTITY = BlogsStatsUserImpl.class.getName();
67 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
68 ".List";
69 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
70 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
71 FINDER_CLASS_NAME_LIST, "findByGroupId",
72 new String[] { Long.class.getName() });
73 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
74 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
75 FINDER_CLASS_NAME_LIST, "findByGroupId",
76 new String[] {
77 Long.class.getName(),
78
79 "java.lang.Integer", "java.lang.Integer",
80 "com.liferay.portal.kernel.util.OrderByComparator"
81 });
82 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
83 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
84 FINDER_CLASS_NAME_LIST, "countByGroupId",
85 new String[] { Long.class.getName() });
86 public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
87 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
88 FINDER_CLASS_NAME_LIST, "findByUserId",
89 new String[] { Long.class.getName() });
90 public static final FinderPath FINDER_PATH_FIND_BY_OBC_USERID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
91 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
92 FINDER_CLASS_NAME_LIST, "findByUserId",
93 new String[] {
94 Long.class.getName(),
95
96 "java.lang.Integer", "java.lang.Integer",
97 "com.liferay.portal.kernel.util.OrderByComparator"
98 });
99 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
100 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
101 FINDER_CLASS_NAME_LIST, "countByUserId",
102 new String[] { Long.class.getName() });
103 public static final FinderPath FINDER_PATH_FETCH_BY_G_U = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
104 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
105 FINDER_CLASS_NAME_ENTITY, "fetchByG_U",
106 new String[] { Long.class.getName(), Long.class.getName() });
107 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
108 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
109 FINDER_CLASS_NAME_LIST, "countByG_U",
110 new String[] { Long.class.getName(), Long.class.getName() });
111 public static final FinderPath FINDER_PATH_FIND_BY_G_E = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
112 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
113 FINDER_CLASS_NAME_LIST, "findByG_E",
114 new String[] { Long.class.getName(), Integer.class.getName() });
115 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_E = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
116 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
117 FINDER_CLASS_NAME_LIST, "findByG_E",
118 new String[] {
119 Long.class.getName(), Integer.class.getName(),
120
121 "java.lang.Integer", "java.lang.Integer",
122 "com.liferay.portal.kernel.util.OrderByComparator"
123 });
124 public static final FinderPath FINDER_PATH_COUNT_BY_G_E = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
125 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
126 FINDER_CLASS_NAME_LIST, "countByG_E",
127 new String[] { Long.class.getName(), Integer.class.getName() });
128 public static final FinderPath FINDER_PATH_FIND_BY_C_E = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
129 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
130 FINDER_CLASS_NAME_LIST, "findByC_E",
131 new String[] { Long.class.getName(), Integer.class.getName() });
132 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_E = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
133 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
134 FINDER_CLASS_NAME_LIST, "findByC_E",
135 new String[] {
136 Long.class.getName(), Integer.class.getName(),
137
138 "java.lang.Integer", "java.lang.Integer",
139 "com.liferay.portal.kernel.util.OrderByComparator"
140 });
141 public static final FinderPath FINDER_PATH_COUNT_BY_C_E = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
142 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
143 FINDER_CLASS_NAME_LIST, "countByC_E",
144 new String[] { Long.class.getName(), Integer.class.getName() });
145 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
146 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
147 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
148 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
149 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
150 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
151
152 public void cacheResult(BlogsStatsUser blogsStatsUser) {
153 EntityCacheUtil.putResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
154 BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey(),
155 blogsStatsUser);
156
157 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
158 new Object[] {
159 new Long(blogsStatsUser.getGroupId()),
160 new Long(blogsStatsUser.getUserId())
161 }, blogsStatsUser);
162 }
163
164 public void cacheResult(List<BlogsStatsUser> blogsStatsUsers) {
165 for (BlogsStatsUser blogsStatsUser : blogsStatsUsers) {
166 if (EntityCacheUtil.getResult(
167 BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
168 BlogsStatsUserImpl.class,
169 blogsStatsUser.getPrimaryKey(), this) == null) {
170 cacheResult(blogsStatsUser);
171 }
172 }
173 }
174
175 public void clearCache() {
176 CacheRegistry.clear(BlogsStatsUserImpl.class.getName());
177 EntityCacheUtil.clearCache(BlogsStatsUserImpl.class.getName());
178 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
179 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
180 }
181
182 public BlogsStatsUser create(long statsUserId) {
183 BlogsStatsUser blogsStatsUser = new BlogsStatsUserImpl();
184
185 blogsStatsUser.setNew(true);
186 blogsStatsUser.setPrimaryKey(statsUserId);
187
188 return blogsStatsUser;
189 }
190
191 public BlogsStatsUser remove(Serializable primaryKey)
192 throws NoSuchModelException, SystemException {
193 return remove(((Long)primaryKey).longValue());
194 }
195
196 public BlogsStatsUser remove(long statsUserId)
197 throws NoSuchStatsUserException, SystemException {
198 Session session = null;
199
200 try {
201 session = openSession();
202
203 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
204 new Long(statsUserId));
205
206 if (blogsStatsUser == null) {
207 if (_log.isWarnEnabled()) {
208 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsUserId);
209 }
210
211 throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
212 statsUserId);
213 }
214
215 return remove(blogsStatsUser);
216 }
217 catch (NoSuchStatsUserException nsee) {
218 throw nsee;
219 }
220 catch (Exception e) {
221 throw processException(e);
222 }
223 finally {
224 closeSession(session);
225 }
226 }
227
228 public BlogsStatsUser remove(BlogsStatsUser blogsStatsUser)
229 throws SystemException {
230 for (ModelListener<BlogsStatsUser> listener : listeners) {
231 listener.onBeforeRemove(blogsStatsUser);
232 }
233
234 blogsStatsUser = removeImpl(blogsStatsUser);
235
236 for (ModelListener<BlogsStatsUser> listener : listeners) {
237 listener.onAfterRemove(blogsStatsUser);
238 }
239
240 return blogsStatsUser;
241 }
242
243 protected BlogsStatsUser removeImpl(BlogsStatsUser blogsStatsUser)
244 throws SystemException {
245 blogsStatsUser = toUnwrappedModel(blogsStatsUser);
246
247 Session session = null;
248
249 try {
250 session = openSession();
251
252 if (blogsStatsUser.isCachedModel() || BatchSessionUtil.isEnabled()) {
253 Object staleObject = session.get(BlogsStatsUserImpl.class,
254 blogsStatsUser.getPrimaryKeyObj());
255
256 if (staleObject != null) {
257 session.evict(staleObject);
258 }
259 }
260
261 session.delete(blogsStatsUser);
262
263 session.flush();
264 }
265 catch (Exception e) {
266 throw processException(e);
267 }
268 finally {
269 closeSession(session);
270 }
271
272 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
273
274 BlogsStatsUserModelImpl blogsStatsUserModelImpl = (BlogsStatsUserModelImpl)blogsStatsUser;
275
276 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
277 new Object[] {
278 new Long(blogsStatsUserModelImpl.getOriginalGroupId()),
279 new Long(blogsStatsUserModelImpl.getOriginalUserId())
280 });
281
282 EntityCacheUtil.removeResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
283 BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey());
284
285 return blogsStatsUser;
286 }
287
288
291 public BlogsStatsUser update(BlogsStatsUser blogsStatsUser)
292 throws SystemException {
293 if (_log.isWarnEnabled()) {
294 _log.warn(
295 "Using the deprecated update(BlogsStatsUser blogsStatsUser) method. Use update(BlogsStatsUser blogsStatsUser, boolean merge) instead.");
296 }
297
298 return update(blogsStatsUser, false);
299 }
300
301 public BlogsStatsUser updateImpl(
302 com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser,
303 boolean merge) throws SystemException {
304 blogsStatsUser = toUnwrappedModel(blogsStatsUser);
305
306 boolean isNew = blogsStatsUser.isNew();
307
308 BlogsStatsUserModelImpl blogsStatsUserModelImpl = (BlogsStatsUserModelImpl)blogsStatsUser;
309
310 Session session = null;
311
312 try {
313 session = openSession();
314
315 BatchSessionUtil.update(session, blogsStatsUser, merge);
316
317 blogsStatsUser.setNew(false);
318 }
319 catch (Exception e) {
320 throw processException(e);
321 }
322 finally {
323 closeSession(session);
324 }
325
326 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
327
328 EntityCacheUtil.putResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
329 BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey(),
330 blogsStatsUser);
331
332 if (!isNew &&
333 ((blogsStatsUser.getGroupId() != blogsStatsUserModelImpl.getOriginalGroupId()) ||
334 (blogsStatsUser.getUserId() != blogsStatsUserModelImpl.getOriginalUserId()))) {
335 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
336 new Object[] {
337 new Long(blogsStatsUserModelImpl.getOriginalGroupId()),
338 new Long(blogsStatsUserModelImpl.getOriginalUserId())
339 });
340 }
341
342 if (isNew ||
343 ((blogsStatsUser.getGroupId() != blogsStatsUserModelImpl.getOriginalGroupId()) ||
344 (blogsStatsUser.getUserId() != blogsStatsUserModelImpl.getOriginalUserId()))) {
345 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
346 new Object[] {
347 new Long(blogsStatsUser.getGroupId()),
348 new Long(blogsStatsUser.getUserId())
349 }, blogsStatsUser);
350 }
351
352 return blogsStatsUser;
353 }
354
355 protected BlogsStatsUser toUnwrappedModel(BlogsStatsUser blogsStatsUser) {
356 if (blogsStatsUser instanceof BlogsStatsUserImpl) {
357 return blogsStatsUser;
358 }
359
360 BlogsStatsUserImpl blogsStatsUserImpl = new BlogsStatsUserImpl();
361
362 blogsStatsUserImpl.setNew(blogsStatsUser.isNew());
363 blogsStatsUserImpl.setPrimaryKey(blogsStatsUser.getPrimaryKey());
364
365 blogsStatsUserImpl.setStatsUserId(blogsStatsUser.getStatsUserId());
366 blogsStatsUserImpl.setGroupId(blogsStatsUser.getGroupId());
367 blogsStatsUserImpl.setCompanyId(blogsStatsUser.getCompanyId());
368 blogsStatsUserImpl.setUserId(blogsStatsUser.getUserId());
369 blogsStatsUserImpl.setEntryCount(blogsStatsUser.getEntryCount());
370 blogsStatsUserImpl.setLastPostDate(blogsStatsUser.getLastPostDate());
371 blogsStatsUserImpl.setRatingsTotalEntries(blogsStatsUser.getRatingsTotalEntries());
372 blogsStatsUserImpl.setRatingsTotalScore(blogsStatsUser.getRatingsTotalScore());
373 blogsStatsUserImpl.setRatingsAverageScore(blogsStatsUser.getRatingsAverageScore());
374
375 return blogsStatsUserImpl;
376 }
377
378 public BlogsStatsUser findByPrimaryKey(Serializable primaryKey)
379 throws NoSuchModelException, SystemException {
380 return findByPrimaryKey(((Long)primaryKey).longValue());
381 }
382
383 public BlogsStatsUser findByPrimaryKey(long statsUserId)
384 throws NoSuchStatsUserException, SystemException {
385 BlogsStatsUser blogsStatsUser = fetchByPrimaryKey(statsUserId);
386
387 if (blogsStatsUser == null) {
388 if (_log.isWarnEnabled()) {
389 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsUserId);
390 }
391
392 throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
393 statsUserId);
394 }
395
396 return blogsStatsUser;
397 }
398
399 public BlogsStatsUser fetchByPrimaryKey(Serializable primaryKey)
400 throws SystemException {
401 return fetchByPrimaryKey(((Long)primaryKey).longValue());
402 }
403
404 public BlogsStatsUser fetchByPrimaryKey(long statsUserId)
405 throws SystemException {
406 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)EntityCacheUtil.getResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
407 BlogsStatsUserImpl.class, statsUserId, this);
408
409 if (blogsStatsUser == null) {
410 Session session = null;
411
412 try {
413 session = openSession();
414
415 blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
416 new Long(statsUserId));
417 }
418 catch (Exception e) {
419 throw processException(e);
420 }
421 finally {
422 if (blogsStatsUser != null) {
423 cacheResult(blogsStatsUser);
424 }
425
426 closeSession(session);
427 }
428 }
429
430 return blogsStatsUser;
431 }
432
433 public List<BlogsStatsUser> findByGroupId(long groupId)
434 throws SystemException {
435 Object[] finderArgs = new Object[] { new Long(groupId) };
436
437 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
438 finderArgs, this);
439
440 if (list == null) {
441 Session session = null;
442
443 try {
444 session = openSession();
445
446 StringBundler query = new StringBundler(3);
447
448 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
449
450 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
451
452 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
453
454 String sql = query.toString();
455
456 Query q = session.createQuery(sql);
457
458 QueryPos qPos = QueryPos.getInstance(q);
459
460 qPos.add(groupId);
461
462 list = q.list();
463 }
464 catch (Exception e) {
465 throw processException(e);
466 }
467 finally {
468 if (list == null) {
469 list = new ArrayList<BlogsStatsUser>();
470 }
471
472 cacheResult(list);
473
474 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
475 finderArgs, list);
476
477 closeSession(session);
478 }
479 }
480
481 return list;
482 }
483
484 public List<BlogsStatsUser> findByGroupId(long groupId, int start, int end)
485 throws SystemException {
486 return findByGroupId(groupId, start, end, null);
487 }
488
489 public List<BlogsStatsUser> findByGroupId(long groupId, int start, int end,
490 OrderByComparator obc) throws SystemException {
491 Object[] finderArgs = new Object[] {
492 new Long(groupId),
493
494 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
495 };
496
497 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
498 finderArgs, this);
499
500 if (list == null) {
501 Session session = null;
502
503 try {
504 session = openSession();
505
506 StringBundler query = null;
507
508 if (obc != null) {
509 query = new StringBundler(3 +
510 (obc.getOrderByFields().length * 3));
511 }
512 else {
513 query = new StringBundler(3);
514 }
515
516 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
517
518 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
519
520 if (obc != null) {
521 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
522 }
523
524 else {
525 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
526 }
527
528 String sql = query.toString();
529
530 Query q = session.createQuery(sql);
531
532 QueryPos qPos = QueryPos.getInstance(q);
533
534 qPos.add(groupId);
535
536 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
537 start, end);
538 }
539 catch (Exception e) {
540 throw processException(e);
541 }
542 finally {
543 if (list == null) {
544 list = new ArrayList<BlogsStatsUser>();
545 }
546
547 cacheResult(list);
548
549 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
550 finderArgs, list);
551
552 closeSession(session);
553 }
554 }
555
556 return list;
557 }
558
559 public BlogsStatsUser findByGroupId_First(long groupId,
560 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
561 List<BlogsStatsUser> list = findByGroupId(groupId, 0, 1, obc);
562
563 if (list.isEmpty()) {
564 StringBundler msg = new StringBundler(4);
565
566 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
567
568 msg.append("groupId=");
569 msg.append(groupId);
570
571 msg.append(StringPool.CLOSE_CURLY_BRACE);
572
573 throw new NoSuchStatsUserException(msg.toString());
574 }
575 else {
576 return list.get(0);
577 }
578 }
579
580 public BlogsStatsUser findByGroupId_Last(long groupId, OrderByComparator obc)
581 throws NoSuchStatsUserException, SystemException {
582 int count = countByGroupId(groupId);
583
584 List<BlogsStatsUser> list = findByGroupId(groupId, count - 1, count, obc);
585
586 if (list.isEmpty()) {
587 StringBundler msg = new StringBundler(4);
588
589 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
590
591 msg.append("groupId=");
592 msg.append(groupId);
593
594 msg.append(StringPool.CLOSE_CURLY_BRACE);
595
596 throw new NoSuchStatsUserException(msg.toString());
597 }
598 else {
599 return list.get(0);
600 }
601 }
602
603 public BlogsStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
604 long groupId, OrderByComparator obc)
605 throws NoSuchStatsUserException, SystemException {
606 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
607
608 int count = countByGroupId(groupId);
609
610 Session session = null;
611
612 try {
613 session = openSession();
614
615 StringBundler query = null;
616
617 if (obc != null) {
618 query = new StringBundler(3 +
619 (obc.getOrderByFields().length * 3));
620 }
621 else {
622 query = new StringBundler(3);
623 }
624
625 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
626
627 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
628
629 if (obc != null) {
630 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
631 }
632
633 else {
634 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
635 }
636
637 String sql = query.toString();
638
639 Query q = session.createQuery(sql);
640
641 QueryPos qPos = QueryPos.getInstance(q);
642
643 qPos.add(groupId);
644
645 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
646 blogsStatsUser);
647
648 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
649
650 array[0] = (BlogsStatsUser)objArray[0];
651 array[1] = (BlogsStatsUser)objArray[1];
652 array[2] = (BlogsStatsUser)objArray[2];
653
654 return array;
655 }
656 catch (Exception e) {
657 throw processException(e);
658 }
659 finally {
660 closeSession(session);
661 }
662 }
663
664 public List<BlogsStatsUser> findByUserId(long userId)
665 throws SystemException {
666 Object[] finderArgs = new Object[] { new Long(userId) };
667
668 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
669 finderArgs, this);
670
671 if (list == null) {
672 Session session = null;
673
674 try {
675 session = openSession();
676
677 StringBundler query = new StringBundler(3);
678
679 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
680
681 query.append(_FINDER_COLUMN_USERID_USERID_2);
682
683 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
684
685 String sql = query.toString();
686
687 Query q = session.createQuery(sql);
688
689 QueryPos qPos = QueryPos.getInstance(q);
690
691 qPos.add(userId);
692
693 list = q.list();
694 }
695 catch (Exception e) {
696 throw processException(e);
697 }
698 finally {
699 if (list == null) {
700 list = new ArrayList<BlogsStatsUser>();
701 }
702
703 cacheResult(list);
704
705 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
706 finderArgs, list);
707
708 closeSession(session);
709 }
710 }
711
712 return list;
713 }
714
715 public List<BlogsStatsUser> findByUserId(long userId, int start, int end)
716 throws SystemException {
717 return findByUserId(userId, start, end, null);
718 }
719
720 public List<BlogsStatsUser> findByUserId(long userId, int start, int end,
721 OrderByComparator obc) throws SystemException {
722 Object[] finderArgs = new Object[] {
723 new Long(userId),
724
725 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
726 };
727
728 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_USERID,
729 finderArgs, this);
730
731 if (list == null) {
732 Session session = null;
733
734 try {
735 session = openSession();
736
737 StringBundler query = null;
738
739 if (obc != null) {
740 query = new StringBundler(3 +
741 (obc.getOrderByFields().length * 3));
742 }
743 else {
744 query = new StringBundler(3);
745 }
746
747 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
748
749 query.append(_FINDER_COLUMN_USERID_USERID_2);
750
751 if (obc != null) {
752 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
753 }
754
755 else {
756 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
757 }
758
759 String sql = query.toString();
760
761 Query q = session.createQuery(sql);
762
763 QueryPos qPos = QueryPos.getInstance(q);
764
765 qPos.add(userId);
766
767 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
768 start, end);
769 }
770 catch (Exception e) {
771 throw processException(e);
772 }
773 finally {
774 if (list == null) {
775 list = new ArrayList<BlogsStatsUser>();
776 }
777
778 cacheResult(list);
779
780 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_USERID,
781 finderArgs, list);
782
783 closeSession(session);
784 }
785 }
786
787 return list;
788 }
789
790 public BlogsStatsUser findByUserId_First(long userId, OrderByComparator obc)
791 throws NoSuchStatsUserException, SystemException {
792 List<BlogsStatsUser> list = findByUserId(userId, 0, 1, obc);
793
794 if (list.isEmpty()) {
795 StringBundler msg = new StringBundler(4);
796
797 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
798
799 msg.append("userId=");
800 msg.append(userId);
801
802 msg.append(StringPool.CLOSE_CURLY_BRACE);
803
804 throw new NoSuchStatsUserException(msg.toString());
805 }
806 else {
807 return list.get(0);
808 }
809 }
810
811 public BlogsStatsUser findByUserId_Last(long userId, OrderByComparator obc)
812 throws NoSuchStatsUserException, SystemException {
813 int count = countByUserId(userId);
814
815 List<BlogsStatsUser> list = findByUserId(userId, count - 1, count, obc);
816
817 if (list.isEmpty()) {
818 StringBundler msg = new StringBundler(4);
819
820 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
821
822 msg.append("userId=");
823 msg.append(userId);
824
825 msg.append(StringPool.CLOSE_CURLY_BRACE);
826
827 throw new NoSuchStatsUserException(msg.toString());
828 }
829 else {
830 return list.get(0);
831 }
832 }
833
834 public BlogsStatsUser[] findByUserId_PrevAndNext(long statsUserId,
835 long userId, OrderByComparator obc)
836 throws NoSuchStatsUserException, SystemException {
837 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
838
839 int count = countByUserId(userId);
840
841 Session session = null;
842
843 try {
844 session = openSession();
845
846 StringBundler query = null;
847
848 if (obc != null) {
849 query = new StringBundler(3 +
850 (obc.getOrderByFields().length * 3));
851 }
852 else {
853 query = new StringBundler(3);
854 }
855
856 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
857
858 query.append(_FINDER_COLUMN_USERID_USERID_2);
859
860 if (obc != null) {
861 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
862 }
863
864 else {
865 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
866 }
867
868 String sql = query.toString();
869
870 Query q = session.createQuery(sql);
871
872 QueryPos qPos = QueryPos.getInstance(q);
873
874 qPos.add(userId);
875
876 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
877 blogsStatsUser);
878
879 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
880
881 array[0] = (BlogsStatsUser)objArray[0];
882 array[1] = (BlogsStatsUser)objArray[1];
883 array[2] = (BlogsStatsUser)objArray[2];
884
885 return array;
886 }
887 catch (Exception e) {
888 throw processException(e);
889 }
890 finally {
891 closeSession(session);
892 }
893 }
894
895 public BlogsStatsUser findByG_U(long groupId, long userId)
896 throws NoSuchStatsUserException, SystemException {
897 BlogsStatsUser blogsStatsUser = fetchByG_U(groupId, userId);
898
899 if (blogsStatsUser == null) {
900 StringBundler msg = new StringBundler(6);
901
902 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
903
904 msg.append("groupId=");
905 msg.append(groupId);
906
907 msg.append(", userId=");
908 msg.append(userId);
909
910 msg.append(StringPool.CLOSE_CURLY_BRACE);
911
912 if (_log.isWarnEnabled()) {
913 _log.warn(msg.toString());
914 }
915
916 throw new NoSuchStatsUserException(msg.toString());
917 }
918
919 return blogsStatsUser;
920 }
921
922 public BlogsStatsUser fetchByG_U(long groupId, long userId)
923 throws SystemException {
924 return fetchByG_U(groupId, userId, true);
925 }
926
927 public BlogsStatsUser fetchByG_U(long groupId, long userId,
928 boolean retrieveFromCache) throws SystemException {
929 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
930
931 Object result = null;
932
933 if (retrieveFromCache) {
934 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_U,
935 finderArgs, this);
936 }
937
938 if (result == null) {
939 Session session = null;
940
941 try {
942 session = openSession();
943
944 StringBundler query = new StringBundler(4);
945
946 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
947
948 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
949
950 query.append(_FINDER_COLUMN_G_U_USERID_2);
951
952 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
953
954 String sql = query.toString();
955
956 Query q = session.createQuery(sql);
957
958 QueryPos qPos = QueryPos.getInstance(q);
959
960 qPos.add(groupId);
961
962 qPos.add(userId);
963
964 List<BlogsStatsUser> list = q.list();
965
966 result = list;
967
968 BlogsStatsUser blogsStatsUser = null;
969
970 if (list.isEmpty()) {
971 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
972 finderArgs, list);
973 }
974 else {
975 blogsStatsUser = list.get(0);
976
977 cacheResult(blogsStatsUser);
978
979 if ((blogsStatsUser.getGroupId() != groupId) ||
980 (blogsStatsUser.getUserId() != userId)) {
981 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
982 finderArgs, blogsStatsUser);
983 }
984 }
985
986 return blogsStatsUser;
987 }
988 catch (Exception e) {
989 throw processException(e);
990 }
991 finally {
992 if (result == null) {
993 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
994 finderArgs, new ArrayList<BlogsStatsUser>());
995 }
996
997 closeSession(session);
998 }
999 }
1000 else {
1001 if (result instanceof List<?>) {
1002 return null;
1003 }
1004 else {
1005 return (BlogsStatsUser)result;
1006 }
1007 }
1008 }
1009
1010 public List<BlogsStatsUser> findByG_E(long groupId, int entryCount)
1011 throws SystemException {
1012 Object[] finderArgs = new Object[] {
1013 new Long(groupId), new Integer(entryCount)
1014 };
1015
1016 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_E,
1017 finderArgs, this);
1018
1019 if (list == null) {
1020 Session session = null;
1021
1022 try {
1023 session = openSession();
1024
1025 StringBundler query = new StringBundler(4);
1026
1027 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1028
1029 query.append(_FINDER_COLUMN_G_E_GROUPID_2);
1030
1031 query.append(_FINDER_COLUMN_G_E_ENTRYCOUNT_2);
1032
1033 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1034
1035 String sql = query.toString();
1036
1037 Query q = session.createQuery(sql);
1038
1039 QueryPos qPos = QueryPos.getInstance(q);
1040
1041 qPos.add(groupId);
1042
1043 qPos.add(entryCount);
1044
1045 list = q.list();
1046 }
1047 catch (Exception e) {
1048 throw processException(e);
1049 }
1050 finally {
1051 if (list == null) {
1052 list = new ArrayList<BlogsStatsUser>();
1053 }
1054
1055 cacheResult(list);
1056
1057 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_E, finderArgs,
1058 list);
1059
1060 closeSession(session);
1061 }
1062 }
1063
1064 return list;
1065 }
1066
1067 public List<BlogsStatsUser> findByG_E(long groupId, int entryCount,
1068 int start, int end) throws SystemException {
1069 return findByG_E(groupId, entryCount, start, end, null);
1070 }
1071
1072 public List<BlogsStatsUser> findByG_E(long groupId, int entryCount,
1073 int start, int end, OrderByComparator obc) throws SystemException {
1074 Object[] finderArgs = new Object[] {
1075 new Long(groupId), new Integer(entryCount),
1076
1077 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1078 };
1079
1080 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_E,
1081 finderArgs, this);
1082
1083 if (list == null) {
1084 Session session = null;
1085
1086 try {
1087 session = openSession();
1088
1089 StringBundler query = null;
1090
1091 if (obc != null) {
1092 query = new StringBundler(4 +
1093 (obc.getOrderByFields().length * 3));
1094 }
1095 else {
1096 query = new StringBundler(4);
1097 }
1098
1099 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1100
1101 query.append(_FINDER_COLUMN_G_E_GROUPID_2);
1102
1103 query.append(_FINDER_COLUMN_G_E_ENTRYCOUNT_2);
1104
1105 if (obc != null) {
1106 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1107 }
1108
1109 else {
1110 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1111 }
1112
1113 String sql = query.toString();
1114
1115 Query q = session.createQuery(sql);
1116
1117 QueryPos qPos = QueryPos.getInstance(q);
1118
1119 qPos.add(groupId);
1120
1121 qPos.add(entryCount);
1122
1123 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
1124 start, end);
1125 }
1126 catch (Exception e) {
1127 throw processException(e);
1128 }
1129 finally {
1130 if (list == null) {
1131 list = new ArrayList<BlogsStatsUser>();
1132 }
1133
1134 cacheResult(list);
1135
1136 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_E,
1137 finderArgs, list);
1138
1139 closeSession(session);
1140 }
1141 }
1142
1143 return list;
1144 }
1145
1146 public BlogsStatsUser findByG_E_First(long groupId, int entryCount,
1147 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1148 List<BlogsStatsUser> list = findByG_E(groupId, entryCount, 0, 1, obc);
1149
1150 if (list.isEmpty()) {
1151 StringBundler msg = new StringBundler(6);
1152
1153 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1154
1155 msg.append("groupId=");
1156 msg.append(groupId);
1157
1158 msg.append(", entryCount=");
1159 msg.append(entryCount);
1160
1161 msg.append(StringPool.CLOSE_CURLY_BRACE);
1162
1163 throw new NoSuchStatsUserException(msg.toString());
1164 }
1165 else {
1166 return list.get(0);
1167 }
1168 }
1169
1170 public BlogsStatsUser findByG_E_Last(long groupId, int entryCount,
1171 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1172 int count = countByG_E(groupId, entryCount);
1173
1174 List<BlogsStatsUser> list = findByG_E(groupId, entryCount, count - 1,
1175 count, obc);
1176
1177 if (list.isEmpty()) {
1178 StringBundler msg = new StringBundler(6);
1179
1180 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1181
1182 msg.append("groupId=");
1183 msg.append(groupId);
1184
1185 msg.append(", entryCount=");
1186 msg.append(entryCount);
1187
1188 msg.append(StringPool.CLOSE_CURLY_BRACE);
1189
1190 throw new NoSuchStatsUserException(msg.toString());
1191 }
1192 else {
1193 return list.get(0);
1194 }
1195 }
1196
1197 public BlogsStatsUser[] findByG_E_PrevAndNext(long statsUserId,
1198 long groupId, int entryCount, OrderByComparator obc)
1199 throws NoSuchStatsUserException, SystemException {
1200 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1201
1202 int count = countByG_E(groupId, entryCount);
1203
1204 Session session = null;
1205
1206 try {
1207 session = openSession();
1208
1209 StringBundler query = null;
1210
1211 if (obc != null) {
1212 query = new StringBundler(4 +
1213 (obc.getOrderByFields().length * 3));
1214 }
1215 else {
1216 query = new StringBundler(4);
1217 }
1218
1219 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1220
1221 query.append(_FINDER_COLUMN_G_E_GROUPID_2);
1222
1223 query.append(_FINDER_COLUMN_G_E_ENTRYCOUNT_2);
1224
1225 if (obc != null) {
1226 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1227 }
1228
1229 else {
1230 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1231 }
1232
1233 String sql = query.toString();
1234
1235 Query q = session.createQuery(sql);
1236
1237 QueryPos qPos = QueryPos.getInstance(q);
1238
1239 qPos.add(groupId);
1240
1241 qPos.add(entryCount);
1242
1243 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1244 blogsStatsUser);
1245
1246 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1247
1248 array[0] = (BlogsStatsUser)objArray[0];
1249 array[1] = (BlogsStatsUser)objArray[1];
1250 array[2] = (BlogsStatsUser)objArray[2];
1251
1252 return array;
1253 }
1254 catch (Exception e) {
1255 throw processException(e);
1256 }
1257 finally {
1258 closeSession(session);
1259 }
1260 }
1261
1262 public List<BlogsStatsUser> findByC_E(long companyId, int entryCount)
1263 throws SystemException {
1264 Object[] finderArgs = new Object[] {
1265 new Long(companyId), new Integer(entryCount)
1266 };
1267
1268 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_E,
1269 finderArgs, this);
1270
1271 if (list == null) {
1272 Session session = null;
1273
1274 try {
1275 session = openSession();
1276
1277 StringBundler query = new StringBundler(4);
1278
1279 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1280
1281 query.append(_FINDER_COLUMN_C_E_COMPANYID_2);
1282
1283 query.append(_FINDER_COLUMN_C_E_ENTRYCOUNT_2);
1284
1285 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1286
1287 String sql = query.toString();
1288
1289 Query q = session.createQuery(sql);
1290
1291 QueryPos qPos = QueryPos.getInstance(q);
1292
1293 qPos.add(companyId);
1294
1295 qPos.add(entryCount);
1296
1297 list = q.list();
1298 }
1299 catch (Exception e) {
1300 throw processException(e);
1301 }
1302 finally {
1303 if (list == null) {
1304 list = new ArrayList<BlogsStatsUser>();
1305 }
1306
1307 cacheResult(list);
1308
1309 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_E, finderArgs,
1310 list);
1311
1312 closeSession(session);
1313 }
1314 }
1315
1316 return list;
1317 }
1318
1319 public List<BlogsStatsUser> findByC_E(long companyId, int entryCount,
1320 int start, int end) throws SystemException {
1321 return findByC_E(companyId, entryCount, start, end, null);
1322 }
1323
1324 public List<BlogsStatsUser> findByC_E(long companyId, int entryCount,
1325 int start, int end, OrderByComparator obc) throws SystemException {
1326 Object[] finderArgs = new Object[] {
1327 new Long(companyId), new Integer(entryCount),
1328
1329 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1330 };
1331
1332 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_E,
1333 finderArgs, this);
1334
1335 if (list == null) {
1336 Session session = null;
1337
1338 try {
1339 session = openSession();
1340
1341 StringBundler query = null;
1342
1343 if (obc != null) {
1344 query = new StringBundler(4 +
1345 (obc.getOrderByFields().length * 3));
1346 }
1347 else {
1348 query = new StringBundler(4);
1349 }
1350
1351 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1352
1353 query.append(_FINDER_COLUMN_C_E_COMPANYID_2);
1354
1355 query.append(_FINDER_COLUMN_C_E_ENTRYCOUNT_2);
1356
1357 if (obc != null) {
1358 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1359 }
1360
1361 else {
1362 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1363 }
1364
1365 String sql = query.toString();
1366
1367 Query q = session.createQuery(sql);
1368
1369 QueryPos qPos = QueryPos.getInstance(q);
1370
1371 qPos.add(companyId);
1372
1373 qPos.add(entryCount);
1374
1375 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
1376 start, end);
1377 }
1378 catch (Exception e) {
1379 throw processException(e);
1380 }
1381 finally {
1382 if (list == null) {
1383 list = new ArrayList<BlogsStatsUser>();
1384 }
1385
1386 cacheResult(list);
1387
1388 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_E,
1389 finderArgs, list);
1390
1391 closeSession(session);
1392 }
1393 }
1394
1395 return list;
1396 }
1397
1398 public BlogsStatsUser findByC_E_First(long companyId, int entryCount,
1399 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1400 List<BlogsStatsUser> list = findByC_E(companyId, entryCount, 0, 1, obc);
1401
1402 if (list.isEmpty()) {
1403 StringBundler msg = new StringBundler(6);
1404
1405 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1406
1407 msg.append("companyId=");
1408 msg.append(companyId);
1409
1410 msg.append(", entryCount=");
1411 msg.append(entryCount);
1412
1413 msg.append(StringPool.CLOSE_CURLY_BRACE);
1414
1415 throw new NoSuchStatsUserException(msg.toString());
1416 }
1417 else {
1418 return list.get(0);
1419 }
1420 }
1421
1422 public BlogsStatsUser findByC_E_Last(long companyId, int entryCount,
1423 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1424 int count = countByC_E(companyId, entryCount);
1425
1426 List<BlogsStatsUser> list = findByC_E(companyId, entryCount, count - 1,
1427 count, obc);
1428
1429 if (list.isEmpty()) {
1430 StringBundler msg = new StringBundler(6);
1431
1432 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1433
1434 msg.append("companyId=");
1435 msg.append(companyId);
1436
1437 msg.append(", entryCount=");
1438 msg.append(entryCount);
1439
1440 msg.append(StringPool.CLOSE_CURLY_BRACE);
1441
1442 throw new NoSuchStatsUserException(msg.toString());
1443 }
1444 else {
1445 return list.get(0);
1446 }
1447 }
1448
1449 public BlogsStatsUser[] findByC_E_PrevAndNext(long statsUserId,
1450 long companyId, int entryCount, OrderByComparator obc)
1451 throws NoSuchStatsUserException, SystemException {
1452 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1453
1454 int count = countByC_E(companyId, entryCount);
1455
1456 Session session = null;
1457
1458 try {
1459 session = openSession();
1460
1461 StringBundler query = null;
1462
1463 if (obc != null) {
1464 query = new StringBundler(4 +
1465 (obc.getOrderByFields().length * 3));
1466 }
1467 else {
1468 query = new StringBundler(4);
1469 }
1470
1471 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1472
1473 query.append(_FINDER_COLUMN_C_E_COMPANYID_2);
1474
1475 query.append(_FINDER_COLUMN_C_E_ENTRYCOUNT_2);
1476
1477 if (obc != null) {
1478 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1479 }
1480
1481 else {
1482 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1483 }
1484
1485 String sql = query.toString();
1486
1487 Query q = session.createQuery(sql);
1488
1489 QueryPos qPos = QueryPos.getInstance(q);
1490
1491 qPos.add(companyId);
1492
1493 qPos.add(entryCount);
1494
1495 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1496 blogsStatsUser);
1497
1498 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1499
1500 array[0] = (BlogsStatsUser)objArray[0];
1501 array[1] = (BlogsStatsUser)objArray[1];
1502 array[2] = (BlogsStatsUser)objArray[2];
1503
1504 return array;
1505 }
1506 catch (Exception e) {
1507 throw processException(e);
1508 }
1509 finally {
1510 closeSession(session);
1511 }
1512 }
1513
1514 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1515 throws SystemException {
1516 Session session = null;
1517
1518 try {
1519 session = openSession();
1520
1521 dynamicQuery.compile(session);
1522
1523 return dynamicQuery.list();
1524 }
1525 catch (Exception e) {
1526 throw processException(e);
1527 }
1528 finally {
1529 closeSession(session);
1530 }
1531 }
1532
1533 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1534 int start, int end) throws SystemException {
1535 Session session = null;
1536
1537 try {
1538 session = openSession();
1539
1540 dynamicQuery.setLimit(start, end);
1541
1542 dynamicQuery.compile(session);
1543
1544 return dynamicQuery.list();
1545 }
1546 catch (Exception e) {
1547 throw processException(e);
1548 }
1549 finally {
1550 closeSession(session);
1551 }
1552 }
1553
1554 public List<BlogsStatsUser> findAll() throws SystemException {
1555 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1556 }
1557
1558 public List<BlogsStatsUser> findAll(int start, int end)
1559 throws SystemException {
1560 return findAll(start, end, null);
1561 }
1562
1563 public List<BlogsStatsUser> findAll(int start, int end,
1564 OrderByComparator obc) throws SystemException {
1565 Object[] finderArgs = new Object[] {
1566 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1567 };
1568
1569 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1570 finderArgs, this);
1571
1572 if (list == null) {
1573 Session session = null;
1574
1575 try {
1576 session = openSession();
1577
1578 StringBundler query = null;
1579 String sql = null;
1580
1581 if (obc != null) {
1582 query = new StringBundler(2 +
1583 (obc.getOrderByFields().length * 3));
1584
1585 query.append(_SQL_SELECT_BLOGSSTATSUSER);
1586
1587 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1588
1589 sql = query.toString();
1590 }
1591
1592 else {
1593 sql = _SQL_SELECT_BLOGSSTATSUSER.concat(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1594 }
1595
1596 Query q = session.createQuery(sql);
1597
1598 if (obc == null) {
1599 list = (List<BlogsStatsUser>)QueryUtil.list(q,
1600 getDialect(), start, end, false);
1601
1602 Collections.sort(list);
1603 }
1604 else {
1605 list = (List<BlogsStatsUser>)QueryUtil.list(q,
1606 getDialect(), start, end);
1607 }
1608 }
1609 catch (Exception e) {
1610 throw processException(e);
1611 }
1612 finally {
1613 if (list == null) {
1614 list = new ArrayList<BlogsStatsUser>();
1615 }
1616
1617 cacheResult(list);
1618
1619 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1620
1621 closeSession(session);
1622 }
1623 }
1624
1625 return list;
1626 }
1627
1628 public void removeByGroupId(long groupId) throws SystemException {
1629 for (BlogsStatsUser blogsStatsUser : findByGroupId(groupId)) {
1630 remove(blogsStatsUser);
1631 }
1632 }
1633
1634 public void removeByUserId(long userId) throws SystemException {
1635 for (BlogsStatsUser blogsStatsUser : findByUserId(userId)) {
1636 remove(blogsStatsUser);
1637 }
1638 }
1639
1640 public void removeByG_U(long groupId, long userId)
1641 throws NoSuchStatsUserException, SystemException {
1642 BlogsStatsUser blogsStatsUser = findByG_U(groupId, userId);
1643
1644 remove(blogsStatsUser);
1645 }
1646
1647 public void removeByG_E(long groupId, int entryCount)
1648 throws SystemException {
1649 for (BlogsStatsUser blogsStatsUser : findByG_E(groupId, entryCount)) {
1650 remove(blogsStatsUser);
1651 }
1652 }
1653
1654 public void removeByC_E(long companyId, int entryCount)
1655 throws SystemException {
1656 for (BlogsStatsUser blogsStatsUser : findByC_E(companyId, entryCount)) {
1657 remove(blogsStatsUser);
1658 }
1659 }
1660
1661 public void removeAll() throws SystemException {
1662 for (BlogsStatsUser blogsStatsUser : findAll()) {
1663 remove(blogsStatsUser);
1664 }
1665 }
1666
1667 public int countByGroupId(long groupId) throws SystemException {
1668 Object[] finderArgs = new Object[] { new Long(groupId) };
1669
1670 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1671 finderArgs, this);
1672
1673 if (count == null) {
1674 Session session = null;
1675
1676 try {
1677 session = openSession();
1678
1679 StringBundler query = new StringBundler(2);
1680
1681 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
1682
1683 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1684
1685 String sql = query.toString();
1686
1687 Query q = session.createQuery(sql);
1688
1689 QueryPos qPos = QueryPos.getInstance(q);
1690
1691 qPos.add(groupId);
1692
1693 count = (Long)q.uniqueResult();
1694 }
1695 catch (Exception e) {
1696 throw processException(e);
1697 }
1698 finally {
1699 if (count == null) {
1700 count = Long.valueOf(0);
1701 }
1702
1703 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1704 finderArgs, count);
1705
1706 closeSession(session);
1707 }
1708 }
1709
1710 return count.intValue();
1711 }
1712
1713 public int countByUserId(long userId) throws SystemException {
1714 Object[] finderArgs = new Object[] { new Long(userId) };
1715
1716 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1717 finderArgs, this);
1718
1719 if (count == null) {
1720 Session session = null;
1721
1722 try {
1723 session = openSession();
1724
1725 StringBundler query = new StringBundler(2);
1726
1727 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
1728
1729 query.append(_FINDER_COLUMN_USERID_USERID_2);
1730
1731 String sql = query.toString();
1732
1733 Query q = session.createQuery(sql);
1734
1735 QueryPos qPos = QueryPos.getInstance(q);
1736
1737 qPos.add(userId);
1738
1739 count = (Long)q.uniqueResult();
1740 }
1741 catch (Exception e) {
1742 throw processException(e);
1743 }
1744 finally {
1745 if (count == null) {
1746 count = Long.valueOf(0);
1747 }
1748
1749 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1750 finderArgs, count);
1751
1752 closeSession(session);
1753 }
1754 }
1755
1756 return count.intValue();
1757 }
1758
1759 public int countByG_U(long groupId, long userId) throws SystemException {
1760 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1761
1762 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1763 finderArgs, this);
1764
1765 if (count == null) {
1766 Session session = null;
1767
1768 try {
1769 session = openSession();
1770
1771 StringBundler query = new StringBundler(3);
1772
1773 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
1774
1775 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1776
1777 query.append(_FINDER_COLUMN_G_U_USERID_2);
1778
1779 String sql = query.toString();
1780
1781 Query q = session.createQuery(sql);
1782
1783 QueryPos qPos = QueryPos.getInstance(q);
1784
1785 qPos.add(groupId);
1786
1787 qPos.add(userId);
1788
1789 count = (Long)q.uniqueResult();
1790 }
1791 catch (Exception e) {
1792 throw processException(e);
1793 }
1794 finally {
1795 if (count == null) {
1796 count = Long.valueOf(0);
1797 }
1798
1799 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1800 count);
1801
1802 closeSession(session);
1803 }
1804 }
1805
1806 return count.intValue();
1807 }
1808
1809 public int countByG_E(long groupId, int entryCount)
1810 throws SystemException {
1811 Object[] finderArgs = new Object[] {
1812 new Long(groupId), new Integer(entryCount)
1813 };
1814
1815 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_E,
1816 finderArgs, this);
1817
1818 if (count == null) {
1819 Session session = null;
1820
1821 try {
1822 session = openSession();
1823
1824 StringBundler query = new StringBundler(3);
1825
1826 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
1827
1828 query.append(_FINDER_COLUMN_G_E_GROUPID_2);
1829
1830 query.append(_FINDER_COLUMN_G_E_ENTRYCOUNT_2);
1831
1832 String sql = query.toString();
1833
1834 Query q = session.createQuery(sql);
1835
1836 QueryPos qPos = QueryPos.getInstance(q);
1837
1838 qPos.add(groupId);
1839
1840 qPos.add(entryCount);
1841
1842 count = (Long)q.uniqueResult();
1843 }
1844 catch (Exception e) {
1845 throw processException(e);
1846 }
1847 finally {
1848 if (count == null) {
1849 count = Long.valueOf(0);
1850 }
1851
1852 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_E, finderArgs,
1853 count);
1854
1855 closeSession(session);
1856 }
1857 }
1858
1859 return count.intValue();
1860 }
1861
1862 public int countByC_E(long companyId, int entryCount)
1863 throws SystemException {
1864 Object[] finderArgs = new Object[] {
1865 new Long(companyId), new Integer(entryCount)
1866 };
1867
1868 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_E,
1869 finderArgs, this);
1870
1871 if (count == null) {
1872 Session session = null;
1873
1874 try {
1875 session = openSession();
1876
1877 StringBundler query = new StringBundler(3);
1878
1879 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
1880
1881 query.append(_FINDER_COLUMN_C_E_COMPANYID_2);
1882
1883 query.append(_FINDER_COLUMN_C_E_ENTRYCOUNT_2);
1884
1885 String sql = query.toString();
1886
1887 Query q = session.createQuery(sql);
1888
1889 QueryPos qPos = QueryPos.getInstance(q);
1890
1891 qPos.add(companyId);
1892
1893 qPos.add(entryCount);
1894
1895 count = (Long)q.uniqueResult();
1896 }
1897 catch (Exception e) {
1898 throw processException(e);
1899 }
1900 finally {
1901 if (count == null) {
1902 count = Long.valueOf(0);
1903 }
1904
1905 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_E, finderArgs,
1906 count);
1907
1908 closeSession(session);
1909 }
1910 }
1911
1912 return count.intValue();
1913 }
1914
1915 public int countAll() throws SystemException {
1916 Object[] finderArgs = new Object[0];
1917
1918 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1919 finderArgs, this);
1920
1921 if (count == null) {
1922 Session session = null;
1923
1924 try {
1925 session = openSession();
1926
1927 Query q = session.createQuery(_SQL_COUNT_BLOGSSTATSUSER);
1928
1929 count = (Long)q.uniqueResult();
1930 }
1931 catch (Exception e) {
1932 throw processException(e);
1933 }
1934 finally {
1935 if (count == null) {
1936 count = Long.valueOf(0);
1937 }
1938
1939 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1940 count);
1941
1942 closeSession(session);
1943 }
1944 }
1945
1946 return count.intValue();
1947 }
1948
1949 public void afterPropertiesSet() {
1950 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1951 com.liferay.portal.util.PropsUtil.get(
1952 "value.object.listener.com.liferay.portlet.blogs.model.BlogsStatsUser")));
1953
1954 if (listenerClassNames.length > 0) {
1955 try {
1956 List<ModelListener<BlogsStatsUser>> listenersList = new ArrayList<ModelListener<BlogsStatsUser>>();
1957
1958 for (String listenerClassName : listenerClassNames) {
1959 listenersList.add((ModelListener<BlogsStatsUser>)Class.forName(
1960 listenerClassName).newInstance());
1961 }
1962
1963 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1964 }
1965 catch (Exception e) {
1966 _log.error(e);
1967 }
1968 }
1969 }
1970
1971 @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence")
1972 protected com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence blogsEntryPersistence;
1973 @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence")
1974 protected com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence blogsStatsUserPersistence;
1975 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
1976 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1977 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1978 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1979 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1980 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1981 private static final String _SQL_SELECT_BLOGSSTATSUSER = "SELECT blogsStatsUser FROM BlogsStatsUser blogsStatsUser";
1982 private static final String _SQL_SELECT_BLOGSSTATSUSER_WHERE = "SELECT blogsStatsUser FROM BlogsStatsUser blogsStatsUser WHERE ";
1983 private static final String _SQL_COUNT_BLOGSSTATSUSER = "SELECT COUNT(blogsStatsUser) FROM BlogsStatsUser blogsStatsUser";
1984 private static final String _SQL_COUNT_BLOGSSTATSUSER_WHERE = "SELECT COUNT(blogsStatsUser) FROM BlogsStatsUser blogsStatsUser WHERE ";
1985 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsStatsUser.groupId = ?";
1986 private static final String _FINDER_COLUMN_USERID_USERID_2 = "blogsStatsUser.userId = ?";
1987 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "blogsStatsUser.groupId = ? AND ";
1988 private static final String _FINDER_COLUMN_G_U_USERID_2 = "blogsStatsUser.userId = ?";
1989 private static final String _FINDER_COLUMN_G_E_GROUPID_2 = "blogsStatsUser.groupId = ? AND ";
1990 private static final String _FINDER_COLUMN_G_E_ENTRYCOUNT_2 = "blogsStatsUser.entryCount != ?";
1991 private static final String _FINDER_COLUMN_C_E_COMPANYID_2 = "blogsStatsUser.companyId = ? AND ";
1992 private static final String _FINDER_COLUMN_C_E_ENTRYCOUNT_2 = "blogsStatsUser.entryCount != ?";
1993 private static final String _ORDER_BY_ENTITY_ALIAS = "blogsStatsUser.";
1994 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsStatsUser exists with the primary key ";
1995 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsStatsUser exists with the key {";
1996 private static Log _log = LogFactoryUtil.getLog(BlogsStatsUserPersistenceImpl.class);
1997}