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