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.messageboards.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.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.GroupPersistence;
040    import com.liferay.portal.service.persistence.ResourcePersistence;
041    import com.liferay.portal.service.persistence.UserPersistence;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.messageboards.NoSuchStatsUserException;
045    import com.liferay.portlet.messageboards.model.MBStatsUser;
046    import com.liferay.portlet.messageboards.model.impl.MBStatsUserImpl;
047    import com.liferay.portlet.messageboards.model.impl.MBStatsUserModelImpl;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    
055    /**
056     * The persistence implementation for the message boards stats user service.
057     *
058     * <p>
059     * Caching information and settings can be found in <code>portal.properties</code>
060     * </p>
061     *
062     * @author Brian Wing Shun Chan
063     * @see MBStatsUserPersistence
064     * @see MBStatsUserUtil
065     * @generated
066     */
067    public class MBStatsUserPersistenceImpl extends BasePersistenceImpl<MBStatsUser>
068            implements MBStatsUserPersistence {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link MBStatsUserUtil} to access the message boards stats user persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
073             */
074            public static final String FINDER_CLASS_NAME_ENTITY = MBStatsUserImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List1";
077            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List2";
079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
080                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, MBStatsUserImpl.class,
081                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
082                            new String[] {
083                                    Long.class.getName(),
084                                    
085                            "java.lang.Integer", "java.lang.Integer",
086                                    "com.liferay.portal.kernel.util.OrderByComparator"
087                            });
088            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
089                    new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
090                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, MBStatsUserImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
092                            new String[] { Long.class.getName() },
093                            MBStatsUserModelImpl.GROUPID_COLUMN_BITMASK);
094            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
095                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
097                            new String[] { Long.class.getName() });
098            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
099                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, MBStatsUserImpl.class,
100                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
101                            new String[] {
102                                    Long.class.getName(),
103                                    
104                            "java.lang.Integer", "java.lang.Integer",
105                                    "com.liferay.portal.kernel.util.OrderByComparator"
106                            });
107            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
108                    new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
109                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, MBStatsUserImpl.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
111                            new String[] { Long.class.getName() },
112                            MBStatsUserModelImpl.USERID_COLUMN_BITMASK);
113            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
114                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
116                            new String[] { Long.class.getName() });
117            public static final FinderPath FINDER_PATH_FETCH_BY_G_U = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
118                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, MBStatsUserImpl.class,
119                            FINDER_CLASS_NAME_ENTITY, "fetchByG_U",
120                            new String[] { Long.class.getName(), Long.class.getName() },
121                            MBStatsUserModelImpl.GROUPID_COLUMN_BITMASK |
122                            MBStatsUserModelImpl.USERID_COLUMN_BITMASK);
123            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
124                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
125                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
126                            new String[] { Long.class.getName(), Long.class.getName() });
127            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTU_NOTM =
128                    new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
129                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, MBStatsUserImpl.class,
130                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotU_NotM",
131                            new String[] {
132                                    Long.class.getName(), Long.class.getName(),
133                                    Integer.class.getName(),
134                                    
135                            "java.lang.Integer", "java.lang.Integer",
136                                    "com.liferay.portal.kernel.util.OrderByComparator"
137                            });
138            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTU_NOTM =
139                    new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
140                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
141                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotU_NotM",
142                            new String[] {
143                                    Long.class.getName(), Long.class.getName(),
144                                    Integer.class.getName()
145                            });
146            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
147                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, MBStatsUserImpl.class,
148                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
149            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
150                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, MBStatsUserImpl.class,
151                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
152            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
153                            MBStatsUserModelImpl.FINDER_CACHE_ENABLED, Long.class,
154                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
155    
156            /**
157             * Caches the message boards stats user in the entity cache if it is enabled.
158             *
159             * @param mbStatsUser the message boards stats user
160             */
161            public void cacheResult(MBStatsUser mbStatsUser) {
162                    EntityCacheUtil.putResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
163                            MBStatsUserImpl.class, mbStatsUser.getPrimaryKey(), mbStatsUser);
164    
165                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
166                            new Object[] {
167                                    Long.valueOf(mbStatsUser.getGroupId()),
168                                    Long.valueOf(mbStatsUser.getUserId())
169                            }, mbStatsUser);
170    
171                    mbStatsUser.resetOriginalValues();
172            }
173    
174            /**
175             * Caches the message boards stats users in the entity cache if it is enabled.
176             *
177             * @param mbStatsUsers the message boards stats users
178             */
179            public void cacheResult(List<MBStatsUser> mbStatsUsers) {
180                    for (MBStatsUser mbStatsUser : mbStatsUsers) {
181                            if (EntityCacheUtil.getResult(
182                                                    MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
183                                                    MBStatsUserImpl.class, mbStatsUser.getPrimaryKey()) == null) {
184                                    cacheResult(mbStatsUser);
185                            }
186                            else {
187                                    mbStatsUser.resetOriginalValues();
188                            }
189                    }
190            }
191    
192            /**
193             * Clears the cache for all message boards stats users.
194             *
195             * <p>
196             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
197             * </p>
198             */
199            @Override
200            public void clearCache() {
201                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
202                            CacheRegistryUtil.clear(MBStatsUserImpl.class.getName());
203                    }
204    
205                    EntityCacheUtil.clearCache(MBStatsUserImpl.class.getName());
206    
207                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
208                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
209                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
210            }
211    
212            /**
213             * Clears the cache for the message boards stats user.
214             *
215             * <p>
216             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
217             * </p>
218             */
219            @Override
220            public void clearCache(MBStatsUser mbStatsUser) {
221                    EntityCacheUtil.removeResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
222                            MBStatsUserImpl.class, mbStatsUser.getPrimaryKey());
223    
224                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
225                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
226    
227                    clearUniqueFindersCache(mbStatsUser);
228            }
229    
230            @Override
231            public void clearCache(List<MBStatsUser> mbStatsUsers) {
232                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
233                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
234    
235                    for (MBStatsUser mbStatsUser : mbStatsUsers) {
236                            EntityCacheUtil.removeResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
237                                    MBStatsUserImpl.class, mbStatsUser.getPrimaryKey());
238    
239                            clearUniqueFindersCache(mbStatsUser);
240                    }
241            }
242    
243            protected void clearUniqueFindersCache(MBStatsUser mbStatsUser) {
244                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
245                            new Object[] {
246                                    Long.valueOf(mbStatsUser.getGroupId()),
247                                    Long.valueOf(mbStatsUser.getUserId())
248                            });
249            }
250    
251            /**
252             * Creates a new message boards stats user with the primary key. Does not add the message boards stats user to the database.
253             *
254             * @param statsUserId the primary key for the new message boards stats user
255             * @return the new message boards stats user
256             */
257            public MBStatsUser create(long statsUserId) {
258                    MBStatsUser mbStatsUser = new MBStatsUserImpl();
259    
260                    mbStatsUser.setNew(true);
261                    mbStatsUser.setPrimaryKey(statsUserId);
262    
263                    return mbStatsUser;
264            }
265    
266            /**
267             * Removes the message boards stats user with the primary key from the database. Also notifies the appropriate model listeners.
268             *
269             * @param statsUserId the primary key of the message boards stats user
270             * @return the message boards stats user that was removed
271             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a message boards stats user with the primary key could not be found
272             * @throws SystemException if a system exception occurred
273             */
274            public MBStatsUser remove(long statsUserId)
275                    throws NoSuchStatsUserException, SystemException {
276                    return remove(Long.valueOf(statsUserId));
277            }
278    
279            /**
280             * Removes the message boards stats user with the primary key from the database. Also notifies the appropriate model listeners.
281             *
282             * @param primaryKey the primary key of the message boards stats user
283             * @return the message boards stats user that was removed
284             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a message boards stats user with the primary key could not be found
285             * @throws SystemException if a system exception occurred
286             */
287            @Override
288            public MBStatsUser remove(Serializable primaryKey)
289                    throws NoSuchStatsUserException, SystemException {
290                    Session session = null;
291    
292                    try {
293                            session = openSession();
294    
295                            MBStatsUser mbStatsUser = (MBStatsUser)session.get(MBStatsUserImpl.class,
296                                            primaryKey);
297    
298                            if (mbStatsUser == null) {
299                                    if (_log.isWarnEnabled()) {
300                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
301                                    }
302    
303                                    throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
304                                            primaryKey);
305                            }
306    
307                            return remove(mbStatsUser);
308                    }
309                    catch (NoSuchStatsUserException nsee) {
310                            throw nsee;
311                    }
312                    catch (Exception e) {
313                            throw processException(e);
314                    }
315                    finally {
316                            closeSession(session);
317                    }
318            }
319    
320            @Override
321            protected MBStatsUser removeImpl(MBStatsUser mbStatsUser)
322                    throws SystemException {
323                    mbStatsUser = toUnwrappedModel(mbStatsUser);
324    
325                    Session session = null;
326    
327                    try {
328                            session = openSession();
329    
330                            BatchSessionUtil.delete(session, mbStatsUser);
331                    }
332                    catch (Exception e) {
333                            throw processException(e);
334                    }
335                    finally {
336                            closeSession(session);
337                    }
338    
339                    clearCache(mbStatsUser);
340    
341                    return mbStatsUser;
342            }
343    
344            @Override
345            public MBStatsUser updateImpl(
346                    com.liferay.portlet.messageboards.model.MBStatsUser mbStatsUser,
347                    boolean merge) throws SystemException {
348                    mbStatsUser = toUnwrappedModel(mbStatsUser);
349    
350                    boolean isNew = mbStatsUser.isNew();
351    
352                    MBStatsUserModelImpl mbStatsUserModelImpl = (MBStatsUserModelImpl)mbStatsUser;
353    
354                    Session session = null;
355    
356                    try {
357                            session = openSession();
358    
359                            BatchSessionUtil.update(session, mbStatsUser, merge);
360    
361                            mbStatsUser.setNew(false);
362                    }
363                    catch (Exception e) {
364                            throw processException(e);
365                    }
366                    finally {
367                            closeSession(session);
368                    }
369    
370                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
371    
372                    if (isNew || !MBStatsUserModelImpl.COLUMN_BITMASK_ENABLED) {
373                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
374                    }
375    
376                    else {
377                            if ((mbStatsUserModelImpl.getColumnBitmask() &
378                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
379                                    Object[] args = new Object[] {
380                                                    Long.valueOf(mbStatsUserModelImpl.getOriginalGroupId())
381                                            };
382    
383                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
384                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
385                                            args);
386    
387                                    args = new Object[] {
388                                                    Long.valueOf(mbStatsUserModelImpl.getGroupId())
389                                            };
390    
391                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
392                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
393                                            args);
394                            }
395    
396                            if ((mbStatsUserModelImpl.getColumnBitmask() &
397                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
398                                    Object[] args = new Object[] {
399                                                    Long.valueOf(mbStatsUserModelImpl.getOriginalUserId())
400                                            };
401    
402                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
403                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
404                                            args);
405    
406                                    args = new Object[] {
407                                                    Long.valueOf(mbStatsUserModelImpl.getUserId())
408                                            };
409    
410                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
411                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
412                                            args);
413                            }
414                    }
415    
416                    EntityCacheUtil.putResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
417                            MBStatsUserImpl.class, mbStatsUser.getPrimaryKey(), mbStatsUser);
418    
419                    if (isNew) {
420                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
421                                    new Object[] {
422                                            Long.valueOf(mbStatsUser.getGroupId()),
423                                            Long.valueOf(mbStatsUser.getUserId())
424                                    }, mbStatsUser);
425                    }
426                    else {
427                            if ((mbStatsUserModelImpl.getColumnBitmask() &
428                                            FINDER_PATH_FETCH_BY_G_U.getColumnBitmask()) != 0) {
429                                    Object[] args = new Object[] {
430                                                    Long.valueOf(mbStatsUserModelImpl.getOriginalGroupId()),
431                                                    Long.valueOf(mbStatsUserModelImpl.getOriginalUserId())
432                                            };
433    
434                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
435    
436                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U, args);
437    
438                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
439                                            new Object[] {
440                                                    Long.valueOf(mbStatsUser.getGroupId()),
441                                                    Long.valueOf(mbStatsUser.getUserId())
442                                            }, mbStatsUser);
443                            }
444                    }
445    
446                    return mbStatsUser;
447            }
448    
449            protected MBStatsUser toUnwrappedModel(MBStatsUser mbStatsUser) {
450                    if (mbStatsUser instanceof MBStatsUserImpl) {
451                            return mbStatsUser;
452                    }
453    
454                    MBStatsUserImpl mbStatsUserImpl = new MBStatsUserImpl();
455    
456                    mbStatsUserImpl.setNew(mbStatsUser.isNew());
457                    mbStatsUserImpl.setPrimaryKey(mbStatsUser.getPrimaryKey());
458    
459                    mbStatsUserImpl.setStatsUserId(mbStatsUser.getStatsUserId());
460                    mbStatsUserImpl.setGroupId(mbStatsUser.getGroupId());
461                    mbStatsUserImpl.setUserId(mbStatsUser.getUserId());
462                    mbStatsUserImpl.setMessageCount(mbStatsUser.getMessageCount());
463                    mbStatsUserImpl.setLastPostDate(mbStatsUser.getLastPostDate());
464    
465                    return mbStatsUserImpl;
466            }
467    
468            /**
469             * Returns the message boards stats user with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
470             *
471             * @param primaryKey the primary key of the message boards stats user
472             * @return the message boards stats user
473             * @throws com.liferay.portal.NoSuchModelException if a message boards stats user with the primary key could not be found
474             * @throws SystemException if a system exception occurred
475             */
476            @Override
477            public MBStatsUser findByPrimaryKey(Serializable primaryKey)
478                    throws NoSuchModelException, SystemException {
479                    return findByPrimaryKey(((Long)primaryKey).longValue());
480            }
481    
482            /**
483             * Returns the message boards stats user with the primary key or throws a {@link com.liferay.portlet.messageboards.NoSuchStatsUserException} if it could not be found.
484             *
485             * @param statsUserId the primary key of the message boards stats user
486             * @return the message boards stats user
487             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a message boards stats user with the primary key could not be found
488             * @throws SystemException if a system exception occurred
489             */
490            public MBStatsUser findByPrimaryKey(long statsUserId)
491                    throws NoSuchStatsUserException, SystemException {
492                    MBStatsUser mbStatsUser = fetchByPrimaryKey(statsUserId);
493    
494                    if (mbStatsUser == null) {
495                            if (_log.isWarnEnabled()) {
496                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsUserId);
497                            }
498    
499                            throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
500                                    statsUserId);
501                    }
502    
503                    return mbStatsUser;
504            }
505    
506            /**
507             * Returns the message boards stats user with the primary key or returns <code>null</code> if it could not be found.
508             *
509             * @param primaryKey the primary key of the message boards stats user
510             * @return the message boards stats user, or <code>null</code> if a message boards stats user with the primary key could not be found
511             * @throws SystemException if a system exception occurred
512             */
513            @Override
514            public MBStatsUser fetchByPrimaryKey(Serializable primaryKey)
515                    throws SystemException {
516                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
517            }
518    
519            /**
520             * Returns the message boards stats user with the primary key or returns <code>null</code> if it could not be found.
521             *
522             * @param statsUserId the primary key of the message boards stats user
523             * @return the message boards stats user, or <code>null</code> if a message boards stats user with the primary key could not be found
524             * @throws SystemException if a system exception occurred
525             */
526            public MBStatsUser fetchByPrimaryKey(long statsUserId)
527                    throws SystemException {
528                    MBStatsUser mbStatsUser = (MBStatsUser)EntityCacheUtil.getResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
529                                    MBStatsUserImpl.class, statsUserId);
530    
531                    if (mbStatsUser == _nullMBStatsUser) {
532                            return null;
533                    }
534    
535                    if (mbStatsUser == null) {
536                            Session session = null;
537    
538                            boolean hasException = false;
539    
540                            try {
541                                    session = openSession();
542    
543                                    mbStatsUser = (MBStatsUser)session.get(MBStatsUserImpl.class,
544                                                    Long.valueOf(statsUserId));
545                            }
546                            catch (Exception e) {
547                                    hasException = true;
548    
549                                    throw processException(e);
550                            }
551                            finally {
552                                    if (mbStatsUser != null) {
553                                            cacheResult(mbStatsUser);
554                                    }
555                                    else if (!hasException) {
556                                            EntityCacheUtil.putResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
557                                                    MBStatsUserImpl.class, statsUserId, _nullMBStatsUser);
558                                    }
559    
560                                    closeSession(session);
561                            }
562                    }
563    
564                    return mbStatsUser;
565            }
566    
567            /**
568             * Returns all the message boards stats users where groupId = &#63;.
569             *
570             * @param groupId the group ID
571             * @return the matching message boards stats users
572             * @throws SystemException if a system exception occurred
573             */
574            public List<MBStatsUser> findByGroupId(long groupId)
575                    throws SystemException {
576                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
577            }
578    
579            /**
580             * Returns a range of all the message boards stats users where groupId = &#63;.
581             *
582             * <p>
583             * 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.
584             * </p>
585             *
586             * @param groupId the group ID
587             * @param start the lower bound of the range of message boards stats users
588             * @param end the upper bound of the range of message boards stats users (not inclusive)
589             * @return the range of matching message boards stats users
590             * @throws SystemException if a system exception occurred
591             */
592            public List<MBStatsUser> findByGroupId(long groupId, int start, int end)
593                    throws SystemException {
594                    return findByGroupId(groupId, start, end, null);
595            }
596    
597            /**
598             * Returns an ordered range of all the message boards stats users where groupId = &#63;.
599             *
600             * <p>
601             * 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.
602             * </p>
603             *
604             * @param groupId the group ID
605             * @param start the lower bound of the range of message boards stats users
606             * @param end the upper bound of the range of message boards stats users (not inclusive)
607             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
608             * @return the ordered range of matching message boards stats users
609             * @throws SystemException if a system exception occurred
610             */
611            public List<MBStatsUser> findByGroupId(long groupId, int start, int end,
612                    OrderByComparator orderByComparator) throws SystemException {
613                    FinderPath finderPath = null;
614                    Object[] finderArgs = null;
615    
616                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
617                                    (orderByComparator == null)) {
618                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
619                            finderArgs = new Object[] { groupId };
620                    }
621                    else {
622                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
623                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
624                    }
625    
626                    List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(finderPath,
627                                    finderArgs, this);
628    
629                    if ((list != null) && !list.isEmpty()) {
630                            for (MBStatsUser mbStatsUser : list) {
631                                    if ((groupId != mbStatsUser.getGroupId())) {
632                                            list = null;
633    
634                                            break;
635                                    }
636                            }
637                    }
638    
639                    if (list == null) {
640                            StringBundler query = null;
641    
642                            if (orderByComparator != null) {
643                                    query = new StringBundler(3 +
644                                                    (orderByComparator.getOrderByFields().length * 3));
645                            }
646                            else {
647                                    query = new StringBundler(3);
648                            }
649    
650                            query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
651    
652                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
653    
654                            if (orderByComparator != null) {
655                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
656                                            orderByComparator);
657                            }
658    
659                            else {
660                                    query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
661                            }
662    
663                            String sql = query.toString();
664    
665                            Session session = null;
666    
667                            try {
668                                    session = openSession();
669    
670                                    Query q = session.createQuery(sql);
671    
672                                    QueryPos qPos = QueryPos.getInstance(q);
673    
674                                    qPos.add(groupId);
675    
676                                    list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
677                                                    start, end);
678                            }
679                            catch (Exception e) {
680                                    throw processException(e);
681                            }
682                            finally {
683                                    if (list == null) {
684                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
685                                    }
686                                    else {
687                                            cacheResult(list);
688    
689                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
690                                    }
691    
692                                    closeSession(session);
693                            }
694                    }
695    
696                    return list;
697            }
698    
699            /**
700             * Returns the first message boards stats user in the ordered set where groupId = &#63;.
701             *
702             * @param groupId the group ID
703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
704             * @return the first matching message boards stats user
705             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a matching message boards stats user could not be found
706             * @throws SystemException if a system exception occurred
707             */
708            public MBStatsUser findByGroupId_First(long groupId,
709                    OrderByComparator orderByComparator)
710                    throws NoSuchStatsUserException, SystemException {
711                    MBStatsUser mbStatsUser = fetchByGroupId_First(groupId,
712                                    orderByComparator);
713    
714                    if (mbStatsUser != null) {
715                            return mbStatsUser;
716                    }
717    
718                    StringBundler msg = new StringBundler(4);
719    
720                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
721    
722                    msg.append("groupId=");
723                    msg.append(groupId);
724    
725                    msg.append(StringPool.CLOSE_CURLY_BRACE);
726    
727                    throw new NoSuchStatsUserException(msg.toString());
728            }
729    
730            /**
731             * Returns the first message boards stats user in the ordered set where groupId = &#63;.
732             *
733             * @param groupId the group ID
734             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
735             * @return the first matching message boards stats user, or <code>null</code> if a matching message boards stats user could not be found
736             * @throws SystemException if a system exception occurred
737             */
738            public MBStatsUser fetchByGroupId_First(long groupId,
739                    OrderByComparator orderByComparator) throws SystemException {
740                    List<MBStatsUser> list = findByGroupId(groupId, 0, 1, orderByComparator);
741    
742                    if (!list.isEmpty()) {
743                            return list.get(0);
744                    }
745    
746                    return null;
747            }
748    
749            /**
750             * Returns the last message boards stats user in the ordered set where groupId = &#63;.
751             *
752             * @param groupId the group ID
753             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
754             * @return the last matching message boards stats user
755             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a matching message boards stats user could not be found
756             * @throws SystemException if a system exception occurred
757             */
758            public MBStatsUser findByGroupId_Last(long groupId,
759                    OrderByComparator orderByComparator)
760                    throws NoSuchStatsUserException, SystemException {
761                    MBStatsUser mbStatsUser = fetchByGroupId_Last(groupId, orderByComparator);
762    
763                    if (mbStatsUser != null) {
764                            return mbStatsUser;
765                    }
766    
767                    StringBundler msg = new StringBundler(4);
768    
769                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
770    
771                    msg.append("groupId=");
772                    msg.append(groupId);
773    
774                    msg.append(StringPool.CLOSE_CURLY_BRACE);
775    
776                    throw new NoSuchStatsUserException(msg.toString());
777            }
778    
779            /**
780             * Returns the last message boards stats user in the ordered set where groupId = &#63;.
781             *
782             * @param groupId the group ID
783             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
784             * @return the last matching message boards stats user, or <code>null</code> if a matching message boards stats user could not be found
785             * @throws SystemException if a system exception occurred
786             */
787            public MBStatsUser fetchByGroupId_Last(long groupId,
788                    OrderByComparator orderByComparator) throws SystemException {
789                    int count = countByGroupId(groupId);
790    
791                    List<MBStatsUser> list = findByGroupId(groupId, count - 1, count,
792                                    orderByComparator);
793    
794                    if (!list.isEmpty()) {
795                            return list.get(0);
796                    }
797    
798                    return null;
799            }
800    
801            /**
802             * Returns the message boards stats users before and after the current message boards stats user in the ordered set where groupId = &#63;.
803             *
804             * @param statsUserId the primary key of the current message boards stats user
805             * @param groupId the group ID
806             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
807             * @return the previous, current, and next message boards stats user
808             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a message boards stats user with the primary key could not be found
809             * @throws SystemException if a system exception occurred
810             */
811            public MBStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
812                    long groupId, OrderByComparator orderByComparator)
813                    throws NoSuchStatsUserException, SystemException {
814                    MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
815    
816                    Session session = null;
817    
818                    try {
819                            session = openSession();
820    
821                            MBStatsUser[] array = new MBStatsUserImpl[3];
822    
823                            array[0] = getByGroupId_PrevAndNext(session, mbStatsUser, groupId,
824                                            orderByComparator, true);
825    
826                            array[1] = mbStatsUser;
827    
828                            array[2] = getByGroupId_PrevAndNext(session, mbStatsUser, groupId,
829                                            orderByComparator, false);
830    
831                            return array;
832                    }
833                    catch (Exception e) {
834                            throw processException(e);
835                    }
836                    finally {
837                            closeSession(session);
838                    }
839            }
840    
841            protected MBStatsUser getByGroupId_PrevAndNext(Session session,
842                    MBStatsUser mbStatsUser, long groupId,
843                    OrderByComparator orderByComparator, boolean previous) {
844                    StringBundler query = null;
845    
846                    if (orderByComparator != null) {
847                            query = new StringBundler(6 +
848                                            (orderByComparator.getOrderByFields().length * 6));
849                    }
850                    else {
851                            query = new StringBundler(3);
852                    }
853    
854                    query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
855    
856                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
857    
858                    if (orderByComparator != null) {
859                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
860    
861                            if (orderByConditionFields.length > 0) {
862                                    query.append(WHERE_AND);
863                            }
864    
865                            for (int i = 0; i < orderByConditionFields.length; i++) {
866                                    query.append(_ORDER_BY_ENTITY_ALIAS);
867                                    query.append(orderByConditionFields[i]);
868    
869                                    if ((i + 1) < orderByConditionFields.length) {
870                                            if (orderByComparator.isAscending() ^ previous) {
871                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
872                                            }
873                                            else {
874                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
875                                            }
876                                    }
877                                    else {
878                                            if (orderByComparator.isAscending() ^ previous) {
879                                                    query.append(WHERE_GREATER_THAN);
880                                            }
881                                            else {
882                                                    query.append(WHERE_LESSER_THAN);
883                                            }
884                                    }
885                            }
886    
887                            query.append(ORDER_BY_CLAUSE);
888    
889                            String[] orderByFields = orderByComparator.getOrderByFields();
890    
891                            for (int i = 0; i < orderByFields.length; i++) {
892                                    query.append(_ORDER_BY_ENTITY_ALIAS);
893                                    query.append(orderByFields[i]);
894    
895                                    if ((i + 1) < orderByFields.length) {
896                                            if (orderByComparator.isAscending() ^ previous) {
897                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
898                                            }
899                                            else {
900                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
901                                            }
902                                    }
903                                    else {
904                                            if (orderByComparator.isAscending() ^ previous) {
905                                                    query.append(ORDER_BY_ASC);
906                                            }
907                                            else {
908                                                    query.append(ORDER_BY_DESC);
909                                            }
910                                    }
911                            }
912                    }
913    
914                    else {
915                            query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
916                    }
917    
918                    String sql = query.toString();
919    
920                    Query q = session.createQuery(sql);
921    
922                    q.setFirstResult(0);
923                    q.setMaxResults(2);
924    
925                    QueryPos qPos = QueryPos.getInstance(q);
926    
927                    qPos.add(groupId);
928    
929                    if (orderByComparator != null) {
930                            Object[] values = orderByComparator.getOrderByConditionValues(mbStatsUser);
931    
932                            for (Object value : values) {
933                                    qPos.add(value);
934                            }
935                    }
936    
937                    List<MBStatsUser> list = q.list();
938    
939                    if (list.size() == 2) {
940                            return list.get(1);
941                    }
942                    else {
943                            return null;
944                    }
945            }
946    
947            /**
948             * Returns all the message boards stats users where userId = &#63;.
949             *
950             * @param userId the user ID
951             * @return the matching message boards stats users
952             * @throws SystemException if a system exception occurred
953             */
954            public List<MBStatsUser> findByUserId(long userId)
955                    throws SystemException {
956                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
957            }
958    
959            /**
960             * Returns a range of all the message boards stats users where userId = &#63;.
961             *
962             * <p>
963             * 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.
964             * </p>
965             *
966             * @param userId the user ID
967             * @param start the lower bound of the range of message boards stats users
968             * @param end the upper bound of the range of message boards stats users (not inclusive)
969             * @return the range of matching message boards stats users
970             * @throws SystemException if a system exception occurred
971             */
972            public List<MBStatsUser> findByUserId(long userId, int start, int end)
973                    throws SystemException {
974                    return findByUserId(userId, start, end, null);
975            }
976    
977            /**
978             * Returns an ordered range of all the message boards stats users where userId = &#63;.
979             *
980             * <p>
981             * 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.
982             * </p>
983             *
984             * @param userId the user ID
985             * @param start the lower bound of the range of message boards stats users
986             * @param end the upper bound of the range of message boards stats users (not inclusive)
987             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
988             * @return the ordered range of matching message boards stats users
989             * @throws SystemException if a system exception occurred
990             */
991            public List<MBStatsUser> findByUserId(long userId, int start, int end,
992                    OrderByComparator orderByComparator) throws SystemException {
993                    FinderPath finderPath = null;
994                    Object[] finderArgs = null;
995    
996                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
997                                    (orderByComparator == null)) {
998                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
999                            finderArgs = new Object[] { userId };
1000                    }
1001                    else {
1002                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1003                            finderArgs = new Object[] { userId, start, end, orderByComparator };
1004                    }
1005    
1006                    List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(finderPath,
1007                                    finderArgs, this);
1008    
1009                    if ((list != null) && !list.isEmpty()) {
1010                            for (MBStatsUser mbStatsUser : list) {
1011                                    if ((userId != mbStatsUser.getUserId())) {
1012                                            list = null;
1013    
1014                                            break;
1015                                    }
1016                            }
1017                    }
1018    
1019                    if (list == null) {
1020                            StringBundler query = null;
1021    
1022                            if (orderByComparator != null) {
1023                                    query = new StringBundler(3 +
1024                                                    (orderByComparator.getOrderByFields().length * 3));
1025                            }
1026                            else {
1027                                    query = new StringBundler(3);
1028                            }
1029    
1030                            query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
1031    
1032                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1033    
1034                            if (orderByComparator != null) {
1035                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1036                                            orderByComparator);
1037                            }
1038    
1039                            else {
1040                                    query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
1041                            }
1042    
1043                            String sql = query.toString();
1044    
1045                            Session session = null;
1046    
1047                            try {
1048                                    session = openSession();
1049    
1050                                    Query q = session.createQuery(sql);
1051    
1052                                    QueryPos qPos = QueryPos.getInstance(q);
1053    
1054                                    qPos.add(userId);
1055    
1056                                    list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
1057                                                    start, end);
1058                            }
1059                            catch (Exception e) {
1060                                    throw processException(e);
1061                            }
1062                            finally {
1063                                    if (list == null) {
1064                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1065                                    }
1066                                    else {
1067                                            cacheResult(list);
1068    
1069                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1070                                    }
1071    
1072                                    closeSession(session);
1073                            }
1074                    }
1075    
1076                    return list;
1077            }
1078    
1079            /**
1080             * Returns the first message boards stats user in the ordered set where userId = &#63;.
1081             *
1082             * @param userId the user ID
1083             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1084             * @return the first matching message boards stats user
1085             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a matching message boards stats user could not be found
1086             * @throws SystemException if a system exception occurred
1087             */
1088            public MBStatsUser findByUserId_First(long userId,
1089                    OrderByComparator orderByComparator)
1090                    throws NoSuchStatsUserException, SystemException {
1091                    MBStatsUser mbStatsUser = fetchByUserId_First(userId, orderByComparator);
1092    
1093                    if (mbStatsUser != null) {
1094                            return mbStatsUser;
1095                    }
1096    
1097                    StringBundler msg = new StringBundler(4);
1098    
1099                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1100    
1101                    msg.append("userId=");
1102                    msg.append(userId);
1103    
1104                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1105    
1106                    throw new NoSuchStatsUserException(msg.toString());
1107            }
1108    
1109            /**
1110             * Returns the first message boards stats user in the ordered set where userId = &#63;.
1111             *
1112             * @param userId the user ID
1113             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1114             * @return the first matching message boards stats user, or <code>null</code> if a matching message boards stats user could not be found
1115             * @throws SystemException if a system exception occurred
1116             */
1117            public MBStatsUser fetchByUserId_First(long userId,
1118                    OrderByComparator orderByComparator) throws SystemException {
1119                    List<MBStatsUser> list = findByUserId(userId, 0, 1, orderByComparator);
1120    
1121                    if (!list.isEmpty()) {
1122                            return list.get(0);
1123                    }
1124    
1125                    return null;
1126            }
1127    
1128            /**
1129             * Returns the last message boards stats user in the ordered set where userId = &#63;.
1130             *
1131             * @param userId the user ID
1132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1133             * @return the last matching message boards stats user
1134             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a matching message boards stats user could not be found
1135             * @throws SystemException if a system exception occurred
1136             */
1137            public MBStatsUser findByUserId_Last(long userId,
1138                    OrderByComparator orderByComparator)
1139                    throws NoSuchStatsUserException, SystemException {
1140                    MBStatsUser mbStatsUser = fetchByUserId_Last(userId, orderByComparator);
1141    
1142                    if (mbStatsUser != null) {
1143                            return mbStatsUser;
1144                    }
1145    
1146                    StringBundler msg = new StringBundler(4);
1147    
1148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1149    
1150                    msg.append("userId=");
1151                    msg.append(userId);
1152    
1153                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1154    
1155                    throw new NoSuchStatsUserException(msg.toString());
1156            }
1157    
1158            /**
1159             * Returns the last message boards stats user in the ordered set where userId = &#63;.
1160             *
1161             * @param userId the user ID
1162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1163             * @return the last matching message boards stats user, or <code>null</code> if a matching message boards stats user could not be found
1164             * @throws SystemException if a system exception occurred
1165             */
1166            public MBStatsUser fetchByUserId_Last(long userId,
1167                    OrderByComparator orderByComparator) throws SystemException {
1168                    int count = countByUserId(userId);
1169    
1170                    List<MBStatsUser> list = findByUserId(userId, count - 1, count,
1171                                    orderByComparator);
1172    
1173                    if (!list.isEmpty()) {
1174                            return list.get(0);
1175                    }
1176    
1177                    return null;
1178            }
1179    
1180            /**
1181             * Returns the message boards stats users before and after the current message boards stats user in the ordered set where userId = &#63;.
1182             *
1183             * @param statsUserId the primary key of the current message boards stats user
1184             * @param userId the user ID
1185             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1186             * @return the previous, current, and next message boards stats user
1187             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a message boards stats user with the primary key could not be found
1188             * @throws SystemException if a system exception occurred
1189             */
1190            public MBStatsUser[] findByUserId_PrevAndNext(long statsUserId,
1191                    long userId, OrderByComparator orderByComparator)
1192                    throws NoSuchStatsUserException, SystemException {
1193                    MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
1194    
1195                    Session session = null;
1196    
1197                    try {
1198                            session = openSession();
1199    
1200                            MBStatsUser[] array = new MBStatsUserImpl[3];
1201    
1202                            array[0] = getByUserId_PrevAndNext(session, mbStatsUser, userId,
1203                                            orderByComparator, true);
1204    
1205                            array[1] = mbStatsUser;
1206    
1207                            array[2] = getByUserId_PrevAndNext(session, mbStatsUser, userId,
1208                                            orderByComparator, false);
1209    
1210                            return array;
1211                    }
1212                    catch (Exception e) {
1213                            throw processException(e);
1214                    }
1215                    finally {
1216                            closeSession(session);
1217                    }
1218            }
1219    
1220            protected MBStatsUser getByUserId_PrevAndNext(Session session,
1221                    MBStatsUser mbStatsUser, long userId,
1222                    OrderByComparator orderByComparator, boolean previous) {
1223                    StringBundler query = null;
1224    
1225                    if (orderByComparator != null) {
1226                            query = new StringBundler(6 +
1227                                            (orderByComparator.getOrderByFields().length * 6));
1228                    }
1229                    else {
1230                            query = new StringBundler(3);
1231                    }
1232    
1233                    query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
1234    
1235                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1236    
1237                    if (orderByComparator != null) {
1238                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1239    
1240                            if (orderByConditionFields.length > 0) {
1241                                    query.append(WHERE_AND);
1242                            }
1243    
1244                            for (int i = 0; i < orderByConditionFields.length; i++) {
1245                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1246                                    query.append(orderByConditionFields[i]);
1247    
1248                                    if ((i + 1) < orderByConditionFields.length) {
1249                                            if (orderByComparator.isAscending() ^ previous) {
1250                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1251                                            }
1252                                            else {
1253                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1254                                            }
1255                                    }
1256                                    else {
1257                                            if (orderByComparator.isAscending() ^ previous) {
1258                                                    query.append(WHERE_GREATER_THAN);
1259                                            }
1260                                            else {
1261                                                    query.append(WHERE_LESSER_THAN);
1262                                            }
1263                                    }
1264                            }
1265    
1266                            query.append(ORDER_BY_CLAUSE);
1267    
1268                            String[] orderByFields = orderByComparator.getOrderByFields();
1269    
1270                            for (int i = 0; i < orderByFields.length; i++) {
1271                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1272                                    query.append(orderByFields[i]);
1273    
1274                                    if ((i + 1) < orderByFields.length) {
1275                                            if (orderByComparator.isAscending() ^ previous) {
1276                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1277                                            }
1278                                            else {
1279                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1280                                            }
1281                                    }
1282                                    else {
1283                                            if (orderByComparator.isAscending() ^ previous) {
1284                                                    query.append(ORDER_BY_ASC);
1285                                            }
1286                                            else {
1287                                                    query.append(ORDER_BY_DESC);
1288                                            }
1289                                    }
1290                            }
1291                    }
1292    
1293                    else {
1294                            query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
1295                    }
1296    
1297                    String sql = query.toString();
1298    
1299                    Query q = session.createQuery(sql);
1300    
1301                    q.setFirstResult(0);
1302                    q.setMaxResults(2);
1303    
1304                    QueryPos qPos = QueryPos.getInstance(q);
1305    
1306                    qPos.add(userId);
1307    
1308                    if (orderByComparator != null) {
1309                            Object[] values = orderByComparator.getOrderByConditionValues(mbStatsUser);
1310    
1311                            for (Object value : values) {
1312                                    qPos.add(value);
1313                            }
1314                    }
1315    
1316                    List<MBStatsUser> list = q.list();
1317    
1318                    if (list.size() == 2) {
1319                            return list.get(1);
1320                    }
1321                    else {
1322                            return null;
1323                    }
1324            }
1325    
1326            /**
1327             * Returns the message boards stats user where groupId = &#63; and userId = &#63; or throws a {@link com.liferay.portlet.messageboards.NoSuchStatsUserException} if it could not be found.
1328             *
1329             * @param groupId the group ID
1330             * @param userId the user ID
1331             * @return the matching message boards stats user
1332             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a matching message boards stats user could not be found
1333             * @throws SystemException if a system exception occurred
1334             */
1335            public MBStatsUser findByG_U(long groupId, long userId)
1336                    throws NoSuchStatsUserException, SystemException {
1337                    MBStatsUser mbStatsUser = fetchByG_U(groupId, userId);
1338    
1339                    if (mbStatsUser == null) {
1340                            StringBundler msg = new StringBundler(6);
1341    
1342                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1343    
1344                            msg.append("groupId=");
1345                            msg.append(groupId);
1346    
1347                            msg.append(", userId=");
1348                            msg.append(userId);
1349    
1350                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1351    
1352                            if (_log.isWarnEnabled()) {
1353                                    _log.warn(msg.toString());
1354                            }
1355    
1356                            throw new NoSuchStatsUserException(msg.toString());
1357                    }
1358    
1359                    return mbStatsUser;
1360            }
1361    
1362            /**
1363             * Returns the message boards stats user where groupId = &#63; and userId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1364             *
1365             * @param groupId the group ID
1366             * @param userId the user ID
1367             * @return the matching message boards stats user, or <code>null</code> if a matching message boards stats user could not be found
1368             * @throws SystemException if a system exception occurred
1369             */
1370            public MBStatsUser fetchByG_U(long groupId, long userId)
1371                    throws SystemException {
1372                    return fetchByG_U(groupId, userId, true);
1373            }
1374    
1375            /**
1376             * Returns the message boards stats user where groupId = &#63; and userId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1377             *
1378             * @param groupId the group ID
1379             * @param userId the user ID
1380             * @param retrieveFromCache whether to use the finder cache
1381             * @return the matching message boards stats user, or <code>null</code> if a matching message boards stats user could not be found
1382             * @throws SystemException if a system exception occurred
1383             */
1384            public MBStatsUser fetchByG_U(long groupId, long userId,
1385                    boolean retrieveFromCache) throws SystemException {
1386                    Object[] finderArgs = new Object[] { groupId, userId };
1387    
1388                    Object result = null;
1389    
1390                    if (retrieveFromCache) {
1391                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_U,
1392                                            finderArgs, this);
1393                    }
1394    
1395                    if (result instanceof MBStatsUser) {
1396                            MBStatsUser mbStatsUser = (MBStatsUser)result;
1397    
1398                            if ((groupId != mbStatsUser.getGroupId()) ||
1399                                            (userId != mbStatsUser.getUserId())) {
1400                                    result = null;
1401                            }
1402                    }
1403    
1404                    if (result == null) {
1405                            StringBundler query = new StringBundler(4);
1406    
1407                            query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
1408    
1409                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1410    
1411                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1412    
1413                            query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
1414    
1415                            String sql = query.toString();
1416    
1417                            Session session = null;
1418    
1419                            try {
1420                                    session = openSession();
1421    
1422                                    Query q = session.createQuery(sql);
1423    
1424                                    QueryPos qPos = QueryPos.getInstance(q);
1425    
1426                                    qPos.add(groupId);
1427    
1428                                    qPos.add(userId);
1429    
1430                                    List<MBStatsUser> list = q.list();
1431    
1432                                    result = list;
1433    
1434                                    MBStatsUser mbStatsUser = null;
1435    
1436                                    if (list.isEmpty()) {
1437                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1438                                                    finderArgs, list);
1439                                    }
1440                                    else {
1441                                            mbStatsUser = list.get(0);
1442    
1443                                            cacheResult(mbStatsUser);
1444    
1445                                            if ((mbStatsUser.getGroupId() != groupId) ||
1446                                                            (mbStatsUser.getUserId() != userId)) {
1447                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1448                                                            finderArgs, mbStatsUser);
1449                                            }
1450                                    }
1451    
1452                                    return mbStatsUser;
1453                            }
1454                            catch (Exception e) {
1455                                    throw processException(e);
1456                            }
1457                            finally {
1458                                    if (result == null) {
1459                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
1460                                                    finderArgs);
1461                                    }
1462    
1463                                    closeSession(session);
1464                            }
1465                    }
1466                    else {
1467                            if (result instanceof List<?>) {
1468                                    return null;
1469                            }
1470                            else {
1471                                    return (MBStatsUser)result;
1472                            }
1473                    }
1474            }
1475    
1476            /**
1477             * Returns all the message boards stats users where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
1478             *
1479             * @param groupId the group ID
1480             * @param userId the user ID
1481             * @param messageCount the message count
1482             * @return the matching message boards stats users
1483             * @throws SystemException if a system exception occurred
1484             */
1485            public List<MBStatsUser> findByG_NotU_NotM(long groupId, long userId,
1486                    int messageCount) throws SystemException {
1487                    return findByG_NotU_NotM(groupId, userId, messageCount,
1488                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1489            }
1490    
1491            /**
1492             * Returns a range of all the message boards stats users where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
1493             *
1494             * <p>
1495             * 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.
1496             * </p>
1497             *
1498             * @param groupId the group ID
1499             * @param userId the user ID
1500             * @param messageCount the message count
1501             * @param start the lower bound of the range of message boards stats users
1502             * @param end the upper bound of the range of message boards stats users (not inclusive)
1503             * @return the range of matching message boards stats users
1504             * @throws SystemException if a system exception occurred
1505             */
1506            public List<MBStatsUser> findByG_NotU_NotM(long groupId, long userId,
1507                    int messageCount, int start, int end) throws SystemException {
1508                    return findByG_NotU_NotM(groupId, userId, messageCount, start, end, null);
1509            }
1510    
1511            /**
1512             * Returns an ordered range of all the message boards stats users where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
1513             *
1514             * <p>
1515             * 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.
1516             * </p>
1517             *
1518             * @param groupId the group ID
1519             * @param userId the user ID
1520             * @param messageCount the message count
1521             * @param start the lower bound of the range of message boards stats users
1522             * @param end the upper bound of the range of message boards stats users (not inclusive)
1523             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1524             * @return the ordered range of matching message boards stats users
1525             * @throws SystemException if a system exception occurred
1526             */
1527            public List<MBStatsUser> findByG_NotU_NotM(long groupId, long userId,
1528                    int messageCount, int start, int end,
1529                    OrderByComparator orderByComparator) throws SystemException {
1530                    FinderPath finderPath = null;
1531                    Object[] finderArgs = null;
1532    
1533                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTU_NOTM;
1534                    finderArgs = new Object[] {
1535                                    groupId, userId, messageCount,
1536                                    
1537                                    start, end, orderByComparator
1538                            };
1539    
1540                    List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(finderPath,
1541                                    finderArgs, this);
1542    
1543                    if ((list != null) && !list.isEmpty()) {
1544                            for (MBStatsUser mbStatsUser : list) {
1545                                    if ((groupId != mbStatsUser.getGroupId()) ||
1546                                                    (userId != mbStatsUser.getUserId()) ||
1547                                                    (messageCount != mbStatsUser.getMessageCount())) {
1548                                            list = null;
1549    
1550                                            break;
1551                                    }
1552                            }
1553                    }
1554    
1555                    if (list == null) {
1556                            StringBundler query = null;
1557    
1558                            if (orderByComparator != null) {
1559                                    query = new StringBundler(5 +
1560                                                    (orderByComparator.getOrderByFields().length * 3));
1561                            }
1562                            else {
1563                                    query = new StringBundler(5);
1564                            }
1565    
1566                            query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
1567    
1568                            query.append(_FINDER_COLUMN_G_NOTU_NOTM_GROUPID_2);
1569    
1570                            query.append(_FINDER_COLUMN_G_NOTU_NOTM_USERID_2);
1571    
1572                            query.append(_FINDER_COLUMN_G_NOTU_NOTM_MESSAGECOUNT_2);
1573    
1574                            if (orderByComparator != null) {
1575                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1576                                            orderByComparator);
1577                            }
1578    
1579                            else {
1580                                    query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
1581                            }
1582    
1583                            String sql = query.toString();
1584    
1585                            Session session = null;
1586    
1587                            try {
1588                                    session = openSession();
1589    
1590                                    Query q = session.createQuery(sql);
1591    
1592                                    QueryPos qPos = QueryPos.getInstance(q);
1593    
1594                                    qPos.add(groupId);
1595    
1596                                    qPos.add(userId);
1597    
1598                                    qPos.add(messageCount);
1599    
1600                                    list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
1601                                                    start, end);
1602                            }
1603                            catch (Exception e) {
1604                                    throw processException(e);
1605                            }
1606                            finally {
1607                                    if (list == null) {
1608                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1609                                    }
1610                                    else {
1611                                            cacheResult(list);
1612    
1613                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1614                                    }
1615    
1616                                    closeSession(session);
1617                            }
1618                    }
1619    
1620                    return list;
1621            }
1622    
1623            /**
1624             * Returns the first message boards stats user in the ordered set where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
1625             *
1626             * @param groupId the group ID
1627             * @param userId the user ID
1628             * @param messageCount the message count
1629             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1630             * @return the first matching message boards stats user
1631             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a matching message boards stats user could not be found
1632             * @throws SystemException if a system exception occurred
1633             */
1634            public MBStatsUser findByG_NotU_NotM_First(long groupId, long userId,
1635                    int messageCount, OrderByComparator orderByComparator)
1636                    throws NoSuchStatsUserException, SystemException {
1637                    MBStatsUser mbStatsUser = fetchByG_NotU_NotM_First(groupId, userId,
1638                                    messageCount, orderByComparator);
1639    
1640                    if (mbStatsUser != null) {
1641                            return mbStatsUser;
1642                    }
1643    
1644                    StringBundler msg = new StringBundler(8);
1645    
1646                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1647    
1648                    msg.append("groupId=");
1649                    msg.append(groupId);
1650    
1651                    msg.append(", userId=");
1652                    msg.append(userId);
1653    
1654                    msg.append(", messageCount=");
1655                    msg.append(messageCount);
1656    
1657                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1658    
1659                    throw new NoSuchStatsUserException(msg.toString());
1660            }
1661    
1662            /**
1663             * Returns the first message boards stats user in the ordered set where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
1664             *
1665             * @param groupId the group ID
1666             * @param userId the user ID
1667             * @param messageCount the message count
1668             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1669             * @return the first matching message boards stats user, or <code>null</code> if a matching message boards stats user could not be found
1670             * @throws SystemException if a system exception occurred
1671             */
1672            public MBStatsUser fetchByG_NotU_NotM_First(long groupId, long userId,
1673                    int messageCount, OrderByComparator orderByComparator)
1674                    throws SystemException {
1675                    List<MBStatsUser> list = findByG_NotU_NotM(groupId, userId,
1676                                    messageCount, 0, 1, orderByComparator);
1677    
1678                    if (!list.isEmpty()) {
1679                            return list.get(0);
1680                    }
1681    
1682                    return null;
1683            }
1684    
1685            /**
1686             * Returns the last message boards stats user in the ordered set where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
1687             *
1688             * @param groupId the group ID
1689             * @param userId the user ID
1690             * @param messageCount the message count
1691             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1692             * @return the last matching message boards stats user
1693             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a matching message boards stats user could not be found
1694             * @throws SystemException if a system exception occurred
1695             */
1696            public MBStatsUser findByG_NotU_NotM_Last(long groupId, long userId,
1697                    int messageCount, OrderByComparator orderByComparator)
1698                    throws NoSuchStatsUserException, SystemException {
1699                    MBStatsUser mbStatsUser = fetchByG_NotU_NotM_Last(groupId, userId,
1700                                    messageCount, orderByComparator);
1701    
1702                    if (mbStatsUser != null) {
1703                            return mbStatsUser;
1704                    }
1705    
1706                    StringBundler msg = new StringBundler(8);
1707    
1708                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1709    
1710                    msg.append("groupId=");
1711                    msg.append(groupId);
1712    
1713                    msg.append(", userId=");
1714                    msg.append(userId);
1715    
1716                    msg.append(", messageCount=");
1717                    msg.append(messageCount);
1718    
1719                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1720    
1721                    throw new NoSuchStatsUserException(msg.toString());
1722            }
1723    
1724            /**
1725             * Returns the last message boards stats user in the ordered set where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
1726             *
1727             * @param groupId the group ID
1728             * @param userId the user ID
1729             * @param messageCount the message count
1730             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1731             * @return the last matching message boards stats user, or <code>null</code> if a matching message boards stats user could not be found
1732             * @throws SystemException if a system exception occurred
1733             */
1734            public MBStatsUser fetchByG_NotU_NotM_Last(long groupId, long userId,
1735                    int messageCount, OrderByComparator orderByComparator)
1736                    throws SystemException {
1737                    int count = countByG_NotU_NotM(groupId, userId, messageCount);
1738    
1739                    List<MBStatsUser> list = findByG_NotU_NotM(groupId, userId,
1740                                    messageCount, count - 1, count, orderByComparator);
1741    
1742                    if (!list.isEmpty()) {
1743                            return list.get(0);
1744                    }
1745    
1746                    return null;
1747            }
1748    
1749            /**
1750             * Returns the message boards stats users before and after the current message boards stats user in the ordered set where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
1751             *
1752             * @param statsUserId the primary key of the current message boards stats user
1753             * @param groupId the group ID
1754             * @param userId the user ID
1755             * @param messageCount the message count
1756             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1757             * @return the previous, current, and next message boards stats user
1758             * @throws com.liferay.portlet.messageboards.NoSuchStatsUserException if a message boards stats user with the primary key could not be found
1759             * @throws SystemException if a system exception occurred
1760             */
1761            public MBStatsUser[] findByG_NotU_NotM_PrevAndNext(long statsUserId,
1762                    long groupId, long userId, int messageCount,
1763                    OrderByComparator orderByComparator)
1764                    throws NoSuchStatsUserException, SystemException {
1765                    MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
1766    
1767                    Session session = null;
1768    
1769                    try {
1770                            session = openSession();
1771    
1772                            MBStatsUser[] array = new MBStatsUserImpl[3];
1773    
1774                            array[0] = getByG_NotU_NotM_PrevAndNext(session, mbStatsUser,
1775                                            groupId, userId, messageCount, orderByComparator, true);
1776    
1777                            array[1] = mbStatsUser;
1778    
1779                            array[2] = getByG_NotU_NotM_PrevAndNext(session, mbStatsUser,
1780                                            groupId, userId, messageCount, orderByComparator, false);
1781    
1782                            return array;
1783                    }
1784                    catch (Exception e) {
1785                            throw processException(e);
1786                    }
1787                    finally {
1788                            closeSession(session);
1789                    }
1790            }
1791    
1792            protected MBStatsUser getByG_NotU_NotM_PrevAndNext(Session session,
1793                    MBStatsUser mbStatsUser, long groupId, long userId, int messageCount,
1794                    OrderByComparator orderByComparator, boolean previous) {
1795                    StringBundler query = null;
1796    
1797                    if (orderByComparator != null) {
1798                            query = new StringBundler(6 +
1799                                            (orderByComparator.getOrderByFields().length * 6));
1800                    }
1801                    else {
1802                            query = new StringBundler(3);
1803                    }
1804    
1805                    query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
1806    
1807                    query.append(_FINDER_COLUMN_G_NOTU_NOTM_GROUPID_2);
1808    
1809                    query.append(_FINDER_COLUMN_G_NOTU_NOTM_USERID_2);
1810    
1811                    query.append(_FINDER_COLUMN_G_NOTU_NOTM_MESSAGECOUNT_2);
1812    
1813                    if (orderByComparator != null) {
1814                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1815    
1816                            if (orderByConditionFields.length > 0) {
1817                                    query.append(WHERE_AND);
1818                            }
1819    
1820                            for (int i = 0; i < orderByConditionFields.length; i++) {
1821                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1822                                    query.append(orderByConditionFields[i]);
1823    
1824                                    if ((i + 1) < orderByConditionFields.length) {
1825                                            if (orderByComparator.isAscending() ^ previous) {
1826                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1827                                            }
1828                                            else {
1829                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1830                                            }
1831                                    }
1832                                    else {
1833                                            if (orderByComparator.isAscending() ^ previous) {
1834                                                    query.append(WHERE_GREATER_THAN);
1835                                            }
1836                                            else {
1837                                                    query.append(WHERE_LESSER_THAN);
1838                                            }
1839                                    }
1840                            }
1841    
1842                            query.append(ORDER_BY_CLAUSE);
1843    
1844                            String[] orderByFields = orderByComparator.getOrderByFields();
1845    
1846                            for (int i = 0; i < orderByFields.length; i++) {
1847                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1848                                    query.append(orderByFields[i]);
1849    
1850                                    if ((i + 1) < orderByFields.length) {
1851                                            if (orderByComparator.isAscending() ^ previous) {
1852                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1853                                            }
1854                                            else {
1855                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1856                                            }
1857                                    }
1858                                    else {
1859                                            if (orderByComparator.isAscending() ^ previous) {
1860                                                    query.append(ORDER_BY_ASC);
1861                                            }
1862                                            else {
1863                                                    query.append(ORDER_BY_DESC);
1864                                            }
1865                                    }
1866                            }
1867                    }
1868    
1869                    else {
1870                            query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
1871                    }
1872    
1873                    String sql = query.toString();
1874    
1875                    Query q = session.createQuery(sql);
1876    
1877                    q.setFirstResult(0);
1878                    q.setMaxResults(2);
1879    
1880                    QueryPos qPos = QueryPos.getInstance(q);
1881    
1882                    qPos.add(groupId);
1883    
1884                    qPos.add(userId);
1885    
1886                    qPos.add(messageCount);
1887    
1888                    if (orderByComparator != null) {
1889                            Object[] values = orderByComparator.getOrderByConditionValues(mbStatsUser);
1890    
1891                            for (Object value : values) {
1892                                    qPos.add(value);
1893                            }
1894                    }
1895    
1896                    List<MBStatsUser> list = q.list();
1897    
1898                    if (list.size() == 2) {
1899                            return list.get(1);
1900                    }
1901                    else {
1902                            return null;
1903                    }
1904            }
1905    
1906            /**
1907             * Returns all the message boards stats users.
1908             *
1909             * @return the message boards stats users
1910             * @throws SystemException if a system exception occurred
1911             */
1912            public List<MBStatsUser> findAll() throws SystemException {
1913                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1914            }
1915    
1916            /**
1917             * Returns a range of all the message boards stats users.
1918             *
1919             * <p>
1920             * 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.
1921             * </p>
1922             *
1923             * @param start the lower bound of the range of message boards stats users
1924             * @param end the upper bound of the range of message boards stats users (not inclusive)
1925             * @return the range of message boards stats users
1926             * @throws SystemException if a system exception occurred
1927             */
1928            public List<MBStatsUser> findAll(int start, int end)
1929                    throws SystemException {
1930                    return findAll(start, end, null);
1931            }
1932    
1933            /**
1934             * Returns an ordered range of all the message boards stats users.
1935             *
1936             * <p>
1937             * 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.
1938             * </p>
1939             *
1940             * @param start the lower bound of the range of message boards stats users
1941             * @param end the upper bound of the range of message boards stats users (not inclusive)
1942             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1943             * @return the ordered range of message boards stats users
1944             * @throws SystemException if a system exception occurred
1945             */
1946            public List<MBStatsUser> findAll(int start, int end,
1947                    OrderByComparator orderByComparator) throws SystemException {
1948                    FinderPath finderPath = null;
1949                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1950    
1951                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1952                                    (orderByComparator == null)) {
1953                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1954                            finderArgs = FINDER_ARGS_EMPTY;
1955                    }
1956                    else {
1957                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1958                            finderArgs = new Object[] { start, end, orderByComparator };
1959                    }
1960    
1961                    List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(finderPath,
1962                                    finderArgs, this);
1963    
1964                    if (list == null) {
1965                            StringBundler query = null;
1966                            String sql = null;
1967    
1968                            if (orderByComparator != null) {
1969                                    query = new StringBundler(2 +
1970                                                    (orderByComparator.getOrderByFields().length * 3));
1971    
1972                                    query.append(_SQL_SELECT_MBSTATSUSER);
1973    
1974                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1975                                            orderByComparator);
1976    
1977                                    sql = query.toString();
1978                            }
1979                            else {
1980                                    sql = _SQL_SELECT_MBSTATSUSER.concat(MBStatsUserModelImpl.ORDER_BY_JPQL);
1981                            }
1982    
1983                            Session session = null;
1984    
1985                            try {
1986                                    session = openSession();
1987    
1988                                    Query q = session.createQuery(sql);
1989    
1990                                    if (orderByComparator == null) {
1991                                            list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
1992                                                            start, end, false);
1993    
1994                                            Collections.sort(list);
1995                                    }
1996                                    else {
1997                                            list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
1998                                                            start, end);
1999                                    }
2000                            }
2001                            catch (Exception e) {
2002                                    throw processException(e);
2003                            }
2004                            finally {
2005                                    if (list == null) {
2006                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2007                                    }
2008                                    else {
2009                                            cacheResult(list);
2010    
2011                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2012                                    }
2013    
2014                                    closeSession(session);
2015                            }
2016                    }
2017    
2018                    return list;
2019            }
2020    
2021            /**
2022             * Removes all the message boards stats users where groupId = &#63; from the database.
2023             *
2024             * @param groupId the group ID
2025             * @throws SystemException if a system exception occurred
2026             */
2027            public void removeByGroupId(long groupId) throws SystemException {
2028                    for (MBStatsUser mbStatsUser : findByGroupId(groupId)) {
2029                            remove(mbStatsUser);
2030                    }
2031            }
2032    
2033            /**
2034             * Removes all the message boards stats users where userId = &#63; from the database.
2035             *
2036             * @param userId the user ID
2037             * @throws SystemException if a system exception occurred
2038             */
2039            public void removeByUserId(long userId) throws SystemException {
2040                    for (MBStatsUser mbStatsUser : findByUserId(userId)) {
2041                            remove(mbStatsUser);
2042                    }
2043            }
2044    
2045            /**
2046             * Removes the message boards stats user where groupId = &#63; and userId = &#63; from the database.
2047             *
2048             * @param groupId the group ID
2049             * @param userId the user ID
2050             * @return the message boards stats user that was removed
2051             * @throws SystemException if a system exception occurred
2052             */
2053            public MBStatsUser removeByG_U(long groupId, long userId)
2054                    throws NoSuchStatsUserException, SystemException {
2055                    MBStatsUser mbStatsUser = findByG_U(groupId, userId);
2056    
2057                    return remove(mbStatsUser);
2058            }
2059    
2060            /**
2061             * Removes all the message boards stats users where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63; from the database.
2062             *
2063             * @param groupId the group ID
2064             * @param userId the user ID
2065             * @param messageCount the message count
2066             * @throws SystemException if a system exception occurred
2067             */
2068            public void removeByG_NotU_NotM(long groupId, long userId, int messageCount)
2069                    throws SystemException {
2070                    for (MBStatsUser mbStatsUser : findByG_NotU_NotM(groupId, userId,
2071                                    messageCount)) {
2072                            remove(mbStatsUser);
2073                    }
2074            }
2075    
2076            /**
2077             * Removes all the message boards stats users from the database.
2078             *
2079             * @throws SystemException if a system exception occurred
2080             */
2081            public void removeAll() throws SystemException {
2082                    for (MBStatsUser mbStatsUser : findAll()) {
2083                            remove(mbStatsUser);
2084                    }
2085            }
2086    
2087            /**
2088             * Returns the number of message boards stats users where groupId = &#63;.
2089             *
2090             * @param groupId the group ID
2091             * @return the number of matching message boards stats users
2092             * @throws SystemException if a system exception occurred
2093             */
2094            public int countByGroupId(long groupId) throws SystemException {
2095                    Object[] finderArgs = new Object[] { groupId };
2096    
2097                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2098                                    finderArgs, this);
2099    
2100                    if (count == null) {
2101                            StringBundler query = new StringBundler(2);
2102    
2103                            query.append(_SQL_COUNT_MBSTATSUSER_WHERE);
2104    
2105                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2106    
2107                            String sql = query.toString();
2108    
2109                            Session session = null;
2110    
2111                            try {
2112                                    session = openSession();
2113    
2114                                    Query q = session.createQuery(sql);
2115    
2116                                    QueryPos qPos = QueryPos.getInstance(q);
2117    
2118                                    qPos.add(groupId);
2119    
2120                                    count = (Long)q.uniqueResult();
2121                            }
2122                            catch (Exception e) {
2123                                    throw processException(e);
2124                            }
2125                            finally {
2126                                    if (count == null) {
2127                                            count = Long.valueOf(0);
2128                                    }
2129    
2130                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2131                                            finderArgs, count);
2132    
2133                                    closeSession(session);
2134                            }
2135                    }
2136    
2137                    return count.intValue();
2138            }
2139    
2140            /**
2141             * Returns the number of message boards stats users where userId = &#63;.
2142             *
2143             * @param userId the user ID
2144             * @return the number of matching message boards stats users
2145             * @throws SystemException if a system exception occurred
2146             */
2147            public int countByUserId(long userId) throws SystemException {
2148                    Object[] finderArgs = new Object[] { userId };
2149    
2150                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2151                                    finderArgs, this);
2152    
2153                    if (count == null) {
2154                            StringBundler query = new StringBundler(2);
2155    
2156                            query.append(_SQL_COUNT_MBSTATSUSER_WHERE);
2157    
2158                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2159    
2160                            String sql = query.toString();
2161    
2162                            Session session = null;
2163    
2164                            try {
2165                                    session = openSession();
2166    
2167                                    Query q = session.createQuery(sql);
2168    
2169                                    QueryPos qPos = QueryPos.getInstance(q);
2170    
2171                                    qPos.add(userId);
2172    
2173                                    count = (Long)q.uniqueResult();
2174                            }
2175                            catch (Exception e) {
2176                                    throw processException(e);
2177                            }
2178                            finally {
2179                                    if (count == null) {
2180                                            count = Long.valueOf(0);
2181                                    }
2182    
2183                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2184                                            finderArgs, count);
2185    
2186                                    closeSession(session);
2187                            }
2188                    }
2189    
2190                    return count.intValue();
2191            }
2192    
2193            /**
2194             * Returns the number of message boards stats users where groupId = &#63; and userId = &#63;.
2195             *
2196             * @param groupId the group ID
2197             * @param userId the user ID
2198             * @return the number of matching message boards stats users
2199             * @throws SystemException if a system exception occurred
2200             */
2201            public int countByG_U(long groupId, long userId) throws SystemException {
2202                    Object[] finderArgs = new Object[] { groupId, userId };
2203    
2204                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2205                                    finderArgs, this);
2206    
2207                    if (count == null) {
2208                            StringBundler query = new StringBundler(3);
2209    
2210                            query.append(_SQL_COUNT_MBSTATSUSER_WHERE);
2211    
2212                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2213    
2214                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2215    
2216                            String sql = query.toString();
2217    
2218                            Session session = null;
2219    
2220                            try {
2221                                    session = openSession();
2222    
2223                                    Query q = session.createQuery(sql);
2224    
2225                                    QueryPos qPos = QueryPos.getInstance(q);
2226    
2227                                    qPos.add(groupId);
2228    
2229                                    qPos.add(userId);
2230    
2231                                    count = (Long)q.uniqueResult();
2232                            }
2233                            catch (Exception e) {
2234                                    throw processException(e);
2235                            }
2236                            finally {
2237                                    if (count == null) {
2238                                            count = Long.valueOf(0);
2239                                    }
2240    
2241                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2242                                            count);
2243    
2244                                    closeSession(session);
2245                            }
2246                    }
2247    
2248                    return count.intValue();
2249            }
2250    
2251            /**
2252             * Returns the number of message boards stats users where groupId = &#63; and userId &ne; &#63; and messageCount &ne; &#63;.
2253             *
2254             * @param groupId the group ID
2255             * @param userId the user ID
2256             * @param messageCount the message count
2257             * @return the number of matching message boards stats users
2258             * @throws SystemException if a system exception occurred
2259             */
2260            public int countByG_NotU_NotM(long groupId, long userId, int messageCount)
2261                    throws SystemException {
2262                    Object[] finderArgs = new Object[] { groupId, userId, messageCount };
2263    
2264                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTU_NOTM,
2265                                    finderArgs, this);
2266    
2267                    if (count == null) {
2268                            StringBundler query = new StringBundler(4);
2269    
2270                            query.append(_SQL_COUNT_MBSTATSUSER_WHERE);
2271    
2272                            query.append(_FINDER_COLUMN_G_NOTU_NOTM_GROUPID_2);
2273    
2274                            query.append(_FINDER_COLUMN_G_NOTU_NOTM_USERID_2);
2275    
2276                            query.append(_FINDER_COLUMN_G_NOTU_NOTM_MESSAGECOUNT_2);
2277    
2278                            String sql = query.toString();
2279    
2280                            Session session = null;
2281    
2282                            try {
2283                                    session = openSession();
2284    
2285                                    Query q = session.createQuery(sql);
2286    
2287                                    QueryPos qPos = QueryPos.getInstance(q);
2288    
2289                                    qPos.add(groupId);
2290    
2291                                    qPos.add(userId);
2292    
2293                                    qPos.add(messageCount);
2294    
2295                                    count = (Long)q.uniqueResult();
2296                            }
2297                            catch (Exception e) {
2298                                    throw processException(e);
2299                            }
2300                            finally {
2301                                    if (count == null) {
2302                                            count = Long.valueOf(0);
2303                                    }
2304    
2305                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTU_NOTM,
2306                                            finderArgs, count);
2307    
2308                                    closeSession(session);
2309                            }
2310                    }
2311    
2312                    return count.intValue();
2313            }
2314    
2315            /**
2316             * Returns the number of message boards stats users.
2317             *
2318             * @return the number of message boards stats users
2319             * @throws SystemException if a system exception occurred
2320             */
2321            public int countAll() throws SystemException {
2322                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2323                                    FINDER_ARGS_EMPTY, this);
2324    
2325                    if (count == null) {
2326                            Session session = null;
2327    
2328                            try {
2329                                    session = openSession();
2330    
2331                                    Query q = session.createQuery(_SQL_COUNT_MBSTATSUSER);
2332    
2333                                    count = (Long)q.uniqueResult();
2334                            }
2335                            catch (Exception e) {
2336                                    throw processException(e);
2337                            }
2338                            finally {
2339                                    if (count == null) {
2340                                            count = Long.valueOf(0);
2341                                    }
2342    
2343                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2344                                            FINDER_ARGS_EMPTY, count);
2345    
2346                                    closeSession(session);
2347                            }
2348                    }
2349    
2350                    return count.intValue();
2351            }
2352    
2353            /**
2354             * Initializes the message boards stats user persistence.
2355             */
2356            public void afterPropertiesSet() {
2357                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2358                                            com.liferay.portal.util.PropsUtil.get(
2359                                                    "value.object.listener.com.liferay.portlet.messageboards.model.MBStatsUser")));
2360    
2361                    if (listenerClassNames.length > 0) {
2362                            try {
2363                                    List<ModelListener<MBStatsUser>> listenersList = new ArrayList<ModelListener<MBStatsUser>>();
2364    
2365                                    for (String listenerClassName : listenerClassNames) {
2366                                            listenersList.add((ModelListener<MBStatsUser>)InstanceFactory.newInstance(
2367                                                            listenerClassName));
2368                                    }
2369    
2370                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2371                            }
2372                            catch (Exception e) {
2373                                    _log.error(e);
2374                            }
2375                    }
2376            }
2377    
2378            public void destroy() {
2379                    EntityCacheUtil.removeCache(MBStatsUserImpl.class.getName());
2380                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2381                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2382            }
2383    
2384            @BeanReference(type = MBBanPersistence.class)
2385            protected MBBanPersistence mbBanPersistence;
2386            @BeanReference(type = MBCategoryPersistence.class)
2387            protected MBCategoryPersistence mbCategoryPersistence;
2388            @BeanReference(type = MBDiscussionPersistence.class)
2389            protected MBDiscussionPersistence mbDiscussionPersistence;
2390            @BeanReference(type = MBMailingListPersistence.class)
2391            protected MBMailingListPersistence mbMailingListPersistence;
2392            @BeanReference(type = MBMessagePersistence.class)
2393            protected MBMessagePersistence mbMessagePersistence;
2394            @BeanReference(type = MBStatsUserPersistence.class)
2395            protected MBStatsUserPersistence mbStatsUserPersistence;
2396            @BeanReference(type = MBThreadPersistence.class)
2397            protected MBThreadPersistence mbThreadPersistence;
2398            @BeanReference(type = MBThreadFlagPersistence.class)
2399            protected MBThreadFlagPersistence mbThreadFlagPersistence;
2400            @BeanReference(type = GroupPersistence.class)
2401            protected GroupPersistence groupPersistence;
2402            @BeanReference(type = ResourcePersistence.class)
2403            protected ResourcePersistence resourcePersistence;
2404            @BeanReference(type = UserPersistence.class)
2405            protected UserPersistence userPersistence;
2406            private static final String _SQL_SELECT_MBSTATSUSER = "SELECT mbStatsUser FROM MBStatsUser mbStatsUser";
2407            private static final String _SQL_SELECT_MBSTATSUSER_WHERE = "SELECT mbStatsUser FROM MBStatsUser mbStatsUser WHERE ";
2408            private static final String _SQL_COUNT_MBSTATSUSER = "SELECT COUNT(mbStatsUser) FROM MBStatsUser mbStatsUser";
2409            private static final String _SQL_COUNT_MBSTATSUSER_WHERE = "SELECT COUNT(mbStatsUser) FROM MBStatsUser mbStatsUser WHERE ";
2410            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbStatsUser.groupId = ?";
2411            private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbStatsUser.userId = ?";
2412            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "mbStatsUser.groupId = ? AND ";
2413            private static final String _FINDER_COLUMN_G_U_USERID_2 = "mbStatsUser.userId = ?";
2414            private static final String _FINDER_COLUMN_G_NOTU_NOTM_GROUPID_2 = "mbStatsUser.groupId = ? AND ";
2415            private static final String _FINDER_COLUMN_G_NOTU_NOTM_USERID_2 = "mbStatsUser.userId != ? AND ";
2416            private static final String _FINDER_COLUMN_G_NOTU_NOTM_MESSAGECOUNT_2 = "mbStatsUser.messageCount != ?";
2417            private static final String _ORDER_BY_ENTITY_ALIAS = "mbStatsUser.";
2418            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBStatsUser exists with the primary key ";
2419            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBStatsUser exists with the key {";
2420            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2421            private static Log _log = LogFactoryUtil.getLog(MBStatsUserPersistenceImpl.class);
2422            private static MBStatsUser _nullMBStatsUser = new MBStatsUserImpl() {
2423                            @Override
2424                            public Object clone() {
2425                                    return this;
2426                            }
2427    
2428                            @Override
2429                            public CacheModel<MBStatsUser> toCacheModel() {
2430                                    return _nullMBStatsUserCacheModel;
2431                            }
2432                    };
2433    
2434            private static CacheModel<MBStatsUser> _nullMBStatsUserCacheModel = new CacheModel<MBStatsUser>() {
2435                            public MBStatsUser toEntityModel() {
2436                                    return _nullMBStatsUser;
2437                            }
2438                    };
2439    }