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