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