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