001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.CalendarUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.UnmodifiableList;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.blogs.NoSuchStatsUserException;
043    import com.liferay.portlet.blogs.model.BlogsStatsUser;
044    import com.liferay.portlet.blogs.model.impl.BlogsStatsUserImpl;
045    import com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.Date;
052    import java.util.List;
053    
054    /**
055     * The persistence implementation for the blogs stats user service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see BlogsStatsUserPersistence
063     * @see BlogsStatsUserUtil
064     * @generated
065     */
066    public class BlogsStatsUserPersistenceImpl extends BasePersistenceImpl<BlogsStatsUser>
067            implements BlogsStatsUserPersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link BlogsStatsUserUtil} to access the blogs stats user persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072             */
073            public static final String FINDER_CLASS_NAME_ENTITY = BlogsStatsUserImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List1";
076            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List2";
078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
079                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
080                            BlogsStatsUserImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
081                            "findAll", new String[0]);
082            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
083                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
084                            BlogsStatsUserImpl.class,
085                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
087                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
090                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
091                            BlogsStatsUserImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092                            "findByGroupId",
093                            new String[] {
094                                    Long.class.getName(),
095                                    
096                            Integer.class.getName(), Integer.class.getName(),
097                                    OrderByComparator.class.getName()
098                            });
099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
100                    new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
101                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
102                            BlogsStatsUserImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
104                            new String[] { Long.class.getName() },
105                            BlogsStatsUserModelImpl.GROUPID_COLUMN_BITMASK |
106                            BlogsStatsUserModelImpl.ENTRYCOUNT_COLUMN_BITMASK);
107            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
108                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
110                            new String[] { Long.class.getName() });
111    
112            /**
113             * Returns all the blogs stats users where groupId = &#63;.
114             *
115             * @param groupId the group ID
116             * @return the matching blogs stats users
117             * @throws SystemException if a system exception occurred
118             */
119            public List<BlogsStatsUser> findByGroupId(long groupId)
120                    throws SystemException {
121                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122            }
123    
124            /**
125             * Returns a range of all the blogs stats users where groupId = &#63;.
126             *
127             * <p>
128             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
129             * </p>
130             *
131             * @param groupId the group ID
132             * @param start the lower bound of the range of blogs stats users
133             * @param end the upper bound of the range of blogs stats users (not inclusive)
134             * @return the range of matching blogs stats users
135             * @throws SystemException if a system exception occurred
136             */
137            public List<BlogsStatsUser> findByGroupId(long groupId, int start, int end)
138                    throws SystemException {
139                    return findByGroupId(groupId, start, end, null);
140            }
141    
142            /**
143             * Returns an ordered range of all the blogs stats users where groupId = &#63;.
144             *
145             * <p>
146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
147             * </p>
148             *
149             * @param groupId the group ID
150             * @param start the lower bound of the range of blogs stats users
151             * @param end the upper bound of the range of blogs stats users (not inclusive)
152             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
153             * @return the ordered range of matching blogs stats users
154             * @throws SystemException if a system exception occurred
155             */
156            public List<BlogsStatsUser> findByGroupId(long groupId, int start, int end,
157                    OrderByComparator orderByComparator) throws SystemException {
158                    boolean pagination = true;
159                    FinderPath finderPath = null;
160                    Object[] finderArgs = null;
161    
162                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163                                    (orderByComparator == null)) {
164                            pagination = false;
165                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
166                            finderArgs = new Object[] { groupId };
167                    }
168                    else {
169                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
170                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
171                    }
172    
173                    List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(finderPath,
174                                    finderArgs, this);
175    
176                    if ((list != null) && !list.isEmpty()) {
177                            for (BlogsStatsUser blogsStatsUser : list) {
178                                    if ((groupId != blogsStatsUser.getGroupId())) {
179                                            list = null;
180    
181                                            break;
182                                    }
183                            }
184                    }
185    
186                    if (list == null) {
187                            StringBundler query = null;
188    
189                            if (orderByComparator != null) {
190                                    query = new StringBundler(3 +
191                                                    (orderByComparator.getOrderByFields().length * 3));
192                            }
193                            else {
194                                    query = new StringBundler(3);
195                            }
196    
197                            query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
198    
199                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
200    
201                            if (orderByComparator != null) {
202                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
203                                            orderByComparator);
204                            }
205                            else
206                             if (pagination) {
207                                    query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
208                            }
209    
210                            String sql = query.toString();
211    
212                            Session session = null;
213    
214                            try {
215                                    session = openSession();
216    
217                                    Query q = session.createQuery(sql);
218    
219                                    QueryPos qPos = QueryPos.getInstance(q);
220    
221                                    qPos.add(groupId);
222    
223                                    if (!pagination) {
224                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
225                                                            getDialect(), start, end, false);
226    
227                                            Collections.sort(list);
228    
229                                            list = new UnmodifiableList<BlogsStatsUser>(list);
230                                    }
231                                    else {
232                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
233                                                            getDialect(), start, end);
234                                    }
235    
236                                    cacheResult(list);
237    
238                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
239                            }
240                            catch (Exception e) {
241                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
242    
243                                    throw processException(e);
244                            }
245                            finally {
246                                    closeSession(session);
247                            }
248                    }
249    
250                    return list;
251            }
252    
253            /**
254             * Returns the first blogs stats user in the ordered set where groupId = &#63;.
255             *
256             * @param groupId the group ID
257             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
258             * @return the first matching blogs stats user
259             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
260             * @throws SystemException if a system exception occurred
261             */
262            public BlogsStatsUser findByGroupId_First(long groupId,
263                    OrderByComparator orderByComparator)
264                    throws NoSuchStatsUserException, SystemException {
265                    BlogsStatsUser blogsStatsUser = fetchByGroupId_First(groupId,
266                                    orderByComparator);
267    
268                    if (blogsStatsUser != null) {
269                            return blogsStatsUser;
270                    }
271    
272                    StringBundler msg = new StringBundler(4);
273    
274                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
275    
276                    msg.append("groupId=");
277                    msg.append(groupId);
278    
279                    msg.append(StringPool.CLOSE_CURLY_BRACE);
280    
281                    throw new NoSuchStatsUserException(msg.toString());
282            }
283    
284            /**
285             * Returns the first blogs stats user in the ordered set where groupId = &#63;.
286             *
287             * @param groupId the group ID
288             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
289             * @return the first matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
290             * @throws SystemException if a system exception occurred
291             */
292            public BlogsStatsUser fetchByGroupId_First(long groupId,
293                    OrderByComparator orderByComparator) throws SystemException {
294                    List<BlogsStatsUser> list = findByGroupId(groupId, 0, 1,
295                                    orderByComparator);
296    
297                    if (!list.isEmpty()) {
298                            return list.get(0);
299                    }
300    
301                    return null;
302            }
303    
304            /**
305             * Returns the last blogs stats user in the ordered set where groupId = &#63;.
306             *
307             * @param groupId the group ID
308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
309             * @return the last matching blogs stats user
310             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
311             * @throws SystemException if a system exception occurred
312             */
313            public BlogsStatsUser findByGroupId_Last(long groupId,
314                    OrderByComparator orderByComparator)
315                    throws NoSuchStatsUserException, SystemException {
316                    BlogsStatsUser blogsStatsUser = fetchByGroupId_Last(groupId,
317                                    orderByComparator);
318    
319                    if (blogsStatsUser != null) {
320                            return blogsStatsUser;
321                    }
322    
323                    StringBundler msg = new StringBundler(4);
324    
325                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
326    
327                    msg.append("groupId=");
328                    msg.append(groupId);
329    
330                    msg.append(StringPool.CLOSE_CURLY_BRACE);
331    
332                    throw new NoSuchStatsUserException(msg.toString());
333            }
334    
335            /**
336             * Returns the last blogs stats user in the ordered set where groupId = &#63;.
337             *
338             * @param groupId the group ID
339             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
340             * @return the last matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
341             * @throws SystemException if a system exception occurred
342             */
343            public BlogsStatsUser fetchByGroupId_Last(long groupId,
344                    OrderByComparator orderByComparator) throws SystemException {
345                    int count = countByGroupId(groupId);
346    
347                    List<BlogsStatsUser> list = findByGroupId(groupId, count - 1, count,
348                                    orderByComparator);
349    
350                    if (!list.isEmpty()) {
351                            return list.get(0);
352                    }
353    
354                    return null;
355            }
356    
357            /**
358             * Returns the blogs stats users before and after the current blogs stats user in the ordered set where groupId = &#63;.
359             *
360             * @param statsUserId the primary key of the current blogs stats user
361             * @param groupId the group ID
362             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
363             * @return the previous, current, and next blogs stats user
364             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a blogs stats user with the primary key could not be found
365             * @throws SystemException if a system exception occurred
366             */
367            public BlogsStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
368                    long groupId, OrderByComparator orderByComparator)
369                    throws NoSuchStatsUserException, SystemException {
370                    BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
371    
372                    Session session = null;
373    
374                    try {
375                            session = openSession();
376    
377                            BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
378    
379                            array[0] = getByGroupId_PrevAndNext(session, blogsStatsUser,
380                                            groupId, orderByComparator, true);
381    
382                            array[1] = blogsStatsUser;
383    
384                            array[2] = getByGroupId_PrevAndNext(session, blogsStatsUser,
385                                            groupId, orderByComparator, false);
386    
387                            return array;
388                    }
389                    catch (Exception e) {
390                            throw processException(e);
391                    }
392                    finally {
393                            closeSession(session);
394                    }
395            }
396    
397            protected BlogsStatsUser getByGroupId_PrevAndNext(Session session,
398                    BlogsStatsUser blogsStatsUser, long groupId,
399                    OrderByComparator orderByComparator, boolean previous) {
400                    StringBundler query = null;
401    
402                    if (orderByComparator != null) {
403                            query = new StringBundler(6 +
404                                            (orderByComparator.getOrderByFields().length * 6));
405                    }
406                    else {
407                            query = new StringBundler(3);
408                    }
409    
410                    query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
411    
412                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
413    
414                    if (orderByComparator != null) {
415                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
416    
417                            if (orderByConditionFields.length > 0) {
418                                    query.append(WHERE_AND);
419                            }
420    
421                            for (int i = 0; i < orderByConditionFields.length; i++) {
422                                    query.append(_ORDER_BY_ENTITY_ALIAS);
423                                    query.append(orderByConditionFields[i]);
424    
425                                    if ((i + 1) < orderByConditionFields.length) {
426                                            if (orderByComparator.isAscending() ^ previous) {
427                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
428                                            }
429                                            else {
430                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
431                                            }
432                                    }
433                                    else {
434                                            if (orderByComparator.isAscending() ^ previous) {
435                                                    query.append(WHERE_GREATER_THAN);
436                                            }
437                                            else {
438                                                    query.append(WHERE_LESSER_THAN);
439                                            }
440                                    }
441                            }
442    
443                            query.append(ORDER_BY_CLAUSE);
444    
445                            String[] orderByFields = orderByComparator.getOrderByFields();
446    
447                            for (int i = 0; i < orderByFields.length; i++) {
448                                    query.append(_ORDER_BY_ENTITY_ALIAS);
449                                    query.append(orderByFields[i]);
450    
451                                    if ((i + 1) < orderByFields.length) {
452                                            if (orderByComparator.isAscending() ^ previous) {
453                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
454                                            }
455                                            else {
456                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
457                                            }
458                                    }
459                                    else {
460                                            if (orderByComparator.isAscending() ^ previous) {
461                                                    query.append(ORDER_BY_ASC);
462                                            }
463                                            else {
464                                                    query.append(ORDER_BY_DESC);
465                                            }
466                                    }
467                            }
468                    }
469                    else {
470                            query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
471                    }
472    
473                    String sql = query.toString();
474    
475                    Query q = session.createQuery(sql);
476    
477                    q.setFirstResult(0);
478                    q.setMaxResults(2);
479    
480                    QueryPos qPos = QueryPos.getInstance(q);
481    
482                    qPos.add(groupId);
483    
484                    if (orderByComparator != null) {
485                            Object[] values = orderByComparator.getOrderByConditionValues(blogsStatsUser);
486    
487                            for (Object value : values) {
488                                    qPos.add(value);
489                            }
490                    }
491    
492                    List<BlogsStatsUser> list = q.list();
493    
494                    if (list.size() == 2) {
495                            return list.get(1);
496                    }
497                    else {
498                            return null;
499                    }
500            }
501    
502            /**
503             * Removes all the blogs stats users where groupId = &#63; from the database.
504             *
505             * @param groupId the group ID
506             * @throws SystemException if a system exception occurred
507             */
508            public void removeByGroupId(long groupId) throws SystemException {
509                    for (BlogsStatsUser blogsStatsUser : findByGroupId(groupId,
510                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
511                            remove(blogsStatsUser);
512                    }
513            }
514    
515            /**
516             * Returns the number of blogs stats users where groupId = &#63;.
517             *
518             * @param groupId the group ID
519             * @return the number of matching blogs stats users
520             * @throws SystemException if a system exception occurred
521             */
522            public int countByGroupId(long groupId) throws SystemException {
523                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
524    
525                    Object[] finderArgs = new Object[] { groupId };
526    
527                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
528                                    this);
529    
530                    if (count == null) {
531                            StringBundler query = new StringBundler(2);
532    
533                            query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
534    
535                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
536    
537                            String sql = query.toString();
538    
539                            Session session = null;
540    
541                            try {
542                                    session = openSession();
543    
544                                    Query q = session.createQuery(sql);
545    
546                                    QueryPos qPos = QueryPos.getInstance(q);
547    
548                                    qPos.add(groupId);
549    
550                                    count = (Long)q.uniqueResult();
551    
552                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
553                            }
554                            catch (Exception e) {
555                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
556    
557                                    throw processException(e);
558                            }
559                            finally {
560                                    closeSession(session);
561                            }
562                    }
563    
564                    return count.intValue();
565            }
566    
567            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsStatsUser.groupId = ?";
568            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
569                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
570                            BlogsStatsUserImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
571                            "findByUserId",
572                            new String[] {
573                                    Long.class.getName(),
574                                    
575                            Integer.class.getName(), Integer.class.getName(),
576                                    OrderByComparator.class.getName()
577                            });
578            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
579                    new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
580                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
581                            BlogsStatsUserImpl.class,
582                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
583                            new String[] { Long.class.getName() },
584                            BlogsStatsUserModelImpl.USERID_COLUMN_BITMASK |
585                            BlogsStatsUserModelImpl.ENTRYCOUNT_COLUMN_BITMASK);
586            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
587                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
588                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
589                            new String[] { Long.class.getName() });
590    
591            /**
592             * Returns all the blogs stats users where userId = &#63;.
593             *
594             * @param userId the user ID
595             * @return the matching blogs stats users
596             * @throws SystemException if a system exception occurred
597             */
598            public List<BlogsStatsUser> findByUserId(long userId)
599                    throws SystemException {
600                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
601            }
602    
603            /**
604             * Returns a range of all the blogs stats users where userId = &#63;.
605             *
606             * <p>
607             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
608             * </p>
609             *
610             * @param userId the user ID
611             * @param start the lower bound of the range of blogs stats users
612             * @param end the upper bound of the range of blogs stats users (not inclusive)
613             * @return the range of matching blogs stats users
614             * @throws SystemException if a system exception occurred
615             */
616            public List<BlogsStatsUser> findByUserId(long userId, int start, int end)
617                    throws SystemException {
618                    return findByUserId(userId, start, end, null);
619            }
620    
621            /**
622             * Returns an ordered range of all the blogs stats users where userId = &#63;.
623             *
624             * <p>
625             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
626             * </p>
627             *
628             * @param userId the user ID
629             * @param start the lower bound of the range of blogs stats users
630             * @param end the upper bound of the range of blogs stats users (not inclusive)
631             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
632             * @return the ordered range of matching blogs stats users
633             * @throws SystemException if a system exception occurred
634             */
635            public List<BlogsStatsUser> findByUserId(long userId, int start, int end,
636                    OrderByComparator orderByComparator) throws SystemException {
637                    boolean pagination = true;
638                    FinderPath finderPath = null;
639                    Object[] finderArgs = null;
640    
641                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
642                                    (orderByComparator == null)) {
643                            pagination = false;
644                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
645                            finderArgs = new Object[] { userId };
646                    }
647                    else {
648                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
649                            finderArgs = new Object[] { userId, start, end, orderByComparator };
650                    }
651    
652                    List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(finderPath,
653                                    finderArgs, this);
654    
655                    if ((list != null) && !list.isEmpty()) {
656                            for (BlogsStatsUser blogsStatsUser : list) {
657                                    if ((userId != blogsStatsUser.getUserId())) {
658                                            list = null;
659    
660                                            break;
661                                    }
662                            }
663                    }
664    
665                    if (list == null) {
666                            StringBundler query = null;
667    
668                            if (orderByComparator != null) {
669                                    query = new StringBundler(3 +
670                                                    (orderByComparator.getOrderByFields().length * 3));
671                            }
672                            else {
673                                    query = new StringBundler(3);
674                            }
675    
676                            query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
677    
678                            query.append(_FINDER_COLUMN_USERID_USERID_2);
679    
680                            if (orderByComparator != null) {
681                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
682                                            orderByComparator);
683                            }
684                            else
685                             if (pagination) {
686                                    query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
687                            }
688    
689                            String sql = query.toString();
690    
691                            Session session = null;
692    
693                            try {
694                                    session = openSession();
695    
696                                    Query q = session.createQuery(sql);
697    
698                                    QueryPos qPos = QueryPos.getInstance(q);
699    
700                                    qPos.add(userId);
701    
702                                    if (!pagination) {
703                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
704                                                            getDialect(), start, end, false);
705    
706                                            Collections.sort(list);
707    
708                                            list = new UnmodifiableList<BlogsStatsUser>(list);
709                                    }
710                                    else {
711                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
712                                                            getDialect(), start, end);
713                                    }
714    
715                                    cacheResult(list);
716    
717                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
718                            }
719                            catch (Exception e) {
720                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
721    
722                                    throw processException(e);
723                            }
724                            finally {
725                                    closeSession(session);
726                            }
727                    }
728    
729                    return list;
730            }
731    
732            /**
733             * Returns the first blogs stats user in the ordered set where userId = &#63;.
734             *
735             * @param userId the user ID
736             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
737             * @return the first matching blogs stats user
738             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
739             * @throws SystemException if a system exception occurred
740             */
741            public BlogsStatsUser findByUserId_First(long userId,
742                    OrderByComparator orderByComparator)
743                    throws NoSuchStatsUserException, SystemException {
744                    BlogsStatsUser blogsStatsUser = fetchByUserId_First(userId,
745                                    orderByComparator);
746    
747                    if (blogsStatsUser != null) {
748                            return blogsStatsUser;
749                    }
750    
751                    StringBundler msg = new StringBundler(4);
752    
753                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
754    
755                    msg.append("userId=");
756                    msg.append(userId);
757    
758                    msg.append(StringPool.CLOSE_CURLY_BRACE);
759    
760                    throw new NoSuchStatsUserException(msg.toString());
761            }
762    
763            /**
764             * Returns the first blogs stats user in the ordered set where userId = &#63;.
765             *
766             * @param userId the user ID
767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
768             * @return the first matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
769             * @throws SystemException if a system exception occurred
770             */
771            public BlogsStatsUser fetchByUserId_First(long userId,
772                    OrderByComparator orderByComparator) throws SystemException {
773                    List<BlogsStatsUser> list = findByUserId(userId, 0, 1, orderByComparator);
774    
775                    if (!list.isEmpty()) {
776                            return list.get(0);
777                    }
778    
779                    return null;
780            }
781    
782            /**
783             * Returns the last blogs stats user in the ordered set where userId = &#63;.
784             *
785             * @param userId the user ID
786             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
787             * @return the last matching blogs stats user
788             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
789             * @throws SystemException if a system exception occurred
790             */
791            public BlogsStatsUser findByUserId_Last(long userId,
792                    OrderByComparator orderByComparator)
793                    throws NoSuchStatsUserException, SystemException {
794                    BlogsStatsUser blogsStatsUser = fetchByUserId_Last(userId,
795                                    orderByComparator);
796    
797                    if (blogsStatsUser != null) {
798                            return blogsStatsUser;
799                    }
800    
801                    StringBundler msg = new StringBundler(4);
802    
803                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
804    
805                    msg.append("userId=");
806                    msg.append(userId);
807    
808                    msg.append(StringPool.CLOSE_CURLY_BRACE);
809    
810                    throw new NoSuchStatsUserException(msg.toString());
811            }
812    
813            /**
814             * Returns the last blogs stats user in the ordered set where userId = &#63;.
815             *
816             * @param userId the user ID
817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
818             * @return the last matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
819             * @throws SystemException if a system exception occurred
820             */
821            public BlogsStatsUser fetchByUserId_Last(long userId,
822                    OrderByComparator orderByComparator) throws SystemException {
823                    int count = countByUserId(userId);
824    
825                    List<BlogsStatsUser> list = findByUserId(userId, count - 1, count,
826                                    orderByComparator);
827    
828                    if (!list.isEmpty()) {
829                            return list.get(0);
830                    }
831    
832                    return null;
833            }
834    
835            /**
836             * Returns the blogs stats users before and after the current blogs stats user in the ordered set where userId = &#63;.
837             *
838             * @param statsUserId the primary key of the current blogs stats user
839             * @param userId the user ID
840             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
841             * @return the previous, current, and next blogs stats user
842             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a blogs stats user with the primary key could not be found
843             * @throws SystemException if a system exception occurred
844             */
845            public BlogsStatsUser[] findByUserId_PrevAndNext(long statsUserId,
846                    long userId, OrderByComparator orderByComparator)
847                    throws NoSuchStatsUserException, SystemException {
848                    BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
849    
850                    Session session = null;
851    
852                    try {
853                            session = openSession();
854    
855                            BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
856    
857                            array[0] = getByUserId_PrevAndNext(session, blogsStatsUser, userId,
858                                            orderByComparator, true);
859    
860                            array[1] = blogsStatsUser;
861    
862                            array[2] = getByUserId_PrevAndNext(session, blogsStatsUser, userId,
863                                            orderByComparator, false);
864    
865                            return array;
866                    }
867                    catch (Exception e) {
868                            throw processException(e);
869                    }
870                    finally {
871                            closeSession(session);
872                    }
873            }
874    
875            protected BlogsStatsUser getByUserId_PrevAndNext(Session session,
876                    BlogsStatsUser blogsStatsUser, long userId,
877                    OrderByComparator orderByComparator, boolean previous) {
878                    StringBundler query = null;
879    
880                    if (orderByComparator != null) {
881                            query = new StringBundler(6 +
882                                            (orderByComparator.getOrderByFields().length * 6));
883                    }
884                    else {
885                            query = new StringBundler(3);
886                    }
887    
888                    query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
889    
890                    query.append(_FINDER_COLUMN_USERID_USERID_2);
891    
892                    if (orderByComparator != null) {
893                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
894    
895                            if (orderByConditionFields.length > 0) {
896                                    query.append(WHERE_AND);
897                            }
898    
899                            for (int i = 0; i < orderByConditionFields.length; i++) {
900                                    query.append(_ORDER_BY_ENTITY_ALIAS);
901                                    query.append(orderByConditionFields[i]);
902    
903                                    if ((i + 1) < orderByConditionFields.length) {
904                                            if (orderByComparator.isAscending() ^ previous) {
905                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
906                                            }
907                                            else {
908                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
909                                            }
910                                    }
911                                    else {
912                                            if (orderByComparator.isAscending() ^ previous) {
913                                                    query.append(WHERE_GREATER_THAN);
914                                            }
915                                            else {
916                                                    query.append(WHERE_LESSER_THAN);
917                                            }
918                                    }
919                            }
920    
921                            query.append(ORDER_BY_CLAUSE);
922    
923                            String[] orderByFields = orderByComparator.getOrderByFields();
924    
925                            for (int i = 0; i < orderByFields.length; i++) {
926                                    query.append(_ORDER_BY_ENTITY_ALIAS);
927                                    query.append(orderByFields[i]);
928    
929                                    if ((i + 1) < orderByFields.length) {
930                                            if (orderByComparator.isAscending() ^ previous) {
931                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
932                                            }
933                                            else {
934                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
935                                            }
936                                    }
937                                    else {
938                                            if (orderByComparator.isAscending() ^ previous) {
939                                                    query.append(ORDER_BY_ASC);
940                                            }
941                                            else {
942                                                    query.append(ORDER_BY_DESC);
943                                            }
944                                    }
945                            }
946                    }
947                    else {
948                            query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
949                    }
950    
951                    String sql = query.toString();
952    
953                    Query q = session.createQuery(sql);
954    
955                    q.setFirstResult(0);
956                    q.setMaxResults(2);
957    
958                    QueryPos qPos = QueryPos.getInstance(q);
959    
960                    qPos.add(userId);
961    
962                    if (orderByComparator != null) {
963                            Object[] values = orderByComparator.getOrderByConditionValues(blogsStatsUser);
964    
965                            for (Object value : values) {
966                                    qPos.add(value);
967                            }
968                    }
969    
970                    List<BlogsStatsUser> list = q.list();
971    
972                    if (list.size() == 2) {
973                            return list.get(1);
974                    }
975                    else {
976                            return null;
977                    }
978            }
979    
980            /**
981             * Removes all the blogs stats users where userId = &#63; from the database.
982             *
983             * @param userId the user ID
984             * @throws SystemException if a system exception occurred
985             */
986            public void removeByUserId(long userId) throws SystemException {
987                    for (BlogsStatsUser blogsStatsUser : findByUserId(userId,
988                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
989                            remove(blogsStatsUser);
990                    }
991            }
992    
993            /**
994             * Returns the number of blogs stats users where userId = &#63;.
995             *
996             * @param userId the user ID
997             * @return the number of matching blogs stats users
998             * @throws SystemException if a system exception occurred
999             */
1000            public int countByUserId(long userId) throws SystemException {
1001                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1002    
1003                    Object[] finderArgs = new Object[] { userId };
1004    
1005                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1006                                    this);
1007    
1008                    if (count == null) {
1009                            StringBundler query = new StringBundler(2);
1010    
1011                            query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
1012    
1013                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1014    
1015                            String sql = query.toString();
1016    
1017                            Session session = null;
1018    
1019                            try {
1020                                    session = openSession();
1021    
1022                                    Query q = session.createQuery(sql);
1023    
1024                                    QueryPos qPos = QueryPos.getInstance(q);
1025    
1026                                    qPos.add(userId);
1027    
1028                                    count = (Long)q.uniqueResult();
1029    
1030                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1031                            }
1032                            catch (Exception e) {
1033                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1034    
1035                                    throw processException(e);
1036                            }
1037                            finally {
1038                                    closeSession(session);
1039                            }
1040                    }
1041    
1042                    return count.intValue();
1043            }
1044    
1045            private static final String _FINDER_COLUMN_USERID_USERID_2 = "blogsStatsUser.userId = ?";
1046            public static final FinderPath FINDER_PATH_FETCH_BY_G_U = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
1047                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
1048                            BlogsStatsUserImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_U",
1049                            new String[] { Long.class.getName(), Long.class.getName() },
1050                            BlogsStatsUserModelImpl.GROUPID_COLUMN_BITMASK |
1051                            BlogsStatsUserModelImpl.USERID_COLUMN_BITMASK);
1052            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
1053                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
1054                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
1055                            new String[] { Long.class.getName(), Long.class.getName() });
1056    
1057            /**
1058             * Returns the blogs stats user where groupId = &#63; and userId = &#63; or throws a {@link com.liferay.portlet.blogs.NoSuchStatsUserException} if it could not be found.
1059             *
1060             * @param groupId the group ID
1061             * @param userId the user ID
1062             * @return the matching blogs stats user
1063             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
1064             * @throws SystemException if a system exception occurred
1065             */
1066            public BlogsStatsUser findByG_U(long groupId, long userId)
1067                    throws NoSuchStatsUserException, SystemException {
1068                    BlogsStatsUser blogsStatsUser = fetchByG_U(groupId, userId);
1069    
1070                    if (blogsStatsUser == null) {
1071                            StringBundler msg = new StringBundler(6);
1072    
1073                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1074    
1075                            msg.append("groupId=");
1076                            msg.append(groupId);
1077    
1078                            msg.append(", userId=");
1079                            msg.append(userId);
1080    
1081                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1082    
1083                            if (_log.isWarnEnabled()) {
1084                                    _log.warn(msg.toString());
1085                            }
1086    
1087                            throw new NoSuchStatsUserException(msg.toString());
1088                    }
1089    
1090                    return blogsStatsUser;
1091            }
1092    
1093            /**
1094             * Returns the blogs stats user where groupId = &#63; and userId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1095             *
1096             * @param groupId the group ID
1097             * @param userId the user ID
1098             * @return the matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
1099             * @throws SystemException if a system exception occurred
1100             */
1101            public BlogsStatsUser fetchByG_U(long groupId, long userId)
1102                    throws SystemException {
1103                    return fetchByG_U(groupId, userId, true);
1104            }
1105    
1106            /**
1107             * Returns the blogs stats user where groupId = &#63; and userId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1108             *
1109             * @param groupId the group ID
1110             * @param userId the user ID
1111             * @param retrieveFromCache whether to use the finder cache
1112             * @return the matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
1113             * @throws SystemException if a system exception occurred
1114             */
1115            public BlogsStatsUser fetchByG_U(long groupId, long userId,
1116                    boolean retrieveFromCache) throws SystemException {
1117                    Object[] finderArgs = new Object[] { groupId, userId };
1118    
1119                    Object result = null;
1120    
1121                    if (retrieveFromCache) {
1122                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_U,
1123                                            finderArgs, this);
1124                    }
1125    
1126                    if (result instanceof BlogsStatsUser) {
1127                            BlogsStatsUser blogsStatsUser = (BlogsStatsUser)result;
1128    
1129                            if ((groupId != blogsStatsUser.getGroupId()) ||
1130                                            (userId != blogsStatsUser.getUserId())) {
1131                                    result = null;
1132                            }
1133                    }
1134    
1135                    if (result == null) {
1136                            StringBundler query = new StringBundler(4);
1137    
1138                            query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1139    
1140                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1141    
1142                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1143    
1144                            String sql = query.toString();
1145    
1146                            Session session = null;
1147    
1148                            try {
1149                                    session = openSession();
1150    
1151                                    Query q = session.createQuery(sql);
1152    
1153                                    QueryPos qPos = QueryPos.getInstance(q);
1154    
1155                                    qPos.add(groupId);
1156    
1157                                    qPos.add(userId);
1158    
1159                                    List<BlogsStatsUser> list = q.list();
1160    
1161                                    if (list.isEmpty()) {
1162                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1163                                                    finderArgs, list);
1164                                    }
1165                                    else {
1166                                            BlogsStatsUser blogsStatsUser = list.get(0);
1167    
1168                                            result = blogsStatsUser;
1169    
1170                                            cacheResult(blogsStatsUser);
1171    
1172                                            if ((blogsStatsUser.getGroupId() != groupId) ||
1173                                                            (blogsStatsUser.getUserId() != userId)) {
1174                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1175                                                            finderArgs, blogsStatsUser);
1176                                            }
1177                                    }
1178                            }
1179                            catch (Exception e) {
1180                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
1181                                            finderArgs);
1182    
1183                                    throw processException(e);
1184                            }
1185                            finally {
1186                                    closeSession(session);
1187                            }
1188                    }
1189    
1190                    if (result instanceof List<?>) {
1191                            return null;
1192                    }
1193                    else {
1194                            return (BlogsStatsUser)result;
1195                    }
1196            }
1197    
1198            /**
1199             * Removes the blogs stats user where groupId = &#63; and userId = &#63; from the database.
1200             *
1201             * @param groupId the group ID
1202             * @param userId the user ID
1203             * @return the blogs stats user that was removed
1204             * @throws SystemException if a system exception occurred
1205             */
1206            public BlogsStatsUser removeByG_U(long groupId, long userId)
1207                    throws NoSuchStatsUserException, SystemException {
1208                    BlogsStatsUser blogsStatsUser = findByG_U(groupId, userId);
1209    
1210                    return remove(blogsStatsUser);
1211            }
1212    
1213            /**
1214             * Returns the number of blogs stats users where groupId = &#63; and userId = &#63;.
1215             *
1216             * @param groupId the group ID
1217             * @param userId the user ID
1218             * @return the number of matching blogs stats users
1219             * @throws SystemException if a system exception occurred
1220             */
1221            public int countByG_U(long groupId, long userId) throws SystemException {
1222                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
1223    
1224                    Object[] finderArgs = new Object[] { groupId, userId };
1225    
1226                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1227                                    this);
1228    
1229                    if (count == null) {
1230                            StringBundler query = new StringBundler(3);
1231    
1232                            query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
1233    
1234                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1235    
1236                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1237    
1238                            String sql = query.toString();
1239    
1240                            Session session = null;
1241    
1242                            try {
1243                                    session = openSession();
1244    
1245                                    Query q = session.createQuery(sql);
1246    
1247                                    QueryPos qPos = QueryPos.getInstance(q);
1248    
1249                                    qPos.add(groupId);
1250    
1251                                    qPos.add(userId);
1252    
1253                                    count = (Long)q.uniqueResult();
1254    
1255                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1256                            }
1257                            catch (Exception e) {
1258                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1259    
1260                                    throw processException(e);
1261                            }
1262                            finally {
1263                                    closeSession(session);
1264                            }
1265                    }
1266    
1267                    return count.intValue();
1268            }
1269    
1270            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "blogsStatsUser.groupId = ? AND ";
1271            private static final String _FINDER_COLUMN_G_U_USERID_2 = "blogsStatsUser.userId = ?";
1272            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTE = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
1273                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
1274                            BlogsStatsUserImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1275                            "findByG_NotE",
1276                            new String[] {
1277                                    Long.class.getName(), Integer.class.getName(),
1278                                    
1279                            Integer.class.getName(), Integer.class.getName(),
1280                                    OrderByComparator.class.getName()
1281                            });
1282            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTE = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
1283                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
1284                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotE",
1285                            new String[] { Long.class.getName(), Integer.class.getName() });
1286    
1287            /**
1288             * Returns all the blogs stats users where groupId = &#63; and entryCount &ne; &#63;.
1289             *
1290             * @param groupId the group ID
1291             * @param entryCount the entry count
1292             * @return the matching blogs stats users
1293             * @throws SystemException if a system exception occurred
1294             */
1295            public List<BlogsStatsUser> findByG_NotE(long groupId, int entryCount)
1296                    throws SystemException {
1297                    return findByG_NotE(groupId, entryCount, QueryUtil.ALL_POS,
1298                            QueryUtil.ALL_POS, null);
1299            }
1300    
1301            /**
1302             * Returns a range of all the blogs stats users where groupId = &#63; and entryCount &ne; &#63;.
1303             *
1304             * <p>
1305             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1306             * </p>
1307             *
1308             * @param groupId the group ID
1309             * @param entryCount the entry count
1310             * @param start the lower bound of the range of blogs stats users
1311             * @param end the upper bound of the range of blogs stats users (not inclusive)
1312             * @return the range of matching blogs stats users
1313             * @throws SystemException if a system exception occurred
1314             */
1315            public List<BlogsStatsUser> findByG_NotE(long groupId, int entryCount,
1316                    int start, int end) throws SystemException {
1317                    return findByG_NotE(groupId, entryCount, start, end, null);
1318            }
1319    
1320            /**
1321             * Returns an ordered range of all the blogs stats users where groupId = &#63; and entryCount &ne; &#63;.
1322             *
1323             * <p>
1324             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1325             * </p>
1326             *
1327             * @param groupId the group ID
1328             * @param entryCount the entry count
1329             * @param start the lower bound of the range of blogs stats users
1330             * @param end the upper bound of the range of blogs stats users (not inclusive)
1331             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1332             * @return the ordered range of matching blogs stats users
1333             * @throws SystemException if a system exception occurred
1334             */
1335            public List<BlogsStatsUser> findByG_NotE(long groupId, int entryCount,
1336                    int start, int end, OrderByComparator orderByComparator)
1337                    throws SystemException {
1338                    boolean pagination = true;
1339                    FinderPath finderPath = null;
1340                    Object[] finderArgs = null;
1341    
1342                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTE;
1343                    finderArgs = new Object[] {
1344                                    groupId, entryCount,
1345                                    
1346                                    start, end, orderByComparator
1347                            };
1348    
1349                    List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(finderPath,
1350                                    finderArgs, this);
1351    
1352                    if ((list != null) && !list.isEmpty()) {
1353                            for (BlogsStatsUser blogsStatsUser : list) {
1354                                    if ((groupId != blogsStatsUser.getGroupId()) ||
1355                                                    (entryCount != blogsStatsUser.getEntryCount())) {
1356                                            list = null;
1357    
1358                                            break;
1359                                    }
1360                            }
1361                    }
1362    
1363                    if (list == null) {
1364                            StringBundler query = null;
1365    
1366                            if (orderByComparator != null) {
1367                                    query = new StringBundler(4 +
1368                                                    (orderByComparator.getOrderByFields().length * 3));
1369                            }
1370                            else {
1371                                    query = new StringBundler(4);
1372                            }
1373    
1374                            query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1375    
1376                            query.append(_FINDER_COLUMN_G_NOTE_GROUPID_2);
1377    
1378                            query.append(_FINDER_COLUMN_G_NOTE_ENTRYCOUNT_2);
1379    
1380                            if (orderByComparator != null) {
1381                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1382                                            orderByComparator);
1383                            }
1384                            else
1385                             if (pagination) {
1386                                    query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1387                            }
1388    
1389                            String sql = query.toString();
1390    
1391                            Session session = null;
1392    
1393                            try {
1394                                    session = openSession();
1395    
1396                                    Query q = session.createQuery(sql);
1397    
1398                                    QueryPos qPos = QueryPos.getInstance(q);
1399    
1400                                    qPos.add(groupId);
1401    
1402                                    qPos.add(entryCount);
1403    
1404                                    if (!pagination) {
1405                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
1406                                                            getDialect(), start, end, false);
1407    
1408                                            Collections.sort(list);
1409    
1410                                            list = new UnmodifiableList<BlogsStatsUser>(list);
1411                                    }
1412                                    else {
1413                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
1414                                                            getDialect(), start, end);
1415                                    }
1416    
1417                                    cacheResult(list);
1418    
1419                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1420                            }
1421                            catch (Exception e) {
1422                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1423    
1424                                    throw processException(e);
1425                            }
1426                            finally {
1427                                    closeSession(session);
1428                            }
1429                    }
1430    
1431                    return list;
1432            }
1433    
1434            /**
1435             * Returns the first blogs stats user in the ordered set where groupId = &#63; and entryCount &ne; &#63;.
1436             *
1437             * @param groupId the group ID
1438             * @param entryCount the entry count
1439             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1440             * @return the first matching blogs stats user
1441             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
1442             * @throws SystemException if a system exception occurred
1443             */
1444            public BlogsStatsUser findByG_NotE_First(long groupId, int entryCount,
1445                    OrderByComparator orderByComparator)
1446                    throws NoSuchStatsUserException, SystemException {
1447                    BlogsStatsUser blogsStatsUser = fetchByG_NotE_First(groupId,
1448                                    entryCount, orderByComparator);
1449    
1450                    if (blogsStatsUser != null) {
1451                            return blogsStatsUser;
1452                    }
1453    
1454                    StringBundler msg = new StringBundler(6);
1455    
1456                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1457    
1458                    msg.append("groupId=");
1459                    msg.append(groupId);
1460    
1461                    msg.append(", entryCount=");
1462                    msg.append(entryCount);
1463    
1464                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1465    
1466                    throw new NoSuchStatsUserException(msg.toString());
1467            }
1468    
1469            /**
1470             * Returns the first blogs stats user in the ordered set where groupId = &#63; and entryCount &ne; &#63;.
1471             *
1472             * @param groupId the group ID
1473             * @param entryCount the entry count
1474             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1475             * @return the first matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
1476             * @throws SystemException if a system exception occurred
1477             */
1478            public BlogsStatsUser fetchByG_NotE_First(long groupId, int entryCount,
1479                    OrderByComparator orderByComparator) throws SystemException {
1480                    List<BlogsStatsUser> list = findByG_NotE(groupId, entryCount, 0, 1,
1481                                    orderByComparator);
1482    
1483                    if (!list.isEmpty()) {
1484                            return list.get(0);
1485                    }
1486    
1487                    return null;
1488            }
1489    
1490            /**
1491             * Returns the last blogs stats user in the ordered set where groupId = &#63; and entryCount &ne; &#63;.
1492             *
1493             * @param groupId the group ID
1494             * @param entryCount the entry count
1495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1496             * @return the last matching blogs stats user
1497             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
1498             * @throws SystemException if a system exception occurred
1499             */
1500            public BlogsStatsUser findByG_NotE_Last(long groupId, int entryCount,
1501                    OrderByComparator orderByComparator)
1502                    throws NoSuchStatsUserException, SystemException {
1503                    BlogsStatsUser blogsStatsUser = fetchByG_NotE_Last(groupId, entryCount,
1504                                    orderByComparator);
1505    
1506                    if (blogsStatsUser != null) {
1507                            return blogsStatsUser;
1508                    }
1509    
1510                    StringBundler msg = new StringBundler(6);
1511    
1512                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1513    
1514                    msg.append("groupId=");
1515                    msg.append(groupId);
1516    
1517                    msg.append(", entryCount=");
1518                    msg.append(entryCount);
1519    
1520                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1521    
1522                    throw new NoSuchStatsUserException(msg.toString());
1523            }
1524    
1525            /**
1526             * Returns the last blogs stats user in the ordered set where groupId = &#63; and entryCount &ne; &#63;.
1527             *
1528             * @param groupId the group ID
1529             * @param entryCount the entry count
1530             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1531             * @return the last matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
1532             * @throws SystemException if a system exception occurred
1533             */
1534            public BlogsStatsUser fetchByG_NotE_Last(long groupId, int entryCount,
1535                    OrderByComparator orderByComparator) throws SystemException {
1536                    int count = countByG_NotE(groupId, entryCount);
1537    
1538                    List<BlogsStatsUser> list = findByG_NotE(groupId, entryCount,
1539                                    count - 1, count, orderByComparator);
1540    
1541                    if (!list.isEmpty()) {
1542                            return list.get(0);
1543                    }
1544    
1545                    return null;
1546            }
1547    
1548            /**
1549             * Returns the blogs stats users before and after the current blogs stats user in the ordered set where groupId = &#63; and entryCount &ne; &#63;.
1550             *
1551             * @param statsUserId the primary key of the current blogs stats user
1552             * @param groupId the group ID
1553             * @param entryCount the entry count
1554             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1555             * @return the previous, current, and next blogs stats user
1556             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a blogs stats user with the primary key could not be found
1557             * @throws SystemException if a system exception occurred
1558             */
1559            public BlogsStatsUser[] findByG_NotE_PrevAndNext(long statsUserId,
1560                    long groupId, int entryCount, OrderByComparator orderByComparator)
1561                    throws NoSuchStatsUserException, SystemException {
1562                    BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1563    
1564                    Session session = null;
1565    
1566                    try {
1567                            session = openSession();
1568    
1569                            BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1570    
1571                            array[0] = getByG_NotE_PrevAndNext(session, blogsStatsUser,
1572                                            groupId, entryCount, orderByComparator, true);
1573    
1574                            array[1] = blogsStatsUser;
1575    
1576                            array[2] = getByG_NotE_PrevAndNext(session, blogsStatsUser,
1577                                            groupId, entryCount, orderByComparator, false);
1578    
1579                            return array;
1580                    }
1581                    catch (Exception e) {
1582                            throw processException(e);
1583                    }
1584                    finally {
1585                            closeSession(session);
1586                    }
1587            }
1588    
1589            protected BlogsStatsUser getByG_NotE_PrevAndNext(Session session,
1590                    BlogsStatsUser blogsStatsUser, long groupId, int entryCount,
1591                    OrderByComparator orderByComparator, boolean previous) {
1592                    StringBundler query = null;
1593    
1594                    if (orderByComparator != null) {
1595                            query = new StringBundler(6 +
1596                                            (orderByComparator.getOrderByFields().length * 6));
1597                    }
1598                    else {
1599                            query = new StringBundler(3);
1600                    }
1601    
1602                    query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1603    
1604                    query.append(_FINDER_COLUMN_G_NOTE_GROUPID_2);
1605    
1606                    query.append(_FINDER_COLUMN_G_NOTE_ENTRYCOUNT_2);
1607    
1608                    if (orderByComparator != null) {
1609                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1610    
1611                            if (orderByConditionFields.length > 0) {
1612                                    query.append(WHERE_AND);
1613                            }
1614    
1615                            for (int i = 0; i < orderByConditionFields.length; i++) {
1616                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1617                                    query.append(orderByConditionFields[i]);
1618    
1619                                    if ((i + 1) < orderByConditionFields.length) {
1620                                            if (orderByComparator.isAscending() ^ previous) {
1621                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1622                                            }
1623                                            else {
1624                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1625                                            }
1626                                    }
1627                                    else {
1628                                            if (orderByComparator.isAscending() ^ previous) {
1629                                                    query.append(WHERE_GREATER_THAN);
1630                                            }
1631                                            else {
1632                                                    query.append(WHERE_LESSER_THAN);
1633                                            }
1634                                    }
1635                            }
1636    
1637                            query.append(ORDER_BY_CLAUSE);
1638    
1639                            String[] orderByFields = orderByComparator.getOrderByFields();
1640    
1641                            for (int i = 0; i < orderByFields.length; i++) {
1642                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1643                                    query.append(orderByFields[i]);
1644    
1645                                    if ((i + 1) < orderByFields.length) {
1646                                            if (orderByComparator.isAscending() ^ previous) {
1647                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1648                                            }
1649                                            else {
1650                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1651                                            }
1652                                    }
1653                                    else {
1654                                            if (orderByComparator.isAscending() ^ previous) {
1655                                                    query.append(ORDER_BY_ASC);
1656                                            }
1657                                            else {
1658                                                    query.append(ORDER_BY_DESC);
1659                                            }
1660                                    }
1661                            }
1662                    }
1663                    else {
1664                            query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1665                    }
1666    
1667                    String sql = query.toString();
1668    
1669                    Query q = session.createQuery(sql);
1670    
1671                    q.setFirstResult(0);
1672                    q.setMaxResults(2);
1673    
1674                    QueryPos qPos = QueryPos.getInstance(q);
1675    
1676                    qPos.add(groupId);
1677    
1678                    qPos.add(entryCount);
1679    
1680                    if (orderByComparator != null) {
1681                            Object[] values = orderByComparator.getOrderByConditionValues(blogsStatsUser);
1682    
1683                            for (Object value : values) {
1684                                    qPos.add(value);
1685                            }
1686                    }
1687    
1688                    List<BlogsStatsUser> list = q.list();
1689    
1690                    if (list.size() == 2) {
1691                            return list.get(1);
1692                    }
1693                    else {
1694                            return null;
1695                    }
1696            }
1697    
1698            /**
1699             * Removes all the blogs stats users where groupId = &#63; and entryCount &ne; &#63; from the database.
1700             *
1701             * @param groupId the group ID
1702             * @param entryCount the entry count
1703             * @throws SystemException if a system exception occurred
1704             */
1705            public void removeByG_NotE(long groupId, int entryCount)
1706                    throws SystemException {
1707                    for (BlogsStatsUser blogsStatsUser : findByG_NotE(groupId, entryCount,
1708                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1709                            remove(blogsStatsUser);
1710                    }
1711            }
1712    
1713            /**
1714             * Returns the number of blogs stats users where groupId = &#63; and entryCount &ne; &#63;.
1715             *
1716             * @param groupId the group ID
1717             * @param entryCount the entry count
1718             * @return the number of matching blogs stats users
1719             * @throws SystemException if a system exception occurred
1720             */
1721            public int countByG_NotE(long groupId, int entryCount)
1722                    throws SystemException {
1723                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTE;
1724    
1725                    Object[] finderArgs = new Object[] { groupId, entryCount };
1726    
1727                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1728                                    this);
1729    
1730                    if (count == null) {
1731                            StringBundler query = new StringBundler(3);
1732    
1733                            query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
1734    
1735                            query.append(_FINDER_COLUMN_G_NOTE_GROUPID_2);
1736    
1737                            query.append(_FINDER_COLUMN_G_NOTE_ENTRYCOUNT_2);
1738    
1739                            String sql = query.toString();
1740    
1741                            Session session = null;
1742    
1743                            try {
1744                                    session = openSession();
1745    
1746                                    Query q = session.createQuery(sql);
1747    
1748                                    QueryPos qPos = QueryPos.getInstance(q);
1749    
1750                                    qPos.add(groupId);
1751    
1752                                    qPos.add(entryCount);
1753    
1754                                    count = (Long)q.uniqueResult();
1755    
1756                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1757                            }
1758                            catch (Exception e) {
1759                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1760    
1761                                    throw processException(e);
1762                            }
1763                            finally {
1764                                    closeSession(session);
1765                            }
1766                    }
1767    
1768                    return count.intValue();
1769            }
1770    
1771            private static final String _FINDER_COLUMN_G_NOTE_GROUPID_2 = "blogsStatsUser.groupId = ? AND ";
1772            private static final String _FINDER_COLUMN_G_NOTE_ENTRYCOUNT_2 = "blogsStatsUser.entryCount != ?";
1773            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTE = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
1774                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
1775                            BlogsStatsUserImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1776                            "findByC_NotE",
1777                            new String[] {
1778                                    Long.class.getName(), Integer.class.getName(),
1779                                    
1780                            Integer.class.getName(), Integer.class.getName(),
1781                                    OrderByComparator.class.getName()
1782                            });
1783            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTE = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
1784                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
1785                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotE",
1786                            new String[] { Long.class.getName(), Integer.class.getName() });
1787    
1788            /**
1789             * Returns all the blogs stats users where companyId = &#63; and entryCount &ne; &#63;.
1790             *
1791             * @param companyId the company ID
1792             * @param entryCount the entry count
1793             * @return the matching blogs stats users
1794             * @throws SystemException if a system exception occurred
1795             */
1796            public List<BlogsStatsUser> findByC_NotE(long companyId, int entryCount)
1797                    throws SystemException {
1798                    return findByC_NotE(companyId, entryCount, QueryUtil.ALL_POS,
1799                            QueryUtil.ALL_POS, null);
1800            }
1801    
1802            /**
1803             * Returns a range of all the blogs stats users where companyId = &#63; and entryCount &ne; &#63;.
1804             *
1805             * <p>
1806             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1807             * </p>
1808             *
1809             * @param companyId the company ID
1810             * @param entryCount the entry count
1811             * @param start the lower bound of the range of blogs stats users
1812             * @param end the upper bound of the range of blogs stats users (not inclusive)
1813             * @return the range of matching blogs stats users
1814             * @throws SystemException if a system exception occurred
1815             */
1816            public List<BlogsStatsUser> findByC_NotE(long companyId, int entryCount,
1817                    int start, int end) throws SystemException {
1818                    return findByC_NotE(companyId, entryCount, start, end, null);
1819            }
1820    
1821            /**
1822             * Returns an ordered range of all the blogs stats users where companyId = &#63; and entryCount &ne; &#63;.
1823             *
1824             * <p>
1825             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1826             * </p>
1827             *
1828             * @param companyId the company ID
1829             * @param entryCount the entry count
1830             * @param start the lower bound of the range of blogs stats users
1831             * @param end the upper bound of the range of blogs stats users (not inclusive)
1832             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1833             * @return the ordered range of matching blogs stats users
1834             * @throws SystemException if a system exception occurred
1835             */
1836            public List<BlogsStatsUser> findByC_NotE(long companyId, int entryCount,
1837                    int start, int end, OrderByComparator orderByComparator)
1838                    throws SystemException {
1839                    boolean pagination = true;
1840                    FinderPath finderPath = null;
1841                    Object[] finderArgs = null;
1842    
1843                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTE;
1844                    finderArgs = new Object[] {
1845                                    companyId, entryCount,
1846                                    
1847                                    start, end, orderByComparator
1848                            };
1849    
1850                    List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(finderPath,
1851                                    finderArgs, this);
1852    
1853                    if ((list != null) && !list.isEmpty()) {
1854                            for (BlogsStatsUser blogsStatsUser : list) {
1855                                    if ((companyId != blogsStatsUser.getCompanyId()) ||
1856                                                    (entryCount != blogsStatsUser.getEntryCount())) {
1857                                            list = null;
1858    
1859                                            break;
1860                                    }
1861                            }
1862                    }
1863    
1864                    if (list == null) {
1865                            StringBundler query = null;
1866    
1867                            if (orderByComparator != null) {
1868                                    query = new StringBundler(4 +
1869                                                    (orderByComparator.getOrderByFields().length * 3));
1870                            }
1871                            else {
1872                                    query = new StringBundler(4);
1873                            }
1874    
1875                            query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1876    
1877                            query.append(_FINDER_COLUMN_C_NOTE_COMPANYID_2);
1878    
1879                            query.append(_FINDER_COLUMN_C_NOTE_ENTRYCOUNT_2);
1880    
1881                            if (orderByComparator != null) {
1882                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1883                                            orderByComparator);
1884                            }
1885                            else
1886                             if (pagination) {
1887                                    query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1888                            }
1889    
1890                            String sql = query.toString();
1891    
1892                            Session session = null;
1893    
1894                            try {
1895                                    session = openSession();
1896    
1897                                    Query q = session.createQuery(sql);
1898    
1899                                    QueryPos qPos = QueryPos.getInstance(q);
1900    
1901                                    qPos.add(companyId);
1902    
1903                                    qPos.add(entryCount);
1904    
1905                                    if (!pagination) {
1906                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
1907                                                            getDialect(), start, end, false);
1908    
1909                                            Collections.sort(list);
1910    
1911                                            list = new UnmodifiableList<BlogsStatsUser>(list);
1912                                    }
1913                                    else {
1914                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
1915                                                            getDialect(), start, end);
1916                                    }
1917    
1918                                    cacheResult(list);
1919    
1920                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1921                            }
1922                            catch (Exception e) {
1923                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1924    
1925                                    throw processException(e);
1926                            }
1927                            finally {
1928                                    closeSession(session);
1929                            }
1930                    }
1931    
1932                    return list;
1933            }
1934    
1935            /**
1936             * Returns the first blogs stats user in the ordered set where companyId = &#63; and entryCount &ne; &#63;.
1937             *
1938             * @param companyId the company ID
1939             * @param entryCount the entry count
1940             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1941             * @return the first matching blogs stats user
1942             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
1943             * @throws SystemException if a system exception occurred
1944             */
1945            public BlogsStatsUser findByC_NotE_First(long companyId, int entryCount,
1946                    OrderByComparator orderByComparator)
1947                    throws NoSuchStatsUserException, SystemException {
1948                    BlogsStatsUser blogsStatsUser = fetchByC_NotE_First(companyId,
1949                                    entryCount, orderByComparator);
1950    
1951                    if (blogsStatsUser != null) {
1952                            return blogsStatsUser;
1953                    }
1954    
1955                    StringBundler msg = new StringBundler(6);
1956    
1957                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1958    
1959                    msg.append("companyId=");
1960                    msg.append(companyId);
1961    
1962                    msg.append(", entryCount=");
1963                    msg.append(entryCount);
1964    
1965                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1966    
1967                    throw new NoSuchStatsUserException(msg.toString());
1968            }
1969    
1970            /**
1971             * Returns the first blogs stats user in the ordered set where companyId = &#63; and entryCount &ne; &#63;.
1972             *
1973             * @param companyId the company ID
1974             * @param entryCount the entry count
1975             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1976             * @return the first matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
1977             * @throws SystemException if a system exception occurred
1978             */
1979            public BlogsStatsUser fetchByC_NotE_First(long companyId, int entryCount,
1980                    OrderByComparator orderByComparator) throws SystemException {
1981                    List<BlogsStatsUser> list = findByC_NotE(companyId, entryCount, 0, 1,
1982                                    orderByComparator);
1983    
1984                    if (!list.isEmpty()) {
1985                            return list.get(0);
1986                    }
1987    
1988                    return null;
1989            }
1990    
1991            /**
1992             * Returns the last blogs stats user in the ordered set where companyId = &#63; and entryCount &ne; &#63;.
1993             *
1994             * @param companyId the company ID
1995             * @param entryCount the entry count
1996             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1997             * @return the last matching blogs stats user
1998             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
1999             * @throws SystemException if a system exception occurred
2000             */
2001            public BlogsStatsUser findByC_NotE_Last(long companyId, int entryCount,
2002                    OrderByComparator orderByComparator)
2003                    throws NoSuchStatsUserException, SystemException {
2004                    BlogsStatsUser blogsStatsUser = fetchByC_NotE_Last(companyId,
2005                                    entryCount, orderByComparator);
2006    
2007                    if (blogsStatsUser != null) {
2008                            return blogsStatsUser;
2009                    }
2010    
2011                    StringBundler msg = new StringBundler(6);
2012    
2013                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2014    
2015                    msg.append("companyId=");
2016                    msg.append(companyId);
2017    
2018                    msg.append(", entryCount=");
2019                    msg.append(entryCount);
2020    
2021                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2022    
2023                    throw new NoSuchStatsUserException(msg.toString());
2024            }
2025    
2026            /**
2027             * Returns the last blogs stats user in the ordered set where companyId = &#63; and entryCount &ne; &#63;.
2028             *
2029             * @param companyId the company ID
2030             * @param entryCount the entry count
2031             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2032             * @return the last matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
2033             * @throws SystemException if a system exception occurred
2034             */
2035            public BlogsStatsUser fetchByC_NotE_Last(long companyId, int entryCount,
2036                    OrderByComparator orderByComparator) throws SystemException {
2037                    int count = countByC_NotE(companyId, entryCount);
2038    
2039                    List<BlogsStatsUser> list = findByC_NotE(companyId, entryCount,
2040                                    count - 1, count, orderByComparator);
2041    
2042                    if (!list.isEmpty()) {
2043                            return list.get(0);
2044                    }
2045    
2046                    return null;
2047            }
2048    
2049            /**
2050             * Returns the blogs stats users before and after the current blogs stats user in the ordered set where companyId = &#63; and entryCount &ne; &#63;.
2051             *
2052             * @param statsUserId the primary key of the current blogs stats user
2053             * @param companyId the company ID
2054             * @param entryCount the entry count
2055             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2056             * @return the previous, current, and next blogs stats user
2057             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a blogs stats user with the primary key could not be found
2058             * @throws SystemException if a system exception occurred
2059             */
2060            public BlogsStatsUser[] findByC_NotE_PrevAndNext(long statsUserId,
2061                    long companyId, int entryCount, OrderByComparator orderByComparator)
2062                    throws NoSuchStatsUserException, SystemException {
2063                    BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
2064    
2065                    Session session = null;
2066    
2067                    try {
2068                            session = openSession();
2069    
2070                            BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
2071    
2072                            array[0] = getByC_NotE_PrevAndNext(session, blogsStatsUser,
2073                                            companyId, entryCount, orderByComparator, true);
2074    
2075                            array[1] = blogsStatsUser;
2076    
2077                            array[2] = getByC_NotE_PrevAndNext(session, blogsStatsUser,
2078                                            companyId, entryCount, orderByComparator, false);
2079    
2080                            return array;
2081                    }
2082                    catch (Exception e) {
2083                            throw processException(e);
2084                    }
2085                    finally {
2086                            closeSession(session);
2087                    }
2088            }
2089    
2090            protected BlogsStatsUser getByC_NotE_PrevAndNext(Session session,
2091                    BlogsStatsUser blogsStatsUser, long companyId, int entryCount,
2092                    OrderByComparator orderByComparator, boolean previous) {
2093                    StringBundler query = null;
2094    
2095                    if (orderByComparator != null) {
2096                            query = new StringBundler(6 +
2097                                            (orderByComparator.getOrderByFields().length * 6));
2098                    }
2099                    else {
2100                            query = new StringBundler(3);
2101                    }
2102    
2103                    query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
2104    
2105                    query.append(_FINDER_COLUMN_C_NOTE_COMPANYID_2);
2106    
2107                    query.append(_FINDER_COLUMN_C_NOTE_ENTRYCOUNT_2);
2108    
2109                    if (orderByComparator != null) {
2110                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2111    
2112                            if (orderByConditionFields.length > 0) {
2113                                    query.append(WHERE_AND);
2114                            }
2115    
2116                            for (int i = 0; i < orderByConditionFields.length; i++) {
2117                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2118                                    query.append(orderByConditionFields[i]);
2119    
2120                                    if ((i + 1) < orderByConditionFields.length) {
2121                                            if (orderByComparator.isAscending() ^ previous) {
2122                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2123                                            }
2124                                            else {
2125                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2126                                            }
2127                                    }
2128                                    else {
2129                                            if (orderByComparator.isAscending() ^ previous) {
2130                                                    query.append(WHERE_GREATER_THAN);
2131                                            }
2132                                            else {
2133                                                    query.append(WHERE_LESSER_THAN);
2134                                            }
2135                                    }
2136                            }
2137    
2138                            query.append(ORDER_BY_CLAUSE);
2139    
2140                            String[] orderByFields = orderByComparator.getOrderByFields();
2141    
2142                            for (int i = 0; i < orderByFields.length; i++) {
2143                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2144                                    query.append(orderByFields[i]);
2145    
2146                                    if ((i + 1) < orderByFields.length) {
2147                                            if (orderByComparator.isAscending() ^ previous) {
2148                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2149                                            }
2150                                            else {
2151                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2152                                            }
2153                                    }
2154                                    else {
2155                                            if (orderByComparator.isAscending() ^ previous) {
2156                                                    query.append(ORDER_BY_ASC);
2157                                            }
2158                                            else {
2159                                                    query.append(ORDER_BY_DESC);
2160                                            }
2161                                    }
2162                            }
2163                    }
2164                    else {
2165                            query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
2166                    }
2167    
2168                    String sql = query.toString();
2169    
2170                    Query q = session.createQuery(sql);
2171    
2172                    q.setFirstResult(0);
2173                    q.setMaxResults(2);
2174    
2175                    QueryPos qPos = QueryPos.getInstance(q);
2176    
2177                    qPos.add(companyId);
2178    
2179                    qPos.add(entryCount);
2180    
2181                    if (orderByComparator != null) {
2182                            Object[] values = orderByComparator.getOrderByConditionValues(blogsStatsUser);
2183    
2184                            for (Object value : values) {
2185                                    qPos.add(value);
2186                            }
2187                    }
2188    
2189                    List<BlogsStatsUser> list = q.list();
2190    
2191                    if (list.size() == 2) {
2192                            return list.get(1);
2193                    }
2194                    else {
2195                            return null;
2196                    }
2197            }
2198    
2199            /**
2200             * Removes all the blogs stats users where companyId = &#63; and entryCount &ne; &#63; from the database.
2201             *
2202             * @param companyId the company ID
2203             * @param entryCount the entry count
2204             * @throws SystemException if a system exception occurred
2205             */
2206            public void removeByC_NotE(long companyId, int entryCount)
2207                    throws SystemException {
2208                    for (BlogsStatsUser blogsStatsUser : findByC_NotE(companyId,
2209                                    entryCount, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2210                            remove(blogsStatsUser);
2211                    }
2212            }
2213    
2214            /**
2215             * Returns the number of blogs stats users where companyId = &#63; and entryCount &ne; &#63;.
2216             *
2217             * @param companyId the company ID
2218             * @param entryCount the entry count
2219             * @return the number of matching blogs stats users
2220             * @throws SystemException if a system exception occurred
2221             */
2222            public int countByC_NotE(long companyId, int entryCount)
2223                    throws SystemException {
2224                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTE;
2225    
2226                    Object[] finderArgs = new Object[] { companyId, entryCount };
2227    
2228                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2229                                    this);
2230    
2231                    if (count == null) {
2232                            StringBundler query = new StringBundler(3);
2233    
2234                            query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
2235    
2236                            query.append(_FINDER_COLUMN_C_NOTE_COMPANYID_2);
2237    
2238                            query.append(_FINDER_COLUMN_C_NOTE_ENTRYCOUNT_2);
2239    
2240                            String sql = query.toString();
2241    
2242                            Session session = null;
2243    
2244                            try {
2245                                    session = openSession();
2246    
2247                                    Query q = session.createQuery(sql);
2248    
2249                                    QueryPos qPos = QueryPos.getInstance(q);
2250    
2251                                    qPos.add(companyId);
2252    
2253                                    qPos.add(entryCount);
2254    
2255                                    count = (Long)q.uniqueResult();
2256    
2257                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2258                            }
2259                            catch (Exception e) {
2260                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2261    
2262                                    throw processException(e);
2263                            }
2264                            finally {
2265                                    closeSession(session);
2266                            }
2267                    }
2268    
2269                    return count.intValue();
2270            }
2271    
2272            private static final String _FINDER_COLUMN_C_NOTE_COMPANYID_2 = "blogsStatsUser.companyId = ? AND ";
2273            private static final String _FINDER_COLUMN_C_NOTE_ENTRYCOUNT_2 = "blogsStatsUser.entryCount != ?";
2274            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_L = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
2275                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
2276                            BlogsStatsUserImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2277                            "findByU_L",
2278                            new String[] {
2279                                    Long.class.getName(), Date.class.getName(),
2280                                    
2281                            Integer.class.getName(), Integer.class.getName(),
2282                                    OrderByComparator.class.getName()
2283                            });
2284            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_L = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
2285                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
2286                            BlogsStatsUserImpl.class,
2287                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_L",
2288                            new String[] { Long.class.getName(), Date.class.getName() },
2289                            BlogsStatsUserModelImpl.USERID_COLUMN_BITMASK |
2290                            BlogsStatsUserModelImpl.LASTPOSTDATE_COLUMN_BITMASK |
2291                            BlogsStatsUserModelImpl.ENTRYCOUNT_COLUMN_BITMASK);
2292            public static final FinderPath FINDER_PATH_COUNT_BY_U_L = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
2293                            BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
2294                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_L",
2295                            new String[] { Long.class.getName(), Date.class.getName() });
2296    
2297            /**
2298             * Returns all the blogs stats users where userId = &#63; and lastPostDate = &#63;.
2299             *
2300             * @param userId the user ID
2301             * @param lastPostDate the last post date
2302             * @return the matching blogs stats users
2303             * @throws SystemException if a system exception occurred
2304             */
2305            public List<BlogsStatsUser> findByU_L(long userId, Date lastPostDate)
2306                    throws SystemException {
2307                    return findByU_L(userId, lastPostDate, QueryUtil.ALL_POS,
2308                            QueryUtil.ALL_POS, null);
2309            }
2310    
2311            /**
2312             * Returns a range of all the blogs stats users where userId = &#63; and lastPostDate = &#63;.
2313             *
2314             * <p>
2315             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2316             * </p>
2317             *
2318             * @param userId the user ID
2319             * @param lastPostDate the last post date
2320             * @param start the lower bound of the range of blogs stats users
2321             * @param end the upper bound of the range of blogs stats users (not inclusive)
2322             * @return the range of matching blogs stats users
2323             * @throws SystemException if a system exception occurred
2324             */
2325            public List<BlogsStatsUser> findByU_L(long userId, Date lastPostDate,
2326                    int start, int end) throws SystemException {
2327                    return findByU_L(userId, lastPostDate, start, end, null);
2328            }
2329    
2330            /**
2331             * Returns an ordered range of all the blogs stats users where userId = &#63; and lastPostDate = &#63;.
2332             *
2333             * <p>
2334             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2335             * </p>
2336             *
2337             * @param userId the user ID
2338             * @param lastPostDate the last post date
2339             * @param start the lower bound of the range of blogs stats users
2340             * @param end the upper bound of the range of blogs stats users (not inclusive)
2341             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2342             * @return the ordered range of matching blogs stats users
2343             * @throws SystemException if a system exception occurred
2344             */
2345            public List<BlogsStatsUser> findByU_L(long userId, Date lastPostDate,
2346                    int start, int end, OrderByComparator orderByComparator)
2347                    throws SystemException {
2348                    boolean pagination = true;
2349                    FinderPath finderPath = null;
2350                    Object[] finderArgs = null;
2351    
2352                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2353                                    (orderByComparator == null)) {
2354                            pagination = false;
2355                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_L;
2356                            finderArgs = new Object[] { userId, lastPostDate };
2357                    }
2358                    else {
2359                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_L;
2360                            finderArgs = new Object[] {
2361                                            userId, lastPostDate,
2362                                            
2363                                            start, end, orderByComparator
2364                                    };
2365                    }
2366    
2367                    List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(finderPath,
2368                                    finderArgs, this);
2369    
2370                    if ((list != null) && !list.isEmpty()) {
2371                            for (BlogsStatsUser blogsStatsUser : list) {
2372                                    if ((userId != blogsStatsUser.getUserId()) ||
2373                                                    !Validator.equals(lastPostDate,
2374                                                            blogsStatsUser.getLastPostDate())) {
2375                                            list = null;
2376    
2377                                            break;
2378                                    }
2379                            }
2380                    }
2381    
2382                    if (list == null) {
2383                            StringBundler query = null;
2384    
2385                            if (orderByComparator != null) {
2386                                    query = new StringBundler(4 +
2387                                                    (orderByComparator.getOrderByFields().length * 3));
2388                            }
2389                            else {
2390                                    query = new StringBundler(4);
2391                            }
2392    
2393                            query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
2394    
2395                            query.append(_FINDER_COLUMN_U_L_USERID_2);
2396    
2397                            if (lastPostDate == null) {
2398                                    query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_1);
2399                            }
2400                            else {
2401                                    query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_2);
2402                            }
2403    
2404                            if (orderByComparator != null) {
2405                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2406                                            orderByComparator);
2407                            }
2408                            else
2409                             if (pagination) {
2410                                    query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
2411                            }
2412    
2413                            String sql = query.toString();
2414    
2415                            Session session = null;
2416    
2417                            try {
2418                                    session = openSession();
2419    
2420                                    Query q = session.createQuery(sql);
2421    
2422                                    QueryPos qPos = QueryPos.getInstance(q);
2423    
2424                                    qPos.add(userId);
2425    
2426                                    if (lastPostDate != null) {
2427                                            qPos.add(CalendarUtil.getTimestamp(lastPostDate));
2428                                    }
2429    
2430                                    if (!pagination) {
2431                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
2432                                                            getDialect(), start, end, false);
2433    
2434                                            Collections.sort(list);
2435    
2436                                            list = new UnmodifiableList<BlogsStatsUser>(list);
2437                                    }
2438                                    else {
2439                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
2440                                                            getDialect(), start, end);
2441                                    }
2442    
2443                                    cacheResult(list);
2444    
2445                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2446                            }
2447                            catch (Exception e) {
2448                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2449    
2450                                    throw processException(e);
2451                            }
2452                            finally {
2453                                    closeSession(session);
2454                            }
2455                    }
2456    
2457                    return list;
2458            }
2459    
2460            /**
2461             * Returns the first blogs stats user in the ordered set where userId = &#63; and lastPostDate = &#63;.
2462             *
2463             * @param userId the user ID
2464             * @param lastPostDate the last post date
2465             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2466             * @return the first matching blogs stats user
2467             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
2468             * @throws SystemException if a system exception occurred
2469             */
2470            public BlogsStatsUser findByU_L_First(long userId, Date lastPostDate,
2471                    OrderByComparator orderByComparator)
2472                    throws NoSuchStatsUserException, SystemException {
2473                    BlogsStatsUser blogsStatsUser = fetchByU_L_First(userId, lastPostDate,
2474                                    orderByComparator);
2475    
2476                    if (blogsStatsUser != null) {
2477                            return blogsStatsUser;
2478                    }
2479    
2480                    StringBundler msg = new StringBundler(6);
2481    
2482                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2483    
2484                    msg.append("userId=");
2485                    msg.append(userId);
2486    
2487                    msg.append(", lastPostDate=");
2488                    msg.append(lastPostDate);
2489    
2490                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2491    
2492                    throw new NoSuchStatsUserException(msg.toString());
2493            }
2494    
2495            /**
2496             * Returns the first blogs stats user in the ordered set where userId = &#63; and lastPostDate = &#63;.
2497             *
2498             * @param userId the user ID
2499             * @param lastPostDate the last post date
2500             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2501             * @return the first matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
2502             * @throws SystemException if a system exception occurred
2503             */
2504            public BlogsStatsUser fetchByU_L_First(long userId, Date lastPostDate,
2505                    OrderByComparator orderByComparator) throws SystemException {
2506                    List<BlogsStatsUser> list = findByU_L(userId, lastPostDate, 0, 1,
2507                                    orderByComparator);
2508    
2509                    if (!list.isEmpty()) {
2510                            return list.get(0);
2511                    }
2512    
2513                    return null;
2514            }
2515    
2516            /**
2517             * Returns the last blogs stats user in the ordered set where userId = &#63; and lastPostDate = &#63;.
2518             *
2519             * @param userId the user ID
2520             * @param lastPostDate the last post date
2521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2522             * @return the last matching blogs stats user
2523             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a matching blogs stats user could not be found
2524             * @throws SystemException if a system exception occurred
2525             */
2526            public BlogsStatsUser findByU_L_Last(long userId, Date lastPostDate,
2527                    OrderByComparator orderByComparator)
2528                    throws NoSuchStatsUserException, SystemException {
2529                    BlogsStatsUser blogsStatsUser = fetchByU_L_Last(userId, lastPostDate,
2530                                    orderByComparator);
2531    
2532                    if (blogsStatsUser != null) {
2533                            return blogsStatsUser;
2534                    }
2535    
2536                    StringBundler msg = new StringBundler(6);
2537    
2538                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2539    
2540                    msg.append("userId=");
2541                    msg.append(userId);
2542    
2543                    msg.append(", lastPostDate=");
2544                    msg.append(lastPostDate);
2545    
2546                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2547    
2548                    throw new NoSuchStatsUserException(msg.toString());
2549            }
2550    
2551            /**
2552             * Returns the last blogs stats user in the ordered set where userId = &#63; and lastPostDate = &#63;.
2553             *
2554             * @param userId the user ID
2555             * @param lastPostDate the last post date
2556             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2557             * @return the last matching blogs stats user, or <code>null</code> if a matching blogs stats user could not be found
2558             * @throws SystemException if a system exception occurred
2559             */
2560            public BlogsStatsUser fetchByU_L_Last(long userId, Date lastPostDate,
2561                    OrderByComparator orderByComparator) throws SystemException {
2562                    int count = countByU_L(userId, lastPostDate);
2563    
2564                    List<BlogsStatsUser> list = findByU_L(userId, lastPostDate, count - 1,
2565                                    count, orderByComparator);
2566    
2567                    if (!list.isEmpty()) {
2568                            return list.get(0);
2569                    }
2570    
2571                    return null;
2572            }
2573    
2574            /**
2575             * Returns the blogs stats users before and after the current blogs stats user in the ordered set where userId = &#63; and lastPostDate = &#63;.
2576             *
2577             * @param statsUserId the primary key of the current blogs stats user
2578             * @param userId the user ID
2579             * @param lastPostDate the last post date
2580             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2581             * @return the previous, current, and next blogs stats user
2582             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a blogs stats user with the primary key could not be found
2583             * @throws SystemException if a system exception occurred
2584             */
2585            public BlogsStatsUser[] findByU_L_PrevAndNext(long statsUserId,
2586                    long userId, Date lastPostDate, OrderByComparator orderByComparator)
2587                    throws NoSuchStatsUserException, SystemException {
2588                    BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
2589    
2590                    Session session = null;
2591    
2592                    try {
2593                            session = openSession();
2594    
2595                            BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
2596    
2597                            array[0] = getByU_L_PrevAndNext(session, blogsStatsUser, userId,
2598                                            lastPostDate, orderByComparator, true);
2599    
2600                            array[1] = blogsStatsUser;
2601    
2602                            array[2] = getByU_L_PrevAndNext(session, blogsStatsUser, userId,
2603                                            lastPostDate, orderByComparator, false);
2604    
2605                            return array;
2606                    }
2607                    catch (Exception e) {
2608                            throw processException(e);
2609                    }
2610                    finally {
2611                            closeSession(session);
2612                    }
2613            }
2614    
2615            protected BlogsStatsUser getByU_L_PrevAndNext(Session session,
2616                    BlogsStatsUser blogsStatsUser, long userId, Date lastPostDate,
2617                    OrderByComparator orderByComparator, boolean previous) {
2618                    StringBundler query = null;
2619    
2620                    if (orderByComparator != null) {
2621                            query = new StringBundler(6 +
2622                                            (orderByComparator.getOrderByFields().length * 6));
2623                    }
2624                    else {
2625                            query = new StringBundler(3);
2626                    }
2627    
2628                    query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
2629    
2630                    query.append(_FINDER_COLUMN_U_L_USERID_2);
2631    
2632                    if (lastPostDate == null) {
2633                            query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_1);
2634                    }
2635                    else {
2636                            query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_2);
2637                    }
2638    
2639                    if (orderByComparator != null) {
2640                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2641    
2642                            if (orderByConditionFields.length > 0) {
2643                                    query.append(WHERE_AND);
2644                            }
2645    
2646                            for (int i = 0; i < orderByConditionFields.length; i++) {
2647                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2648                                    query.append(orderByConditionFields[i]);
2649    
2650                                    if ((i + 1) < orderByConditionFields.length) {
2651                                            if (orderByComparator.isAscending() ^ previous) {
2652                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2653                                            }
2654                                            else {
2655                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2656                                            }
2657                                    }
2658                                    else {
2659                                            if (orderByComparator.isAscending() ^ previous) {
2660                                                    query.append(WHERE_GREATER_THAN);
2661                                            }
2662                                            else {
2663                                                    query.append(WHERE_LESSER_THAN);
2664                                            }
2665                                    }
2666                            }
2667    
2668                            query.append(ORDER_BY_CLAUSE);
2669    
2670                            String[] orderByFields = orderByComparator.getOrderByFields();
2671    
2672                            for (int i = 0; i < orderByFields.length; i++) {
2673                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2674                                    query.append(orderByFields[i]);
2675    
2676                                    if ((i + 1) < orderByFields.length) {
2677                                            if (orderByComparator.isAscending() ^ previous) {
2678                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2679                                            }
2680                                            else {
2681                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2682                                            }
2683                                    }
2684                                    else {
2685                                            if (orderByComparator.isAscending() ^ previous) {
2686                                                    query.append(ORDER_BY_ASC);
2687                                            }
2688                                            else {
2689                                                    query.append(ORDER_BY_DESC);
2690                                            }
2691                                    }
2692                            }
2693                    }
2694                    else {
2695                            query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
2696                    }
2697    
2698                    String sql = query.toString();
2699    
2700                    Query q = session.createQuery(sql);
2701    
2702                    q.setFirstResult(0);
2703                    q.setMaxResults(2);
2704    
2705                    QueryPos qPos = QueryPos.getInstance(q);
2706    
2707                    qPos.add(userId);
2708    
2709                    if (lastPostDate != null) {
2710                            qPos.add(CalendarUtil.getTimestamp(lastPostDate));
2711                    }
2712    
2713                    if (orderByComparator != null) {
2714                            Object[] values = orderByComparator.getOrderByConditionValues(blogsStatsUser);
2715    
2716                            for (Object value : values) {
2717                                    qPos.add(value);
2718                            }
2719                    }
2720    
2721                    List<BlogsStatsUser> list = q.list();
2722    
2723                    if (list.size() == 2) {
2724                            return list.get(1);
2725                    }
2726                    else {
2727                            return null;
2728                    }
2729            }
2730    
2731            /**
2732             * Removes all the blogs stats users where userId = &#63; and lastPostDate = &#63; from the database.
2733             *
2734             * @param userId the user ID
2735             * @param lastPostDate the last post date
2736             * @throws SystemException if a system exception occurred
2737             */
2738            public void removeByU_L(long userId, Date lastPostDate)
2739                    throws SystemException {
2740                    for (BlogsStatsUser blogsStatsUser : findByU_L(userId, lastPostDate,
2741                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2742                            remove(blogsStatsUser);
2743                    }
2744            }
2745    
2746            /**
2747             * Returns the number of blogs stats users where userId = &#63; and lastPostDate = &#63;.
2748             *
2749             * @param userId the user ID
2750             * @param lastPostDate the last post date
2751             * @return the number of matching blogs stats users
2752             * @throws SystemException if a system exception occurred
2753             */
2754            public int countByU_L(long userId, Date lastPostDate)
2755                    throws SystemException {
2756                    FinderPath finderPath = FINDER_PATH_COUNT_BY_U_L;
2757    
2758                    Object[] finderArgs = new Object[] { userId, lastPostDate };
2759    
2760                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2761                                    this);
2762    
2763                    if (count == null) {
2764                            StringBundler query = new StringBundler(3);
2765    
2766                            query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
2767    
2768                            query.append(_FINDER_COLUMN_U_L_USERID_2);
2769    
2770                            if (lastPostDate == null) {
2771                                    query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_1);
2772                            }
2773                            else {
2774                                    query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_2);
2775                            }
2776    
2777                            String sql = query.toString();
2778    
2779                            Session session = null;
2780    
2781                            try {
2782                                    session = openSession();
2783    
2784                                    Query q = session.createQuery(sql);
2785    
2786                                    QueryPos qPos = QueryPos.getInstance(q);
2787    
2788                                    qPos.add(userId);
2789    
2790                                    if (lastPostDate != null) {
2791                                            qPos.add(CalendarUtil.getTimestamp(lastPostDate));
2792                                    }
2793    
2794                                    count = (Long)q.uniqueResult();
2795    
2796                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2797                            }
2798                            catch (Exception e) {
2799                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2800    
2801                                    throw processException(e);
2802                            }
2803                            finally {
2804                                    closeSession(session);
2805                            }
2806                    }
2807    
2808                    return count.intValue();
2809            }
2810    
2811            private static final String _FINDER_COLUMN_U_L_USERID_2 = "blogsStatsUser.userId = ? AND ";
2812            private static final String _FINDER_COLUMN_U_L_LASTPOSTDATE_1 = "blogsStatsUser.lastPostDate IS NULL";
2813            private static final String _FINDER_COLUMN_U_L_LASTPOSTDATE_2 = "blogsStatsUser.lastPostDate = ?";
2814    
2815            /**
2816             * Caches the blogs stats user in the entity cache if it is enabled.
2817             *
2818             * @param blogsStatsUser the blogs stats user
2819             */
2820            public void cacheResult(BlogsStatsUser blogsStatsUser) {
2821                    EntityCacheUtil.putResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
2822                            BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey(),
2823                            blogsStatsUser);
2824    
2825                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
2826                            new Object[] {
2827                                    Long.valueOf(blogsStatsUser.getGroupId()),
2828                                    Long.valueOf(blogsStatsUser.getUserId())
2829                            }, blogsStatsUser);
2830    
2831                    blogsStatsUser.resetOriginalValues();
2832            }
2833    
2834            /**
2835             * Caches the blogs stats users in the entity cache if it is enabled.
2836             *
2837             * @param blogsStatsUsers the blogs stats users
2838             */
2839            public void cacheResult(List<BlogsStatsUser> blogsStatsUsers) {
2840                    for (BlogsStatsUser blogsStatsUser : blogsStatsUsers) {
2841                            if (EntityCacheUtil.getResult(
2842                                                    BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
2843                                                    BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey()) == null) {
2844                                    cacheResult(blogsStatsUser);
2845                            }
2846                            else {
2847                                    blogsStatsUser.resetOriginalValues();
2848                            }
2849                    }
2850            }
2851    
2852            /**
2853             * Clears the cache for all blogs stats users.
2854             *
2855             * <p>
2856             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2857             * </p>
2858             */
2859            @Override
2860            public void clearCache() {
2861                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2862                            CacheRegistryUtil.clear(BlogsStatsUserImpl.class.getName());
2863                    }
2864    
2865                    EntityCacheUtil.clearCache(BlogsStatsUserImpl.class.getName());
2866    
2867                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2868                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2869                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2870            }
2871    
2872            /**
2873             * Clears the cache for the blogs stats user.
2874             *
2875             * <p>
2876             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2877             * </p>
2878             */
2879            @Override
2880            public void clearCache(BlogsStatsUser blogsStatsUser) {
2881                    EntityCacheUtil.removeResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
2882                            BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey());
2883    
2884                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2885                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2886    
2887                    clearUniqueFindersCache(blogsStatsUser);
2888            }
2889    
2890            @Override
2891            public void clearCache(List<BlogsStatsUser> blogsStatsUsers) {
2892                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2893                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2894    
2895                    for (BlogsStatsUser blogsStatsUser : blogsStatsUsers) {
2896                            EntityCacheUtil.removeResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
2897                                    BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey());
2898    
2899                            clearUniqueFindersCache(blogsStatsUser);
2900                    }
2901            }
2902    
2903            protected void cacheUniqueFindersCache(BlogsStatsUser blogsStatsUser) {
2904                    if (blogsStatsUser.isNew()) {
2905                            Object[] args = new Object[] {
2906                                            Long.valueOf(blogsStatsUser.getGroupId()),
2907                                            Long.valueOf(blogsStatsUser.getUserId())
2908                                    };
2909    
2910                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, args,
2911                                    Long.valueOf(1));
2912                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U, args,
2913                                    blogsStatsUser);
2914                    }
2915                    else {
2916                            BlogsStatsUserModelImpl blogsStatsUserModelImpl = (BlogsStatsUserModelImpl)blogsStatsUser;
2917    
2918                            if ((blogsStatsUserModelImpl.getColumnBitmask() &
2919                                            FINDER_PATH_FETCH_BY_G_U.getColumnBitmask()) != 0) {
2920                                    Object[] args = new Object[] {
2921                                                    Long.valueOf(blogsStatsUser.getGroupId()),
2922                                                    Long.valueOf(blogsStatsUser.getUserId())
2923                                            };
2924    
2925                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, args,
2926                                            Long.valueOf(1));
2927                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U, args,
2928                                            blogsStatsUser);
2929                            }
2930                    }
2931            }
2932    
2933            protected void clearUniqueFindersCache(BlogsStatsUser blogsStatsUser) {
2934                    BlogsStatsUserModelImpl blogsStatsUserModelImpl = (BlogsStatsUserModelImpl)blogsStatsUser;
2935    
2936                    Object[] args = new Object[] {
2937                                    Long.valueOf(blogsStatsUser.getGroupId()),
2938                                    Long.valueOf(blogsStatsUser.getUserId())
2939                            };
2940    
2941                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
2942                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U, args);
2943    
2944                    if ((blogsStatsUserModelImpl.getColumnBitmask() &
2945                                    FINDER_PATH_FETCH_BY_G_U.getColumnBitmask()) != 0) {
2946                            args = new Object[] {
2947                                            Long.valueOf(blogsStatsUserModelImpl.getOriginalGroupId()),
2948                                            Long.valueOf(blogsStatsUserModelImpl.getOriginalUserId())
2949                                    };
2950    
2951                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
2952                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U, args);
2953                    }
2954            }
2955    
2956            /**
2957             * Creates a new blogs stats user with the primary key. Does not add the blogs stats user to the database.
2958             *
2959             * @param statsUserId the primary key for the new blogs stats user
2960             * @return the new blogs stats user
2961             */
2962            public BlogsStatsUser create(long statsUserId) {
2963                    BlogsStatsUser blogsStatsUser = new BlogsStatsUserImpl();
2964    
2965                    blogsStatsUser.setNew(true);
2966                    blogsStatsUser.setPrimaryKey(statsUserId);
2967    
2968                    return blogsStatsUser;
2969            }
2970    
2971            /**
2972             * Removes the blogs stats user with the primary key from the database. Also notifies the appropriate model listeners.
2973             *
2974             * @param statsUserId the primary key of the blogs stats user
2975             * @return the blogs stats user that was removed
2976             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a blogs stats user with the primary key could not be found
2977             * @throws SystemException if a system exception occurred
2978             */
2979            public BlogsStatsUser remove(long statsUserId)
2980                    throws NoSuchStatsUserException, SystemException {
2981                    return remove(Long.valueOf(statsUserId));
2982            }
2983    
2984            /**
2985             * Removes the blogs stats user with the primary key from the database. Also notifies the appropriate model listeners.
2986             *
2987             * @param primaryKey the primary key of the blogs stats user
2988             * @return the blogs stats user that was removed
2989             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a blogs stats user with the primary key could not be found
2990             * @throws SystemException if a system exception occurred
2991             */
2992            @Override
2993            public BlogsStatsUser remove(Serializable primaryKey)
2994                    throws NoSuchStatsUserException, SystemException {
2995                    Session session = null;
2996    
2997                    try {
2998                            session = openSession();
2999    
3000                            BlogsStatsUser blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
3001                                            primaryKey);
3002    
3003                            if (blogsStatsUser == null) {
3004                                    if (_log.isWarnEnabled()) {
3005                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3006                                    }
3007    
3008                                    throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3009                                            primaryKey);
3010                            }
3011    
3012                            return remove(blogsStatsUser);
3013                    }
3014                    catch (NoSuchStatsUserException nsee) {
3015                            throw nsee;
3016                    }
3017                    catch (Exception e) {
3018                            throw processException(e);
3019                    }
3020                    finally {
3021                            closeSession(session);
3022                    }
3023            }
3024    
3025            @Override
3026            protected BlogsStatsUser removeImpl(BlogsStatsUser blogsStatsUser)
3027                    throws SystemException {
3028                    blogsStatsUser = toUnwrappedModel(blogsStatsUser);
3029    
3030                    Session session = null;
3031    
3032                    try {
3033                            session = openSession();
3034    
3035                            if (!session.contains(blogsStatsUser)) {
3036                                    blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
3037                                                    blogsStatsUser.getPrimaryKeyObj());
3038                            }
3039    
3040                            if (blogsStatsUser != null) {
3041                                    session.delete(blogsStatsUser);
3042                            }
3043                    }
3044                    catch (Exception e) {
3045                            throw processException(e);
3046                    }
3047                    finally {
3048                            closeSession(session);
3049                    }
3050    
3051                    if (blogsStatsUser != null) {
3052                            clearCache(blogsStatsUser);
3053                    }
3054    
3055                    return blogsStatsUser;
3056            }
3057    
3058            @Override
3059            public BlogsStatsUser updateImpl(
3060                    com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser)
3061                    throws SystemException {
3062                    blogsStatsUser = toUnwrappedModel(blogsStatsUser);
3063    
3064                    boolean isNew = blogsStatsUser.isNew();
3065    
3066                    BlogsStatsUserModelImpl blogsStatsUserModelImpl = (BlogsStatsUserModelImpl)blogsStatsUser;
3067    
3068                    Session session = null;
3069    
3070                    try {
3071                            session = openSession();
3072    
3073                            if (blogsStatsUser.isNew()) {
3074                                    session.save(blogsStatsUser);
3075    
3076                                    blogsStatsUser.setNew(false);
3077                            }
3078                            else {
3079                                    session.merge(blogsStatsUser);
3080                            }
3081                    }
3082                    catch (Exception e) {
3083                            throw processException(e);
3084                    }
3085                    finally {
3086                            closeSession(session);
3087                    }
3088    
3089                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3090    
3091                    if (isNew || !BlogsStatsUserModelImpl.COLUMN_BITMASK_ENABLED) {
3092                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3093                    }
3094    
3095                    else {
3096                            if ((blogsStatsUserModelImpl.getColumnBitmask() &
3097                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
3098                                    Object[] args = new Object[] {
3099                                                    Long.valueOf(blogsStatsUserModelImpl.getOriginalGroupId())
3100                                            };
3101    
3102                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3103                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3104                                            args);
3105    
3106                                    args = new Object[] {
3107                                                    Long.valueOf(blogsStatsUserModelImpl.getGroupId())
3108                                            };
3109    
3110                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3111                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3112                                            args);
3113                            }
3114    
3115                            if ((blogsStatsUserModelImpl.getColumnBitmask() &
3116                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
3117                                    Object[] args = new Object[] {
3118                                                    Long.valueOf(blogsStatsUserModelImpl.getOriginalUserId())
3119                                            };
3120    
3121                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
3122                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
3123                                            args);
3124    
3125                                    args = new Object[] {
3126                                                    Long.valueOf(blogsStatsUserModelImpl.getUserId())
3127                                            };
3128    
3129                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
3130                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
3131                                            args);
3132                            }
3133    
3134                            if ((blogsStatsUserModelImpl.getColumnBitmask() &
3135                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_L.getColumnBitmask()) != 0) {
3136                                    Object[] args = new Object[] {
3137                                                    Long.valueOf(blogsStatsUserModelImpl.getOriginalUserId()),
3138                                                    
3139                                                    blogsStatsUserModelImpl.getOriginalLastPostDate()
3140                                            };
3141    
3142                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_L, args);
3143                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_L,
3144                                            args);
3145    
3146                                    args = new Object[] {
3147                                                    Long.valueOf(blogsStatsUserModelImpl.getUserId()),
3148                                                    
3149                                                    blogsStatsUserModelImpl.getLastPostDate()
3150                                            };
3151    
3152                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_L, args);
3153                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_L,
3154                                            args);
3155                            }
3156                    }
3157    
3158                    EntityCacheUtil.putResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
3159                            BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey(),
3160                            blogsStatsUser);
3161    
3162                    clearUniqueFindersCache(blogsStatsUser);
3163                    cacheUniqueFindersCache(blogsStatsUser);
3164    
3165                    return blogsStatsUser;
3166            }
3167    
3168            protected BlogsStatsUser toUnwrappedModel(BlogsStatsUser blogsStatsUser) {
3169                    if (blogsStatsUser instanceof BlogsStatsUserImpl) {
3170                            return blogsStatsUser;
3171                    }
3172    
3173                    BlogsStatsUserImpl blogsStatsUserImpl = new BlogsStatsUserImpl();
3174    
3175                    blogsStatsUserImpl.setNew(blogsStatsUser.isNew());
3176                    blogsStatsUserImpl.setPrimaryKey(blogsStatsUser.getPrimaryKey());
3177    
3178                    blogsStatsUserImpl.setStatsUserId(blogsStatsUser.getStatsUserId());
3179                    blogsStatsUserImpl.setGroupId(blogsStatsUser.getGroupId());
3180                    blogsStatsUserImpl.setCompanyId(blogsStatsUser.getCompanyId());
3181                    blogsStatsUserImpl.setUserId(blogsStatsUser.getUserId());
3182                    blogsStatsUserImpl.setEntryCount(blogsStatsUser.getEntryCount());
3183                    blogsStatsUserImpl.setLastPostDate(blogsStatsUser.getLastPostDate());
3184                    blogsStatsUserImpl.setRatingsTotalEntries(blogsStatsUser.getRatingsTotalEntries());
3185                    blogsStatsUserImpl.setRatingsTotalScore(blogsStatsUser.getRatingsTotalScore());
3186                    blogsStatsUserImpl.setRatingsAverageScore(blogsStatsUser.getRatingsAverageScore());
3187    
3188                    return blogsStatsUserImpl;
3189            }
3190    
3191            /**
3192             * Returns the blogs stats user with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
3193             *
3194             * @param primaryKey the primary key of the blogs stats user
3195             * @return the blogs stats user
3196             * @throws com.liferay.portal.NoSuchModelException if a blogs stats user with the primary key could not be found
3197             * @throws SystemException if a system exception occurred
3198             */
3199            @Override
3200            public BlogsStatsUser findByPrimaryKey(Serializable primaryKey)
3201                    throws NoSuchModelException, SystemException {
3202                    return findByPrimaryKey(((Long)primaryKey).longValue());
3203            }
3204    
3205            /**
3206             * Returns the blogs stats user with the primary key or throws a {@link com.liferay.portlet.blogs.NoSuchStatsUserException} if it could not be found.
3207             *
3208             * @param statsUserId the primary key of the blogs stats user
3209             * @return the blogs stats user
3210             * @throws com.liferay.portlet.blogs.NoSuchStatsUserException if a blogs stats user with the primary key could not be found
3211             * @throws SystemException if a system exception occurred
3212             */
3213            public BlogsStatsUser findByPrimaryKey(long statsUserId)
3214                    throws NoSuchStatsUserException, SystemException {
3215                    BlogsStatsUser blogsStatsUser = fetchByPrimaryKey(statsUserId);
3216    
3217                    if (blogsStatsUser == null) {
3218                            if (_log.isWarnEnabled()) {
3219                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsUserId);
3220                            }
3221    
3222                            throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3223                                    statsUserId);
3224                    }
3225    
3226                    return blogsStatsUser;
3227            }
3228    
3229            /**
3230             * Returns the blogs stats user with the primary key or returns <code>null</code> if it could not be found.
3231             *
3232             * @param primaryKey the primary key of the blogs stats user
3233             * @return the blogs stats user, or <code>null</code> if a blogs stats user with the primary key could not be found
3234             * @throws SystemException if a system exception occurred
3235             */
3236            @Override
3237            public BlogsStatsUser fetchByPrimaryKey(Serializable primaryKey)
3238                    throws SystemException {
3239                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
3240            }
3241    
3242            /**
3243             * Returns the blogs stats user with the primary key or returns <code>null</code> if it could not be found.
3244             *
3245             * @param statsUserId the primary key of the blogs stats user
3246             * @return the blogs stats user, or <code>null</code> if a blogs stats user with the primary key could not be found
3247             * @throws SystemException if a system exception occurred
3248             */
3249            public BlogsStatsUser fetchByPrimaryKey(long statsUserId)
3250                    throws SystemException {
3251                    BlogsStatsUser blogsStatsUser = (BlogsStatsUser)EntityCacheUtil.getResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
3252                                    BlogsStatsUserImpl.class, statsUserId);
3253    
3254                    if (blogsStatsUser == _nullBlogsStatsUser) {
3255                            return null;
3256                    }
3257    
3258                    if (blogsStatsUser == null) {
3259                            Session session = null;
3260    
3261                            try {
3262                                    session = openSession();
3263    
3264                                    blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
3265                                                    Long.valueOf(statsUserId));
3266    
3267                                    if (blogsStatsUser != null) {
3268                                            cacheResult(blogsStatsUser);
3269                                    }
3270                                    else {
3271                                            EntityCacheUtil.putResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
3272                                                    BlogsStatsUserImpl.class, statsUserId,
3273                                                    _nullBlogsStatsUser);
3274                                    }
3275                            }
3276                            catch (Exception e) {
3277                                    EntityCacheUtil.removeResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
3278                                            BlogsStatsUserImpl.class, statsUserId);
3279    
3280                                    throw processException(e);
3281                            }
3282                            finally {
3283                                    closeSession(session);
3284                            }
3285                    }
3286    
3287                    return blogsStatsUser;
3288            }
3289    
3290            /**
3291             * Returns all the blogs stats users.
3292             *
3293             * @return the blogs stats users
3294             * @throws SystemException if a system exception occurred
3295             */
3296            public List<BlogsStatsUser> findAll() throws SystemException {
3297                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3298            }
3299    
3300            /**
3301             * Returns a range of all the blogs stats users.
3302             *
3303             * <p>
3304             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3305             * </p>
3306             *
3307             * @param start the lower bound of the range of blogs stats users
3308             * @param end the upper bound of the range of blogs stats users (not inclusive)
3309             * @return the range of blogs stats users
3310             * @throws SystemException if a system exception occurred
3311             */
3312            public List<BlogsStatsUser> findAll(int start, int end)
3313                    throws SystemException {
3314                    return findAll(start, end, null);
3315            }
3316    
3317            /**
3318             * Returns an ordered range of all the blogs stats users.
3319             *
3320             * <p>
3321             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3322             * </p>
3323             *
3324             * @param start the lower bound of the range of blogs stats users
3325             * @param end the upper bound of the range of blogs stats users (not inclusive)
3326             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3327             * @return the ordered range of blogs stats users
3328             * @throws SystemException if a system exception occurred
3329             */
3330            public List<BlogsStatsUser> findAll(int start, int end,
3331                    OrderByComparator orderByComparator) throws SystemException {
3332                    boolean pagination = true;
3333                    FinderPath finderPath = null;
3334                    Object[] finderArgs = null;
3335    
3336                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3337                                    (orderByComparator == null)) {
3338                            pagination = false;
3339                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3340                            finderArgs = FINDER_ARGS_EMPTY;
3341                    }
3342                    else {
3343                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3344                            finderArgs = new Object[] { start, end, orderByComparator };
3345                    }
3346    
3347                    List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(finderPath,
3348                                    finderArgs, this);
3349    
3350                    if (list == null) {
3351                            StringBundler query = null;
3352                            String sql = null;
3353    
3354                            if (orderByComparator != null) {
3355                                    query = new StringBundler(2 +
3356                                                    (orderByComparator.getOrderByFields().length * 3));
3357    
3358                                    query.append(_SQL_SELECT_BLOGSSTATSUSER);
3359    
3360                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3361                                            orderByComparator);
3362    
3363                                    sql = query.toString();
3364                            }
3365                            else {
3366                                    sql = _SQL_SELECT_BLOGSSTATSUSER;
3367    
3368                                    if (pagination) {
3369                                            sql = sql.concat(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
3370                                    }
3371                            }
3372    
3373                            Session session = null;
3374    
3375                            try {
3376                                    session = openSession();
3377    
3378                                    Query q = session.createQuery(sql);
3379    
3380                                    if (!pagination) {
3381                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
3382                                                            getDialect(), start, end, false);
3383    
3384                                            Collections.sort(list);
3385    
3386                                            list = new UnmodifiableList<BlogsStatsUser>(list);
3387                                    }
3388                                    else {
3389                                            list = (List<BlogsStatsUser>)QueryUtil.list(q,
3390                                                            getDialect(), start, end);
3391                                    }
3392    
3393                                    cacheResult(list);
3394    
3395                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3396                            }
3397                            catch (Exception e) {
3398                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3399    
3400                                    throw processException(e);
3401                            }
3402                            finally {
3403                                    closeSession(session);
3404                            }
3405                    }
3406    
3407                    return list;
3408            }
3409    
3410            /**
3411             * Removes all the blogs stats users from the database.
3412             *
3413             * @throws SystemException if a system exception occurred
3414             */
3415            public void removeAll() throws SystemException {
3416                    for (BlogsStatsUser blogsStatsUser : findAll()) {
3417                            remove(blogsStatsUser);
3418                    }
3419            }
3420    
3421            /**
3422             * Returns the number of blogs stats users.
3423             *
3424             * @return the number of blogs stats users
3425             * @throws SystemException if a system exception occurred
3426             */
3427            public int countAll() throws SystemException {
3428                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3429                                    FINDER_ARGS_EMPTY, this);
3430    
3431                    if (count == null) {
3432                            Session session = null;
3433    
3434                            try {
3435                                    session = openSession();
3436    
3437                                    Query q = session.createQuery(_SQL_COUNT_BLOGSSTATSUSER);
3438    
3439                                    count = (Long)q.uniqueResult();
3440    
3441                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3442                                            FINDER_ARGS_EMPTY, count);
3443                            }
3444                            catch (Exception e) {
3445                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3446                                            FINDER_ARGS_EMPTY);
3447    
3448                                    throw processException(e);
3449                            }
3450                            finally {
3451                                    closeSession(session);
3452                            }
3453                    }
3454    
3455                    return count.intValue();
3456            }
3457    
3458            /**
3459             * Initializes the blogs stats user persistence.
3460             */
3461            public void afterPropertiesSet() {
3462                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3463                                            com.liferay.portal.util.PropsUtil.get(
3464                                                    "value.object.listener.com.liferay.portlet.blogs.model.BlogsStatsUser")));
3465    
3466                    if (listenerClassNames.length > 0) {
3467                            try {
3468                                    List<ModelListener<BlogsStatsUser>> listenersList = new ArrayList<ModelListener<BlogsStatsUser>>();
3469    
3470                                    for (String listenerClassName : listenerClassNames) {
3471                                            listenersList.add((ModelListener<BlogsStatsUser>)InstanceFactory.newInstance(
3472                                                            listenerClassName));
3473                                    }
3474    
3475                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3476                            }
3477                            catch (Exception e) {
3478                                    _log.error(e);
3479                            }
3480                    }
3481            }
3482    
3483            public void destroy() {
3484                    EntityCacheUtil.removeCache(BlogsStatsUserImpl.class.getName());
3485                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3486                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3487                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3488            }
3489    
3490            private static final String _SQL_SELECT_BLOGSSTATSUSER = "SELECT blogsStatsUser FROM BlogsStatsUser blogsStatsUser";
3491            private static final String _SQL_SELECT_BLOGSSTATSUSER_WHERE = "SELECT blogsStatsUser FROM BlogsStatsUser blogsStatsUser WHERE ";
3492            private static final String _SQL_COUNT_BLOGSSTATSUSER = "SELECT COUNT(blogsStatsUser) FROM BlogsStatsUser blogsStatsUser";
3493            private static final String _SQL_COUNT_BLOGSSTATSUSER_WHERE = "SELECT COUNT(blogsStatsUser) FROM BlogsStatsUser blogsStatsUser WHERE ";
3494            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsStatsUser.";
3495            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsStatsUser exists with the primary key ";
3496            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsStatsUser exists with the key {";
3497            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3498            private static Log _log = LogFactoryUtil.getLog(BlogsStatsUserPersistenceImpl.class);
3499            private static BlogsStatsUser _nullBlogsStatsUser = new BlogsStatsUserImpl() {
3500                            @Override
3501                            public Object clone() {
3502                                    return this;
3503                            }
3504    
3505                            @Override
3506                            public CacheModel<BlogsStatsUser> toCacheModel() {
3507                                    return _nullBlogsStatsUserCacheModel;
3508                            }
3509                    };
3510    
3511            private static CacheModel<BlogsStatsUser> _nullBlogsStatsUserCacheModel = new CacheModel<BlogsStatsUser>() {
3512                            public BlogsStatsUser toEntityModel() {
3513                                    return _nullBlogsStatsUser;
3514                            }
3515                    };
3516    }