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