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