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