1
22
23 package com.liferay.portlet.blogs.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.DynamicQuery;
27 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
28 import com.liferay.portal.kernel.util.OrderByComparator;
29 import com.liferay.portal.kernel.util.StringMaker;
30 import com.liferay.portal.kernel.util.StringPool;
31 import com.liferay.portal.service.persistence.BasePersistence;
32 import com.liferay.portal.spring.hibernate.FinderCache;
33 import com.liferay.portal.spring.hibernate.HibernateUtil;
34
35 import com.liferay.portlet.blogs.NoSuchStatsUserException;
36 import com.liferay.portlet.blogs.model.BlogsStatsUser;
37 import com.liferay.portlet.blogs.model.impl.BlogsStatsUserImpl;
38
39 import com.liferay.util.dao.hibernate.QueryUtil;
40
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43
44 import org.hibernate.Query;
45 import org.hibernate.Session;
46
47 import java.util.Collections;
48 import java.util.Iterator;
49 import java.util.List;
50
51
57 public class BlogsStatsUserPersistenceImpl extends BasePersistence
58 implements BlogsStatsUserPersistence {
59 public BlogsStatsUser create(long statsUserId) {
60 BlogsStatsUser blogsStatsUser = new BlogsStatsUserImpl();
61 blogsStatsUser.setNew(true);
62 blogsStatsUser.setPrimaryKey(statsUserId);
63
64 return blogsStatsUser;
65 }
66
67 public BlogsStatsUser remove(long statsUserId)
68 throws NoSuchStatsUserException, SystemException {
69 Session session = null;
70
71 try {
72 session = openSession();
73
74 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
75 new Long(statsUserId));
76
77 if (blogsStatsUser == null) {
78 if (_log.isWarnEnabled()) {
79 _log.warn("No BlogsStatsUser exists with the primary key " +
80 statsUserId);
81 }
82
83 throw new NoSuchStatsUserException(
84 "No BlogsStatsUser exists with the primary key " +
85 statsUserId);
86 }
87
88 return remove(blogsStatsUser);
89 }
90 catch (NoSuchStatsUserException nsee) {
91 throw nsee;
92 }
93 catch (Exception e) {
94 throw HibernateUtil.processException(e);
95 }
96 finally {
97 closeSession(session);
98 }
99 }
100
101 public BlogsStatsUser remove(BlogsStatsUser blogsStatsUser)
102 throws SystemException {
103 Session session = null;
104
105 try {
106 session = openSession();
107 session.delete(blogsStatsUser);
108 session.flush();
109
110 return blogsStatsUser;
111 }
112 catch (Exception e) {
113 throw HibernateUtil.processException(e);
114 }
115 finally {
116 closeSession(session);
117 FinderCache.clearCache(BlogsStatsUser.class.getName());
118 }
119 }
120
121 public BlogsStatsUser update(
122 com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser)
123 throws SystemException {
124 return update(blogsStatsUser, false);
125 }
126
127 public BlogsStatsUser update(
128 com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser,
129 boolean merge) throws SystemException {
130 Session session = null;
131
132 try {
133 session = openSession();
134
135 if (merge) {
136 session.merge(blogsStatsUser);
137 }
138 else {
139 if (blogsStatsUser.isNew()) {
140 session.save(blogsStatsUser);
141 }
142 }
143
144 session.flush();
145 blogsStatsUser.setNew(false);
146
147 return blogsStatsUser;
148 }
149 catch (Exception e) {
150 throw HibernateUtil.processException(e);
151 }
152 finally {
153 closeSession(session);
154 FinderCache.clearCache(BlogsStatsUser.class.getName());
155 }
156 }
157
158 public BlogsStatsUser findByPrimaryKey(long statsUserId)
159 throws NoSuchStatsUserException, SystemException {
160 BlogsStatsUser blogsStatsUser = fetchByPrimaryKey(statsUserId);
161
162 if (blogsStatsUser == null) {
163 if (_log.isWarnEnabled()) {
164 _log.warn("No BlogsStatsUser exists with the primary key " +
165 statsUserId);
166 }
167
168 throw new NoSuchStatsUserException(
169 "No BlogsStatsUser exists with the primary key " + statsUserId);
170 }
171
172 return blogsStatsUser;
173 }
174
175 public BlogsStatsUser fetchByPrimaryKey(long statsUserId)
176 throws SystemException {
177 Session session = null;
178
179 try {
180 session = openSession();
181
182 return (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
183 new Long(statsUserId));
184 }
185 catch (Exception e) {
186 throw HibernateUtil.processException(e);
187 }
188 finally {
189 closeSession(session);
190 }
191 }
192
193 public List findByGroupId(long groupId) throws SystemException {
194 String finderClassName = BlogsStatsUser.class.getName();
195 String finderMethodName = "findByGroupId";
196 String[] finderParams = new String[] { Long.class.getName() };
197 Object[] finderArgs = new Object[] { new Long(groupId) };
198 Object result = FinderCache.getResult(finderClassName,
199 finderMethodName, finderParams, finderArgs, getSessionFactory());
200
201 if (result == null) {
202 Session session = null;
203
204 try {
205 session = openSession();
206
207 StringMaker query = new StringMaker();
208 query.append(
209 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
210 query.append("groupId = ?");
211 query.append(" ");
212 query.append("ORDER BY ");
213 query.append("entryCount DESC");
214
215 Query q = session.createQuery(query.toString());
216 int queryPos = 0;
217 q.setLong(queryPos++, groupId);
218
219 List list = q.list();
220 FinderCache.putResult(finderClassName, finderMethodName,
221 finderParams, finderArgs, list);
222
223 return list;
224 }
225 catch (Exception e) {
226 throw HibernateUtil.processException(e);
227 }
228 finally {
229 closeSession(session);
230 }
231 }
232 else {
233 return (List)result;
234 }
235 }
236
237 public List findByGroupId(long groupId, int begin, int end)
238 throws SystemException {
239 return findByGroupId(groupId, begin, end, null);
240 }
241
242 public List findByGroupId(long groupId, int begin, int end,
243 OrderByComparator obc) throws SystemException {
244 String finderClassName = BlogsStatsUser.class.getName();
245 String finderMethodName = "findByGroupId";
246 String[] finderParams = new String[] {
247 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
248 "com.liferay.portal.kernel.util.OrderByComparator"
249 };
250 Object[] finderArgs = new Object[] {
251 new Long(groupId), String.valueOf(begin), String.valueOf(end),
252 String.valueOf(obc)
253 };
254 Object result = FinderCache.getResult(finderClassName,
255 finderMethodName, finderParams, finderArgs, getSessionFactory());
256
257 if (result == null) {
258 Session session = null;
259
260 try {
261 session = openSession();
262
263 StringMaker query = new StringMaker();
264 query.append(
265 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
266 query.append("groupId = ?");
267 query.append(" ");
268
269 if (obc != null) {
270 query.append("ORDER BY ");
271 query.append(obc.getOrderBy());
272 }
273 else {
274 query.append("ORDER BY ");
275 query.append("entryCount DESC");
276 }
277
278 Query q = session.createQuery(query.toString());
279 int queryPos = 0;
280 q.setLong(queryPos++, groupId);
281
282 List list = QueryUtil.list(q, getDialect(), begin, end);
283 FinderCache.putResult(finderClassName, finderMethodName,
284 finderParams, finderArgs, list);
285
286 return list;
287 }
288 catch (Exception e) {
289 throw HibernateUtil.processException(e);
290 }
291 finally {
292 closeSession(session);
293 }
294 }
295 else {
296 return (List)result;
297 }
298 }
299
300 public BlogsStatsUser findByGroupId_First(long groupId,
301 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
302 List list = findByGroupId(groupId, 0, 1, obc);
303
304 if (list.size() == 0) {
305 StringMaker msg = new StringMaker();
306 msg.append("No BlogsStatsUser exists with the key ");
307 msg.append(StringPool.OPEN_CURLY_BRACE);
308 msg.append("groupId=");
309 msg.append(groupId);
310 msg.append(StringPool.CLOSE_CURLY_BRACE);
311 throw new NoSuchStatsUserException(msg.toString());
312 }
313 else {
314 return (BlogsStatsUser)list.get(0);
315 }
316 }
317
318 public BlogsStatsUser findByGroupId_Last(long groupId, OrderByComparator obc)
319 throws NoSuchStatsUserException, SystemException {
320 int count = countByGroupId(groupId);
321 List list = findByGroupId(groupId, count - 1, count, obc);
322
323 if (list.size() == 0) {
324 StringMaker msg = new StringMaker();
325 msg.append("No BlogsStatsUser exists with the key ");
326 msg.append(StringPool.OPEN_CURLY_BRACE);
327 msg.append("groupId=");
328 msg.append(groupId);
329 msg.append(StringPool.CLOSE_CURLY_BRACE);
330 throw new NoSuchStatsUserException(msg.toString());
331 }
332 else {
333 return (BlogsStatsUser)list.get(0);
334 }
335 }
336
337 public BlogsStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
338 long groupId, OrderByComparator obc)
339 throws NoSuchStatsUserException, SystemException {
340 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
341 int count = countByGroupId(groupId);
342 Session session = null;
343
344 try {
345 session = openSession();
346
347 StringMaker query = new StringMaker();
348 query.append(
349 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
350 query.append("groupId = ?");
351 query.append(" ");
352
353 if (obc != null) {
354 query.append("ORDER BY ");
355 query.append(obc.getOrderBy());
356 }
357 else {
358 query.append("ORDER BY ");
359 query.append("entryCount DESC");
360 }
361
362 Query q = session.createQuery(query.toString());
363 int queryPos = 0;
364 q.setLong(queryPos++, groupId);
365
366 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
367 blogsStatsUser);
368 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
369 array[0] = (BlogsStatsUser)objArray[0];
370 array[1] = (BlogsStatsUser)objArray[1];
371 array[2] = (BlogsStatsUser)objArray[2];
372
373 return array;
374 }
375 catch (Exception e) {
376 throw HibernateUtil.processException(e);
377 }
378 finally {
379 closeSession(session);
380 }
381 }
382
383 public List findByUserId(long userId) throws SystemException {
384 String finderClassName = BlogsStatsUser.class.getName();
385 String finderMethodName = "findByUserId";
386 String[] finderParams = new String[] { Long.class.getName() };
387 Object[] finderArgs = new Object[] { new Long(userId) };
388 Object result = FinderCache.getResult(finderClassName,
389 finderMethodName, finderParams, finderArgs, getSessionFactory());
390
391 if (result == null) {
392 Session session = null;
393
394 try {
395 session = openSession();
396
397 StringMaker query = new StringMaker();
398 query.append(
399 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
400 query.append("userId = ?");
401 query.append(" ");
402 query.append("ORDER BY ");
403 query.append("entryCount DESC");
404
405 Query q = session.createQuery(query.toString());
406 int queryPos = 0;
407 q.setLong(queryPos++, userId);
408
409 List list = q.list();
410 FinderCache.putResult(finderClassName, finderMethodName,
411 finderParams, finderArgs, list);
412
413 return list;
414 }
415 catch (Exception e) {
416 throw HibernateUtil.processException(e);
417 }
418 finally {
419 closeSession(session);
420 }
421 }
422 else {
423 return (List)result;
424 }
425 }
426
427 public List findByUserId(long userId, int begin, int end)
428 throws SystemException {
429 return findByUserId(userId, begin, end, null);
430 }
431
432 public List findByUserId(long userId, int begin, int end,
433 OrderByComparator obc) throws SystemException {
434 String finderClassName = BlogsStatsUser.class.getName();
435 String finderMethodName = "findByUserId";
436 String[] finderParams = new String[] {
437 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
438 "com.liferay.portal.kernel.util.OrderByComparator"
439 };
440 Object[] finderArgs = new Object[] {
441 new Long(userId), String.valueOf(begin), String.valueOf(end),
442 String.valueOf(obc)
443 };
444 Object result = FinderCache.getResult(finderClassName,
445 finderMethodName, finderParams, finderArgs, getSessionFactory());
446
447 if (result == null) {
448 Session session = null;
449
450 try {
451 session = openSession();
452
453 StringMaker query = new StringMaker();
454 query.append(
455 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
456 query.append("userId = ?");
457 query.append(" ");
458
459 if (obc != null) {
460 query.append("ORDER BY ");
461 query.append(obc.getOrderBy());
462 }
463 else {
464 query.append("ORDER BY ");
465 query.append("entryCount DESC");
466 }
467
468 Query q = session.createQuery(query.toString());
469 int queryPos = 0;
470 q.setLong(queryPos++, userId);
471
472 List list = QueryUtil.list(q, getDialect(), begin, end);
473 FinderCache.putResult(finderClassName, finderMethodName,
474 finderParams, finderArgs, list);
475
476 return list;
477 }
478 catch (Exception e) {
479 throw HibernateUtil.processException(e);
480 }
481 finally {
482 closeSession(session);
483 }
484 }
485 else {
486 return (List)result;
487 }
488 }
489
490 public BlogsStatsUser findByUserId_First(long userId, OrderByComparator obc)
491 throws NoSuchStatsUserException, SystemException {
492 List list = findByUserId(userId, 0, 1, obc);
493
494 if (list.size() == 0) {
495 StringMaker msg = new StringMaker();
496 msg.append("No BlogsStatsUser exists with the key ");
497 msg.append(StringPool.OPEN_CURLY_BRACE);
498 msg.append("userId=");
499 msg.append(userId);
500 msg.append(StringPool.CLOSE_CURLY_BRACE);
501 throw new NoSuchStatsUserException(msg.toString());
502 }
503 else {
504 return (BlogsStatsUser)list.get(0);
505 }
506 }
507
508 public BlogsStatsUser findByUserId_Last(long userId, OrderByComparator obc)
509 throws NoSuchStatsUserException, SystemException {
510 int count = countByUserId(userId);
511 List list = findByUserId(userId, count - 1, count, obc);
512
513 if (list.size() == 0) {
514 StringMaker msg = new StringMaker();
515 msg.append("No BlogsStatsUser exists with the key ");
516 msg.append(StringPool.OPEN_CURLY_BRACE);
517 msg.append("userId=");
518 msg.append(userId);
519 msg.append(StringPool.CLOSE_CURLY_BRACE);
520 throw new NoSuchStatsUserException(msg.toString());
521 }
522 else {
523 return (BlogsStatsUser)list.get(0);
524 }
525 }
526
527 public BlogsStatsUser[] findByUserId_PrevAndNext(long statsUserId,
528 long userId, OrderByComparator obc)
529 throws NoSuchStatsUserException, SystemException {
530 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
531 int count = countByUserId(userId);
532 Session session = null;
533
534 try {
535 session = openSession();
536
537 StringMaker query = new StringMaker();
538 query.append(
539 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
540 query.append("userId = ?");
541 query.append(" ");
542
543 if (obc != null) {
544 query.append("ORDER BY ");
545 query.append(obc.getOrderBy());
546 }
547 else {
548 query.append("ORDER BY ");
549 query.append("entryCount DESC");
550 }
551
552 Query q = session.createQuery(query.toString());
553 int queryPos = 0;
554 q.setLong(queryPos++, userId);
555
556 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
557 blogsStatsUser);
558 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
559 array[0] = (BlogsStatsUser)objArray[0];
560 array[1] = (BlogsStatsUser)objArray[1];
561 array[2] = (BlogsStatsUser)objArray[2];
562
563 return array;
564 }
565 catch (Exception e) {
566 throw HibernateUtil.processException(e);
567 }
568 finally {
569 closeSession(session);
570 }
571 }
572
573 public BlogsStatsUser findByG_U(long groupId, long userId)
574 throws NoSuchStatsUserException, SystemException {
575 BlogsStatsUser blogsStatsUser = fetchByG_U(groupId, userId);
576
577 if (blogsStatsUser == null) {
578 StringMaker msg = new StringMaker();
579 msg.append("No BlogsStatsUser exists with the key ");
580 msg.append(StringPool.OPEN_CURLY_BRACE);
581 msg.append("groupId=");
582 msg.append(groupId);
583 msg.append(", ");
584 msg.append("userId=");
585 msg.append(userId);
586 msg.append(StringPool.CLOSE_CURLY_BRACE);
587
588 if (_log.isWarnEnabled()) {
589 _log.warn(msg.toString());
590 }
591
592 throw new NoSuchStatsUserException(msg.toString());
593 }
594
595 return blogsStatsUser;
596 }
597
598 public BlogsStatsUser fetchByG_U(long groupId, long userId)
599 throws SystemException {
600 String finderClassName = BlogsStatsUser.class.getName();
601 String finderMethodName = "fetchByG_U";
602 String[] finderParams = new String[] {
603 Long.class.getName(), Long.class.getName()
604 };
605 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
606 Object result = FinderCache.getResult(finderClassName,
607 finderMethodName, finderParams, finderArgs, getSessionFactory());
608
609 if (result == null) {
610 Session session = null;
611
612 try {
613 session = openSession();
614
615 StringMaker query = new StringMaker();
616 query.append(
617 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
618 query.append("groupId = ?");
619 query.append(" AND ");
620 query.append("userId = ?");
621 query.append(" ");
622 query.append("ORDER BY ");
623 query.append("entryCount DESC");
624
625 Query q = session.createQuery(query.toString());
626 int queryPos = 0;
627 q.setLong(queryPos++, groupId);
628 q.setLong(queryPos++, userId);
629
630 List list = q.list();
631 FinderCache.putResult(finderClassName, finderMethodName,
632 finderParams, finderArgs, list);
633
634 if (list.size() == 0) {
635 return null;
636 }
637 else {
638 return (BlogsStatsUser)list.get(0);
639 }
640 }
641 catch (Exception e) {
642 throw HibernateUtil.processException(e);
643 }
644 finally {
645 closeSession(session);
646 }
647 }
648 else {
649 List list = (List)result;
650
651 if (list.size() == 0) {
652 return null;
653 }
654 else {
655 return (BlogsStatsUser)list.get(0);
656 }
657 }
658 }
659
660 public List findByG_E(long groupId, int entryCount)
661 throws SystemException {
662 String finderClassName = BlogsStatsUser.class.getName();
663 String finderMethodName = "findByG_E";
664 String[] finderParams = new String[] {
665 Long.class.getName(), Integer.class.getName()
666 };
667 Object[] finderArgs = new Object[] {
668 new Long(groupId), new Integer(entryCount)
669 };
670 Object result = FinderCache.getResult(finderClassName,
671 finderMethodName, finderParams, finderArgs, getSessionFactory());
672
673 if (result == null) {
674 Session session = null;
675
676 try {
677 session = openSession();
678
679 StringMaker query = new StringMaker();
680 query.append(
681 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
682 query.append("groupId = ?");
683 query.append(" AND ");
684 query.append("entryCount != ?");
685 query.append(" ");
686 query.append("ORDER BY ");
687 query.append("entryCount DESC");
688
689 Query q = session.createQuery(query.toString());
690 int queryPos = 0;
691 q.setLong(queryPos++, groupId);
692 q.setInteger(queryPos++, entryCount);
693
694 List list = q.list();
695 FinderCache.putResult(finderClassName, finderMethodName,
696 finderParams, finderArgs, list);
697
698 return list;
699 }
700 catch (Exception e) {
701 throw HibernateUtil.processException(e);
702 }
703 finally {
704 closeSession(session);
705 }
706 }
707 else {
708 return (List)result;
709 }
710 }
711
712 public List findByG_E(long groupId, int entryCount, int begin, int end)
713 throws SystemException {
714 return findByG_E(groupId, entryCount, begin, end, null);
715 }
716
717 public List findByG_E(long groupId, int entryCount, int begin, int end,
718 OrderByComparator obc) throws SystemException {
719 String finderClassName = BlogsStatsUser.class.getName();
720 String finderMethodName = "findByG_E";
721 String[] finderParams = new String[] {
722 Long.class.getName(), Integer.class.getName(),
723 "java.lang.Integer", "java.lang.Integer",
724 "com.liferay.portal.kernel.util.OrderByComparator"
725 };
726 Object[] finderArgs = new Object[] {
727 new Long(groupId), new Integer(entryCount),
728 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
729 };
730 Object result = FinderCache.getResult(finderClassName,
731 finderMethodName, finderParams, finderArgs, getSessionFactory());
732
733 if (result == null) {
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 StringMaker query = new StringMaker();
740 query.append(
741 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
742 query.append("groupId = ?");
743 query.append(" AND ");
744 query.append("entryCount != ?");
745 query.append(" ");
746
747 if (obc != null) {
748 query.append("ORDER BY ");
749 query.append(obc.getOrderBy());
750 }
751 else {
752 query.append("ORDER BY ");
753 query.append("entryCount DESC");
754 }
755
756 Query q = session.createQuery(query.toString());
757 int queryPos = 0;
758 q.setLong(queryPos++, groupId);
759 q.setInteger(queryPos++, entryCount);
760
761 List list = QueryUtil.list(q, getDialect(), begin, end);
762 FinderCache.putResult(finderClassName, finderMethodName,
763 finderParams, finderArgs, list);
764
765 return list;
766 }
767 catch (Exception e) {
768 throw HibernateUtil.processException(e);
769 }
770 finally {
771 closeSession(session);
772 }
773 }
774 else {
775 return (List)result;
776 }
777 }
778
779 public BlogsStatsUser findByG_E_First(long groupId, int entryCount,
780 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
781 List list = findByG_E(groupId, entryCount, 0, 1, obc);
782
783 if (list.size() == 0) {
784 StringMaker msg = new StringMaker();
785 msg.append("No BlogsStatsUser exists with the key ");
786 msg.append(StringPool.OPEN_CURLY_BRACE);
787 msg.append("groupId=");
788 msg.append(groupId);
789 msg.append(", ");
790 msg.append("entryCount=");
791 msg.append(entryCount);
792 msg.append(StringPool.CLOSE_CURLY_BRACE);
793 throw new NoSuchStatsUserException(msg.toString());
794 }
795 else {
796 return (BlogsStatsUser)list.get(0);
797 }
798 }
799
800 public BlogsStatsUser findByG_E_Last(long groupId, int entryCount,
801 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
802 int count = countByG_E(groupId, entryCount);
803 List list = findByG_E(groupId, entryCount, count - 1, count, obc);
804
805 if (list.size() == 0) {
806 StringMaker msg = new StringMaker();
807 msg.append("No BlogsStatsUser exists with the key ");
808 msg.append(StringPool.OPEN_CURLY_BRACE);
809 msg.append("groupId=");
810 msg.append(groupId);
811 msg.append(", ");
812 msg.append("entryCount=");
813 msg.append(entryCount);
814 msg.append(StringPool.CLOSE_CURLY_BRACE);
815 throw new NoSuchStatsUserException(msg.toString());
816 }
817 else {
818 return (BlogsStatsUser)list.get(0);
819 }
820 }
821
822 public BlogsStatsUser[] findByG_E_PrevAndNext(long statsUserId,
823 long groupId, int entryCount, OrderByComparator obc)
824 throws NoSuchStatsUserException, SystemException {
825 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
826 int count = countByG_E(groupId, entryCount);
827 Session session = null;
828
829 try {
830 session = openSession();
831
832 StringMaker query = new StringMaker();
833 query.append(
834 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
835 query.append("groupId = ?");
836 query.append(" AND ");
837 query.append("entryCount != ?");
838 query.append(" ");
839
840 if (obc != null) {
841 query.append("ORDER BY ");
842 query.append(obc.getOrderBy());
843 }
844 else {
845 query.append("ORDER BY ");
846 query.append("entryCount DESC");
847 }
848
849 Query q = session.createQuery(query.toString());
850 int queryPos = 0;
851 q.setLong(queryPos++, groupId);
852 q.setInteger(queryPos++, entryCount);
853
854 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
855 blogsStatsUser);
856 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
857 array[0] = (BlogsStatsUser)objArray[0];
858 array[1] = (BlogsStatsUser)objArray[1];
859 array[2] = (BlogsStatsUser)objArray[2];
860
861 return array;
862 }
863 catch (Exception e) {
864 throw HibernateUtil.processException(e);
865 }
866 finally {
867 closeSession(session);
868 }
869 }
870
871 public List findByC_E(long companyId, int entryCount)
872 throws SystemException {
873 String finderClassName = BlogsStatsUser.class.getName();
874 String finderMethodName = "findByC_E";
875 String[] finderParams = new String[] {
876 Long.class.getName(), Integer.class.getName()
877 };
878 Object[] finderArgs = new Object[] {
879 new Long(companyId), new Integer(entryCount)
880 };
881 Object result = FinderCache.getResult(finderClassName,
882 finderMethodName, finderParams, finderArgs, getSessionFactory());
883
884 if (result == null) {
885 Session session = null;
886
887 try {
888 session = openSession();
889
890 StringMaker query = new StringMaker();
891 query.append(
892 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
893 query.append("companyId = ?");
894 query.append(" AND ");
895 query.append("entryCount != ?");
896 query.append(" ");
897 query.append("ORDER BY ");
898 query.append("entryCount DESC");
899
900 Query q = session.createQuery(query.toString());
901 int queryPos = 0;
902 q.setLong(queryPos++, companyId);
903 q.setInteger(queryPos++, entryCount);
904
905 List list = q.list();
906 FinderCache.putResult(finderClassName, finderMethodName,
907 finderParams, finderArgs, list);
908
909 return list;
910 }
911 catch (Exception e) {
912 throw HibernateUtil.processException(e);
913 }
914 finally {
915 closeSession(session);
916 }
917 }
918 else {
919 return (List)result;
920 }
921 }
922
923 public List findByC_E(long companyId, int entryCount, int begin, int end)
924 throws SystemException {
925 return findByC_E(companyId, entryCount, begin, end, null);
926 }
927
928 public List findByC_E(long companyId, int entryCount, int begin, int end,
929 OrderByComparator obc) throws SystemException {
930 String finderClassName = BlogsStatsUser.class.getName();
931 String finderMethodName = "findByC_E";
932 String[] finderParams = new String[] {
933 Long.class.getName(), Integer.class.getName(),
934 "java.lang.Integer", "java.lang.Integer",
935 "com.liferay.portal.kernel.util.OrderByComparator"
936 };
937 Object[] finderArgs = new Object[] {
938 new Long(companyId), new Integer(entryCount),
939 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
940 };
941 Object result = FinderCache.getResult(finderClassName,
942 finderMethodName, finderParams, finderArgs, getSessionFactory());
943
944 if (result == null) {
945 Session session = null;
946
947 try {
948 session = openSession();
949
950 StringMaker query = new StringMaker();
951 query.append(
952 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
953 query.append("companyId = ?");
954 query.append(" AND ");
955 query.append("entryCount != ?");
956 query.append(" ");
957
958 if (obc != null) {
959 query.append("ORDER BY ");
960 query.append(obc.getOrderBy());
961 }
962 else {
963 query.append("ORDER BY ");
964 query.append("entryCount DESC");
965 }
966
967 Query q = session.createQuery(query.toString());
968 int queryPos = 0;
969 q.setLong(queryPos++, companyId);
970 q.setInteger(queryPos++, entryCount);
971
972 List list = QueryUtil.list(q, getDialect(), begin, end);
973 FinderCache.putResult(finderClassName, finderMethodName,
974 finderParams, finderArgs, list);
975
976 return list;
977 }
978 catch (Exception e) {
979 throw HibernateUtil.processException(e);
980 }
981 finally {
982 closeSession(session);
983 }
984 }
985 else {
986 return (List)result;
987 }
988 }
989
990 public BlogsStatsUser findByC_E_First(long companyId, int entryCount,
991 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
992 List list = findByC_E(companyId, entryCount, 0, 1, obc);
993
994 if (list.size() == 0) {
995 StringMaker msg = new StringMaker();
996 msg.append("No BlogsStatsUser exists with the key ");
997 msg.append(StringPool.OPEN_CURLY_BRACE);
998 msg.append("companyId=");
999 msg.append(companyId);
1000 msg.append(", ");
1001 msg.append("entryCount=");
1002 msg.append(entryCount);
1003 msg.append(StringPool.CLOSE_CURLY_BRACE);
1004 throw new NoSuchStatsUserException(msg.toString());
1005 }
1006 else {
1007 return (BlogsStatsUser)list.get(0);
1008 }
1009 }
1010
1011 public BlogsStatsUser findByC_E_Last(long companyId, int entryCount,
1012 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1013 int count = countByC_E(companyId, entryCount);
1014 List list = findByC_E(companyId, entryCount, count - 1, count, obc);
1015
1016 if (list.size() == 0) {
1017 StringMaker msg = new StringMaker();
1018 msg.append("No BlogsStatsUser exists with the key ");
1019 msg.append(StringPool.OPEN_CURLY_BRACE);
1020 msg.append("companyId=");
1021 msg.append(companyId);
1022 msg.append(", ");
1023 msg.append("entryCount=");
1024 msg.append(entryCount);
1025 msg.append(StringPool.CLOSE_CURLY_BRACE);
1026 throw new NoSuchStatsUserException(msg.toString());
1027 }
1028 else {
1029 return (BlogsStatsUser)list.get(0);
1030 }
1031 }
1032
1033 public BlogsStatsUser[] findByC_E_PrevAndNext(long statsUserId,
1034 long companyId, int entryCount, OrderByComparator obc)
1035 throws NoSuchStatsUserException, SystemException {
1036 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1037 int count = countByC_E(companyId, entryCount);
1038 Session session = null;
1039
1040 try {
1041 session = openSession();
1042
1043 StringMaker query = new StringMaker();
1044 query.append(
1045 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1046 query.append("companyId = ?");
1047 query.append(" AND ");
1048 query.append("entryCount != ?");
1049 query.append(" ");
1050
1051 if (obc != null) {
1052 query.append("ORDER BY ");
1053 query.append(obc.getOrderBy());
1054 }
1055 else {
1056 query.append("ORDER BY ");
1057 query.append("entryCount DESC");
1058 }
1059
1060 Query q = session.createQuery(query.toString());
1061 int queryPos = 0;
1062 q.setLong(queryPos++, companyId);
1063 q.setInteger(queryPos++, entryCount);
1064
1065 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1066 blogsStatsUser);
1067 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1068 array[0] = (BlogsStatsUser)objArray[0];
1069 array[1] = (BlogsStatsUser)objArray[1];
1070 array[2] = (BlogsStatsUser)objArray[2];
1071
1072 return array;
1073 }
1074 catch (Exception e) {
1075 throw HibernateUtil.processException(e);
1076 }
1077 finally {
1078 closeSession(session);
1079 }
1080 }
1081
1082 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
1083 throws SystemException {
1084 Session session = null;
1085
1086 try {
1087 session = openSession();
1088
1089 DynamicQuery query = queryInitializer.initialize(session);
1090
1091 return query.list();
1092 }
1093 catch (Exception e) {
1094 throw HibernateUtil.processException(e);
1095 }
1096 finally {
1097 closeSession(session);
1098 }
1099 }
1100
1101 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
1102 int begin, int end) throws SystemException {
1103 Session session = null;
1104
1105 try {
1106 session = openSession();
1107
1108 DynamicQuery query = queryInitializer.initialize(session);
1109 query.setLimit(begin, end);
1110
1111 return query.list();
1112 }
1113 catch (Exception e) {
1114 throw HibernateUtil.processException(e);
1115 }
1116 finally {
1117 closeSession(session);
1118 }
1119 }
1120
1121 public List findAll() throws SystemException {
1122 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1123 }
1124
1125 public List findAll(int begin, int end) throws SystemException {
1126 return findAll(begin, end, null);
1127 }
1128
1129 public List findAll(int begin, int end, OrderByComparator obc)
1130 throws SystemException {
1131 String finderClassName = BlogsStatsUser.class.getName();
1132 String finderMethodName = "findAll";
1133 String[] finderParams = new String[] {
1134 "java.lang.Integer", "java.lang.Integer",
1135 "com.liferay.portal.kernel.util.OrderByComparator"
1136 };
1137 Object[] finderArgs = new Object[] {
1138 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1139 };
1140 Object result = FinderCache.getResult(finderClassName,
1141 finderMethodName, finderParams, finderArgs, getSessionFactory());
1142
1143 if (result == null) {
1144 Session session = null;
1145
1146 try {
1147 session = openSession();
1148
1149 StringMaker query = new StringMaker();
1150 query.append(
1151 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser ");
1152
1153 if (obc != null) {
1154 query.append("ORDER BY ");
1155 query.append(obc.getOrderBy());
1156 }
1157 else {
1158 query.append("ORDER BY ");
1159 query.append("entryCount DESC");
1160 }
1161
1162 Query q = session.createQuery(query.toString());
1163 List list = QueryUtil.list(q, getDialect(), begin, end);
1164
1165 if (obc == null) {
1166 Collections.sort(list);
1167 }
1168
1169 FinderCache.putResult(finderClassName, finderMethodName,
1170 finderParams, finderArgs, list);
1171
1172 return list;
1173 }
1174 catch (Exception e) {
1175 throw HibernateUtil.processException(e);
1176 }
1177 finally {
1178 closeSession(session);
1179 }
1180 }
1181 else {
1182 return (List)result;
1183 }
1184 }
1185
1186 public void removeByGroupId(long groupId) throws SystemException {
1187 Iterator itr = findByGroupId(groupId).iterator();
1188
1189 while (itr.hasNext()) {
1190 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)itr.next();
1191 remove(blogsStatsUser);
1192 }
1193 }
1194
1195 public void removeByUserId(long userId) throws SystemException {
1196 Iterator itr = findByUserId(userId).iterator();
1197
1198 while (itr.hasNext()) {
1199 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)itr.next();
1200 remove(blogsStatsUser);
1201 }
1202 }
1203
1204 public void removeByG_U(long groupId, long userId)
1205 throws NoSuchStatsUserException, SystemException {
1206 BlogsStatsUser blogsStatsUser = findByG_U(groupId, userId);
1207 remove(blogsStatsUser);
1208 }
1209
1210 public void removeByG_E(long groupId, int entryCount)
1211 throws SystemException {
1212 Iterator itr = findByG_E(groupId, entryCount).iterator();
1213
1214 while (itr.hasNext()) {
1215 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)itr.next();
1216 remove(blogsStatsUser);
1217 }
1218 }
1219
1220 public void removeByC_E(long companyId, int entryCount)
1221 throws SystemException {
1222 Iterator itr = findByC_E(companyId, entryCount).iterator();
1223
1224 while (itr.hasNext()) {
1225 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)itr.next();
1226 remove(blogsStatsUser);
1227 }
1228 }
1229
1230 public void removeAll() throws SystemException {
1231 Iterator itr = findAll().iterator();
1232
1233 while (itr.hasNext()) {
1234 remove((BlogsStatsUser)itr.next());
1235 }
1236 }
1237
1238 public int countByGroupId(long groupId) throws SystemException {
1239 String finderClassName = BlogsStatsUser.class.getName();
1240 String finderMethodName = "countByGroupId";
1241 String[] finderParams = new String[] { Long.class.getName() };
1242 Object[] finderArgs = new Object[] { new Long(groupId) };
1243 Object result = FinderCache.getResult(finderClassName,
1244 finderMethodName, finderParams, finderArgs, getSessionFactory());
1245
1246 if (result == null) {
1247 Session session = null;
1248
1249 try {
1250 session = openSession();
1251
1252 StringMaker query = new StringMaker();
1253 query.append("SELECT COUNT(*) ");
1254 query.append(
1255 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1256 query.append("groupId = ?");
1257 query.append(" ");
1258
1259 Query q = session.createQuery(query.toString());
1260 int queryPos = 0;
1261 q.setLong(queryPos++, groupId);
1262
1263 Long count = null;
1264 Iterator itr = q.list().iterator();
1265
1266 if (itr.hasNext()) {
1267 count = (Long)itr.next();
1268 }
1269
1270 if (count == null) {
1271 count = new Long(0);
1272 }
1273
1274 FinderCache.putResult(finderClassName, finderMethodName,
1275 finderParams, finderArgs, count);
1276
1277 return count.intValue();
1278 }
1279 catch (Exception e) {
1280 throw HibernateUtil.processException(e);
1281 }
1282 finally {
1283 closeSession(session);
1284 }
1285 }
1286 else {
1287 return ((Long)result).intValue();
1288 }
1289 }
1290
1291 public int countByUserId(long userId) throws SystemException {
1292 String finderClassName = BlogsStatsUser.class.getName();
1293 String finderMethodName = "countByUserId";
1294 String[] finderParams = new String[] { Long.class.getName() };
1295 Object[] finderArgs = new Object[] { new Long(userId) };
1296 Object result = FinderCache.getResult(finderClassName,
1297 finderMethodName, finderParams, finderArgs, getSessionFactory());
1298
1299 if (result == null) {
1300 Session session = null;
1301
1302 try {
1303 session = openSession();
1304
1305 StringMaker query = new StringMaker();
1306 query.append("SELECT COUNT(*) ");
1307 query.append(
1308 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1309 query.append("userId = ?");
1310 query.append(" ");
1311
1312 Query q = session.createQuery(query.toString());
1313 int queryPos = 0;
1314 q.setLong(queryPos++, userId);
1315
1316 Long count = null;
1317 Iterator itr = q.list().iterator();
1318
1319 if (itr.hasNext()) {
1320 count = (Long)itr.next();
1321 }
1322
1323 if (count == null) {
1324 count = new Long(0);
1325 }
1326
1327 FinderCache.putResult(finderClassName, finderMethodName,
1328 finderParams, finderArgs, count);
1329
1330 return count.intValue();
1331 }
1332 catch (Exception e) {
1333 throw HibernateUtil.processException(e);
1334 }
1335 finally {
1336 closeSession(session);
1337 }
1338 }
1339 else {
1340 return ((Long)result).intValue();
1341 }
1342 }
1343
1344 public int countByG_U(long groupId, long userId) throws SystemException {
1345 String finderClassName = BlogsStatsUser.class.getName();
1346 String finderMethodName = "countByG_U";
1347 String[] finderParams = new String[] {
1348 Long.class.getName(), Long.class.getName()
1349 };
1350 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1351 Object result = FinderCache.getResult(finderClassName,
1352 finderMethodName, finderParams, finderArgs, getSessionFactory());
1353
1354 if (result == null) {
1355 Session session = null;
1356
1357 try {
1358 session = openSession();
1359
1360 StringMaker query = new StringMaker();
1361 query.append("SELECT COUNT(*) ");
1362 query.append(
1363 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1364 query.append("groupId = ?");
1365 query.append(" AND ");
1366 query.append("userId = ?");
1367 query.append(" ");
1368
1369 Query q = session.createQuery(query.toString());
1370 int queryPos = 0;
1371 q.setLong(queryPos++, groupId);
1372 q.setLong(queryPos++, userId);
1373
1374 Long count = null;
1375 Iterator itr = q.list().iterator();
1376
1377 if (itr.hasNext()) {
1378 count = (Long)itr.next();
1379 }
1380
1381 if (count == null) {
1382 count = new Long(0);
1383 }
1384
1385 FinderCache.putResult(finderClassName, finderMethodName,
1386 finderParams, finderArgs, count);
1387
1388 return count.intValue();
1389 }
1390 catch (Exception e) {
1391 throw HibernateUtil.processException(e);
1392 }
1393 finally {
1394 closeSession(session);
1395 }
1396 }
1397 else {
1398 return ((Long)result).intValue();
1399 }
1400 }
1401
1402 public int countByG_E(long groupId, int entryCount)
1403 throws SystemException {
1404 String finderClassName = BlogsStatsUser.class.getName();
1405 String finderMethodName = "countByG_E";
1406 String[] finderParams = new String[] {
1407 Long.class.getName(), Integer.class.getName()
1408 };
1409 Object[] finderArgs = new Object[] {
1410 new Long(groupId), new Integer(entryCount)
1411 };
1412 Object result = FinderCache.getResult(finderClassName,
1413 finderMethodName, finderParams, finderArgs, getSessionFactory());
1414
1415 if (result == null) {
1416 Session session = null;
1417
1418 try {
1419 session = openSession();
1420
1421 StringMaker query = new StringMaker();
1422 query.append("SELECT COUNT(*) ");
1423 query.append(
1424 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1425 query.append("groupId = ?");
1426 query.append(" AND ");
1427 query.append("entryCount != ?");
1428 query.append(" ");
1429
1430 Query q = session.createQuery(query.toString());
1431 int queryPos = 0;
1432 q.setLong(queryPos++, groupId);
1433 q.setInteger(queryPos++, entryCount);
1434
1435 Long count = null;
1436 Iterator itr = q.list().iterator();
1437
1438 if (itr.hasNext()) {
1439 count = (Long)itr.next();
1440 }
1441
1442 if (count == null) {
1443 count = new Long(0);
1444 }
1445
1446 FinderCache.putResult(finderClassName, finderMethodName,
1447 finderParams, finderArgs, count);
1448
1449 return count.intValue();
1450 }
1451 catch (Exception e) {
1452 throw HibernateUtil.processException(e);
1453 }
1454 finally {
1455 closeSession(session);
1456 }
1457 }
1458 else {
1459 return ((Long)result).intValue();
1460 }
1461 }
1462
1463 public int countByC_E(long companyId, int entryCount)
1464 throws SystemException {
1465 String finderClassName = BlogsStatsUser.class.getName();
1466 String finderMethodName = "countByC_E";
1467 String[] finderParams = new String[] {
1468 Long.class.getName(), Integer.class.getName()
1469 };
1470 Object[] finderArgs = new Object[] {
1471 new Long(companyId), new Integer(entryCount)
1472 };
1473 Object result = FinderCache.getResult(finderClassName,
1474 finderMethodName, finderParams, finderArgs, getSessionFactory());
1475
1476 if (result == null) {
1477 Session session = null;
1478
1479 try {
1480 session = openSession();
1481
1482 StringMaker query = new StringMaker();
1483 query.append("SELECT COUNT(*) ");
1484 query.append(
1485 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1486 query.append("companyId = ?");
1487 query.append(" AND ");
1488 query.append("entryCount != ?");
1489 query.append(" ");
1490
1491 Query q = session.createQuery(query.toString());
1492 int queryPos = 0;
1493 q.setLong(queryPos++, companyId);
1494 q.setInteger(queryPos++, entryCount);
1495
1496 Long count = null;
1497 Iterator itr = q.list().iterator();
1498
1499 if (itr.hasNext()) {
1500 count = (Long)itr.next();
1501 }
1502
1503 if (count == null) {
1504 count = new Long(0);
1505 }
1506
1507 FinderCache.putResult(finderClassName, finderMethodName,
1508 finderParams, finderArgs, count);
1509
1510 return count.intValue();
1511 }
1512 catch (Exception e) {
1513 throw HibernateUtil.processException(e);
1514 }
1515 finally {
1516 closeSession(session);
1517 }
1518 }
1519 else {
1520 return ((Long)result).intValue();
1521 }
1522 }
1523
1524 public int countAll() throws SystemException {
1525 String finderClassName = BlogsStatsUser.class.getName();
1526 String finderMethodName = "countAll";
1527 String[] finderParams = new String[] { };
1528 Object[] finderArgs = new Object[] { };
1529 Object result = FinderCache.getResult(finderClassName,
1530 finderMethodName, finderParams, finderArgs, getSessionFactory());
1531
1532 if (result == null) {
1533 Session session = null;
1534
1535 try {
1536 session = openSession();
1537
1538 StringMaker query = new StringMaker();
1539 query.append("SELECT COUNT(*) ");
1540 query.append(
1541 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser");
1542
1543 Query q = session.createQuery(query.toString());
1544 Long count = null;
1545 Iterator itr = q.list().iterator();
1546
1547 if (itr.hasNext()) {
1548 count = (Long)itr.next();
1549 }
1550
1551 if (count == null) {
1552 count = new Long(0);
1553 }
1554
1555 FinderCache.putResult(finderClassName, finderMethodName,
1556 finderParams, finderArgs, count);
1557
1558 return count.intValue();
1559 }
1560 catch (Exception e) {
1561 throw HibernateUtil.processException(e);
1562 }
1563 finally {
1564 closeSession(session);
1565 }
1566 }
1567 else {
1568 return ((Long)result).intValue();
1569 }
1570 }
1571
1572 protected void initDao() {
1573 }
1574
1575 private static Log _log = LogFactory.getLog(BlogsStatsUserPersistenceImpl.class);
1576}