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