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