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