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