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