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.UserPersistence;
039    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
040    
041    import com.liferay.portlet.messageboards.NoSuchThreadFlagException;
042    import com.liferay.portlet.messageboards.model.MBThreadFlag;
043    import com.liferay.portlet.messageboards.model.impl.MBThreadFlagImpl;
044    import com.liferay.portlet.messageboards.model.impl.MBThreadFlagModelImpl;
045    
046    import java.io.Serializable;
047    
048    import java.util.ArrayList;
049    import java.util.Collections;
050    import java.util.List;
051    
052    /**
053     * The persistence implementation for the message boards thread flag service.
054     *
055     * <p>
056     * Caching information and settings can be found in <code>portal.properties</code>
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see MBThreadFlagPersistence
061     * @see MBThreadFlagUtil
062     * @generated
063     */
064    public class MBThreadFlagPersistenceImpl extends BasePersistenceImpl<MBThreadFlag>
065            implements MBThreadFlagPersistence {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link MBThreadFlagUtil} to access the message boards thread flag persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
070             */
071            public static final String FINDER_CLASS_NAME_ENTITY = MBThreadFlagImpl.class.getName();
072            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073                    ".List1";
074            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List2";
076            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
077                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, MBThreadFlagImpl.class,
078                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
079                            new String[] {
080                                    Long.class.getName(),
081                                    
082                            "java.lang.Integer", "java.lang.Integer",
083                                    "com.liferay.portal.kernel.util.OrderByComparator"
084                            });
085            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
086                    new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
087                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, MBThreadFlagImpl.class,
088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
089                            new String[] { Long.class.getName() },
090                            MBThreadFlagModelImpl.USERID_COLUMN_BITMASK);
091            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
092                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
094                            new String[] { Long.class.getName() });
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADID = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
096                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, MBThreadFlagImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByThreadId",
098                            new String[] {
099                                    Long.class.getName(),
100                                    
101                            "java.lang.Integer", "java.lang.Integer",
102                                    "com.liferay.portal.kernel.util.OrderByComparator"
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID =
105                    new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
106                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, MBThreadFlagImpl.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByThreadId",
108                            new String[] { Long.class.getName() },
109                            MBThreadFlagModelImpl.THREADID_COLUMN_BITMASK);
110            public static final FinderPath FINDER_PATH_COUNT_BY_THREADID = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
111                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, Long.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByThreadId",
113                            new String[] { Long.class.getName() });
114            public static final FinderPath FINDER_PATH_FETCH_BY_U_T = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
115                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, MBThreadFlagImpl.class,
116                            FINDER_CLASS_NAME_ENTITY, "fetchByU_T",
117                            new String[] { Long.class.getName(), Long.class.getName() },
118                            MBThreadFlagModelImpl.USERID_COLUMN_BITMASK |
119                            MBThreadFlagModelImpl.THREADID_COLUMN_BITMASK);
120            public static final FinderPath FINDER_PATH_COUNT_BY_U_T = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
121                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, Long.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_T",
123                            new String[] { Long.class.getName(), Long.class.getName() });
124            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
125                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, MBThreadFlagImpl.class,
126                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
127            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
128                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, MBThreadFlagImpl.class,
129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
130            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
131                            MBThreadFlagModelImpl.FINDER_CACHE_ENABLED, Long.class,
132                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
133    
134            /**
135             * Caches the message boards thread flag in the entity cache if it is enabled.
136             *
137             * @param mbThreadFlag the message boards thread flag
138             */
139            public void cacheResult(MBThreadFlag mbThreadFlag) {
140                    EntityCacheUtil.putResult(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
141                            MBThreadFlagImpl.class, mbThreadFlag.getPrimaryKey(), mbThreadFlag);
142    
143                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
144                            new Object[] {
145                                    Long.valueOf(mbThreadFlag.getUserId()),
146                                    Long.valueOf(mbThreadFlag.getThreadId())
147                            }, mbThreadFlag);
148    
149                    mbThreadFlag.resetOriginalValues();
150            }
151    
152            /**
153             * Caches the message boards thread flags in the entity cache if it is enabled.
154             *
155             * @param mbThreadFlags the message boards thread flags
156             */
157            public void cacheResult(List<MBThreadFlag> mbThreadFlags) {
158                    for (MBThreadFlag mbThreadFlag : mbThreadFlags) {
159                            if (EntityCacheUtil.getResult(
160                                                    MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
161                                                    MBThreadFlagImpl.class, mbThreadFlag.getPrimaryKey()) == null) {
162                                    cacheResult(mbThreadFlag);
163                            }
164                            else {
165                                    mbThreadFlag.resetOriginalValues();
166                            }
167                    }
168            }
169    
170            /**
171             * Clears the cache for all message boards thread flags.
172             *
173             * <p>
174             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
175             * </p>
176             */
177            @Override
178            public void clearCache() {
179                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
180                            CacheRegistryUtil.clear(MBThreadFlagImpl.class.getName());
181                    }
182    
183                    EntityCacheUtil.clearCache(MBThreadFlagImpl.class.getName());
184    
185                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
186                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
187                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
188            }
189    
190            /**
191             * Clears the cache for the message boards thread flag.
192             *
193             * <p>
194             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
195             * </p>
196             */
197            @Override
198            public void clearCache(MBThreadFlag mbThreadFlag) {
199                    EntityCacheUtil.removeResult(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
200                            MBThreadFlagImpl.class, mbThreadFlag.getPrimaryKey());
201    
202                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
203                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
204    
205                    clearUniqueFindersCache(mbThreadFlag);
206            }
207    
208            @Override
209            public void clearCache(List<MBThreadFlag> mbThreadFlags) {
210                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
211                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
212    
213                    for (MBThreadFlag mbThreadFlag : mbThreadFlags) {
214                            EntityCacheUtil.removeResult(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
215                                    MBThreadFlagImpl.class, mbThreadFlag.getPrimaryKey());
216    
217                            clearUniqueFindersCache(mbThreadFlag);
218                    }
219            }
220    
221            protected void clearUniqueFindersCache(MBThreadFlag mbThreadFlag) {
222                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T,
223                            new Object[] {
224                                    Long.valueOf(mbThreadFlag.getUserId()),
225                                    Long.valueOf(mbThreadFlag.getThreadId())
226                            });
227            }
228    
229            /**
230             * Creates a new message boards thread flag with the primary key. Does not add the message boards thread flag to the database.
231             *
232             * @param threadFlagId the primary key for the new message boards thread flag
233             * @return the new message boards thread flag
234             */
235            public MBThreadFlag create(long threadFlagId) {
236                    MBThreadFlag mbThreadFlag = new MBThreadFlagImpl();
237    
238                    mbThreadFlag.setNew(true);
239                    mbThreadFlag.setPrimaryKey(threadFlagId);
240    
241                    return mbThreadFlag;
242            }
243    
244            /**
245             * Removes the message boards thread flag with the primary key from the database. Also notifies the appropriate model listeners.
246             *
247             * @param threadFlagId the primary key of the message boards thread flag
248             * @return the message boards thread flag that was removed
249             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a message boards thread flag with the primary key could not be found
250             * @throws SystemException if a system exception occurred
251             */
252            public MBThreadFlag remove(long threadFlagId)
253                    throws NoSuchThreadFlagException, SystemException {
254                    return remove(Long.valueOf(threadFlagId));
255            }
256    
257            /**
258             * Removes the message boards thread flag with the primary key from the database. Also notifies the appropriate model listeners.
259             *
260             * @param primaryKey the primary key of the message boards thread flag
261             * @return the message boards thread flag that was removed
262             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a message boards thread flag with the primary key could not be found
263             * @throws SystemException if a system exception occurred
264             */
265            @Override
266            public MBThreadFlag remove(Serializable primaryKey)
267                    throws NoSuchThreadFlagException, SystemException {
268                    Session session = null;
269    
270                    try {
271                            session = openSession();
272    
273                            MBThreadFlag mbThreadFlag = (MBThreadFlag)session.get(MBThreadFlagImpl.class,
274                                            primaryKey);
275    
276                            if (mbThreadFlag == null) {
277                                    if (_log.isWarnEnabled()) {
278                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
279                                    }
280    
281                                    throw new NoSuchThreadFlagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
282                                            primaryKey);
283                            }
284    
285                            return remove(mbThreadFlag);
286                    }
287                    catch (NoSuchThreadFlagException nsee) {
288                            throw nsee;
289                    }
290                    catch (Exception e) {
291                            throw processException(e);
292                    }
293                    finally {
294                            closeSession(session);
295                    }
296            }
297    
298            @Override
299            protected MBThreadFlag removeImpl(MBThreadFlag mbThreadFlag)
300                    throws SystemException {
301                    mbThreadFlag = toUnwrappedModel(mbThreadFlag);
302    
303                    Session session = null;
304    
305                    try {
306                            session = openSession();
307    
308                            if (mbThreadFlag.isCachedModel()) {
309                                    mbThreadFlag = (MBThreadFlag)session.get(MBThreadFlagImpl.class,
310                                                    mbThreadFlag.getPrimaryKeyObj());
311                            }
312    
313                            session.delete(mbThreadFlag);
314                    }
315                    catch (Exception e) {
316                            throw processException(e);
317                    }
318                    finally {
319                            closeSession(session);
320                    }
321    
322                    clearCache(mbThreadFlag);
323    
324                    return mbThreadFlag;
325            }
326    
327            @Override
328            public MBThreadFlag updateImpl(
329                    com.liferay.portlet.messageboards.model.MBThreadFlag mbThreadFlag)
330                    throws SystemException {
331                    mbThreadFlag = toUnwrappedModel(mbThreadFlag);
332    
333                    boolean isNew = mbThreadFlag.isNew();
334    
335                    MBThreadFlagModelImpl mbThreadFlagModelImpl = (MBThreadFlagModelImpl)mbThreadFlag;
336    
337                    Session session = null;
338    
339                    try {
340                            session = openSession();
341    
342                            if (mbThreadFlag.isNew()) {
343                                    session.save(mbThreadFlag);
344    
345                                    mbThreadFlag.setNew(false);
346                            }
347                            else {
348                                    session.merge(mbThreadFlag);
349                            }
350                    }
351                    catch (Exception e) {
352                            throw processException(e);
353                    }
354                    finally {
355                            closeSession(session);
356                    }
357    
358                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
359    
360                    if (isNew || !MBThreadFlagModelImpl.COLUMN_BITMASK_ENABLED) {
361                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
362                    }
363    
364                    else {
365                            if ((mbThreadFlagModelImpl.getColumnBitmask() &
366                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
367                                    Object[] args = new Object[] {
368                                                    Long.valueOf(mbThreadFlagModelImpl.getOriginalUserId())
369                                            };
370    
371                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
372                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
373                                            args);
374    
375                                    args = new Object[] {
376                                                    Long.valueOf(mbThreadFlagModelImpl.getUserId())
377                                            };
378    
379                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
380                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
381                                            args);
382                            }
383    
384                            if ((mbThreadFlagModelImpl.getColumnBitmask() &
385                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID.getColumnBitmask()) != 0) {
386                                    Object[] args = new Object[] {
387                                                    Long.valueOf(mbThreadFlagModelImpl.getOriginalThreadId())
388                                            };
389    
390                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THREADID, args);
391                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID,
392                                            args);
393    
394                                    args = new Object[] {
395                                                    Long.valueOf(mbThreadFlagModelImpl.getThreadId())
396                                            };
397    
398                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THREADID, args);
399                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID,
400                                            args);
401                            }
402                    }
403    
404                    EntityCacheUtil.putResult(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
405                            MBThreadFlagImpl.class, mbThreadFlag.getPrimaryKey(), mbThreadFlag);
406    
407                    if (isNew) {
408                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
409                                    new Object[] {
410                                            Long.valueOf(mbThreadFlag.getUserId()),
411                                            Long.valueOf(mbThreadFlag.getThreadId())
412                                    }, mbThreadFlag);
413                    }
414                    else {
415                            if ((mbThreadFlagModelImpl.getColumnBitmask() &
416                                            FINDER_PATH_FETCH_BY_U_T.getColumnBitmask()) != 0) {
417                                    Object[] args = new Object[] {
418                                                    Long.valueOf(mbThreadFlagModelImpl.getOriginalUserId()),
419                                                    Long.valueOf(mbThreadFlagModelImpl.getOriginalThreadId())
420                                            };
421    
422                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_T, args);
423    
424                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T, args);
425    
426                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
427                                            new Object[] {
428                                                    Long.valueOf(mbThreadFlag.getUserId()),
429                                                    Long.valueOf(mbThreadFlag.getThreadId())
430                                            }, mbThreadFlag);
431                            }
432                    }
433    
434                    return mbThreadFlag;
435            }
436    
437            protected MBThreadFlag toUnwrappedModel(MBThreadFlag mbThreadFlag) {
438                    if (mbThreadFlag instanceof MBThreadFlagImpl) {
439                            return mbThreadFlag;
440                    }
441    
442                    MBThreadFlagImpl mbThreadFlagImpl = new MBThreadFlagImpl();
443    
444                    mbThreadFlagImpl.setNew(mbThreadFlag.isNew());
445                    mbThreadFlagImpl.setPrimaryKey(mbThreadFlag.getPrimaryKey());
446    
447                    mbThreadFlagImpl.setThreadFlagId(mbThreadFlag.getThreadFlagId());
448                    mbThreadFlagImpl.setUserId(mbThreadFlag.getUserId());
449                    mbThreadFlagImpl.setModifiedDate(mbThreadFlag.getModifiedDate());
450                    mbThreadFlagImpl.setThreadId(mbThreadFlag.getThreadId());
451    
452                    return mbThreadFlagImpl;
453            }
454    
455            /**
456             * Returns the message boards thread flag with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
457             *
458             * @param primaryKey the primary key of the message boards thread flag
459             * @return the message boards thread flag
460             * @throws com.liferay.portal.NoSuchModelException if a message boards thread flag with the primary key could not be found
461             * @throws SystemException if a system exception occurred
462             */
463            @Override
464            public MBThreadFlag findByPrimaryKey(Serializable primaryKey)
465                    throws NoSuchModelException, SystemException {
466                    return findByPrimaryKey(((Long)primaryKey).longValue());
467            }
468    
469            /**
470             * Returns the message boards thread flag with the primary key or throws a {@link com.liferay.portlet.messageboards.NoSuchThreadFlagException} if it could not be found.
471             *
472             * @param threadFlagId the primary key of the message boards thread flag
473             * @return the message boards thread flag
474             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a message boards thread flag with the primary key could not be found
475             * @throws SystemException if a system exception occurred
476             */
477            public MBThreadFlag findByPrimaryKey(long threadFlagId)
478                    throws NoSuchThreadFlagException, SystemException {
479                    MBThreadFlag mbThreadFlag = fetchByPrimaryKey(threadFlagId);
480    
481                    if (mbThreadFlag == null) {
482                            if (_log.isWarnEnabled()) {
483                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + threadFlagId);
484                            }
485    
486                            throw new NoSuchThreadFlagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
487                                    threadFlagId);
488                    }
489    
490                    return mbThreadFlag;
491            }
492    
493            /**
494             * Returns the message boards thread flag with the primary key or returns <code>null</code> if it could not be found.
495             *
496             * @param primaryKey the primary key of the message boards thread flag
497             * @return the message boards thread flag, or <code>null</code> if a message boards thread flag with the primary key could not be found
498             * @throws SystemException if a system exception occurred
499             */
500            @Override
501            public MBThreadFlag fetchByPrimaryKey(Serializable primaryKey)
502                    throws SystemException {
503                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
504            }
505    
506            /**
507             * Returns the message boards thread flag with the primary key or returns <code>null</code> if it could not be found.
508             *
509             * @param threadFlagId the primary key of the message boards thread flag
510             * @return the message boards thread flag, or <code>null</code> if a message boards thread flag with the primary key could not be found
511             * @throws SystemException if a system exception occurred
512             */
513            public MBThreadFlag fetchByPrimaryKey(long threadFlagId)
514                    throws SystemException {
515                    MBThreadFlag mbThreadFlag = (MBThreadFlag)EntityCacheUtil.getResult(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
516                                    MBThreadFlagImpl.class, threadFlagId);
517    
518                    if (mbThreadFlag == _nullMBThreadFlag) {
519                            return null;
520                    }
521    
522                    if (mbThreadFlag == null) {
523                            Session session = null;
524    
525                            boolean hasException = false;
526    
527                            try {
528                                    session = openSession();
529    
530                                    mbThreadFlag = (MBThreadFlag)session.get(MBThreadFlagImpl.class,
531                                                    Long.valueOf(threadFlagId));
532                            }
533                            catch (Exception e) {
534                                    hasException = true;
535    
536                                    throw processException(e);
537                            }
538                            finally {
539                                    if (mbThreadFlag != null) {
540                                            cacheResult(mbThreadFlag);
541                                    }
542                                    else if (!hasException) {
543                                            EntityCacheUtil.putResult(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
544                                                    MBThreadFlagImpl.class, threadFlagId, _nullMBThreadFlag);
545                                    }
546    
547                                    closeSession(session);
548                            }
549                    }
550    
551                    return mbThreadFlag;
552            }
553    
554            /**
555             * Returns all the message boards thread flags where userId = &#63;.
556             *
557             * @param userId the user ID
558             * @return the matching message boards thread flags
559             * @throws SystemException if a system exception occurred
560             */
561            public List<MBThreadFlag> findByUserId(long userId)
562                    throws SystemException {
563                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
564            }
565    
566            /**
567             * Returns a range of all the message boards thread flags where userId = &#63;.
568             *
569             * <p>
570             * 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.
571             * </p>
572             *
573             * @param userId the user ID
574             * @param start the lower bound of the range of message boards thread flags
575             * @param end the upper bound of the range of message boards thread flags (not inclusive)
576             * @return the range of matching message boards thread flags
577             * @throws SystemException if a system exception occurred
578             */
579            public List<MBThreadFlag> findByUserId(long userId, int start, int end)
580                    throws SystemException {
581                    return findByUserId(userId, start, end, null);
582            }
583    
584            /**
585             * Returns an ordered range of all the message boards thread flags where userId = &#63;.
586             *
587             * <p>
588             * 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.
589             * </p>
590             *
591             * @param userId the user ID
592             * @param start the lower bound of the range of message boards thread flags
593             * @param end the upper bound of the range of message boards thread flags (not inclusive)
594             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
595             * @return the ordered range of matching message boards thread flags
596             * @throws SystemException if a system exception occurred
597             */
598            public List<MBThreadFlag> findByUserId(long userId, int start, int end,
599                    OrderByComparator orderByComparator) throws SystemException {
600                    FinderPath finderPath = null;
601                    Object[] finderArgs = null;
602    
603                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
604                                    (orderByComparator == null)) {
605                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
606                            finderArgs = new Object[] { userId };
607                    }
608                    else {
609                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
610                            finderArgs = new Object[] { userId, start, end, orderByComparator };
611                    }
612    
613                    List<MBThreadFlag> list = (List<MBThreadFlag>)FinderCacheUtil.getResult(finderPath,
614                                    finderArgs, this);
615    
616                    if ((list != null) && !list.isEmpty()) {
617                            for (MBThreadFlag mbThreadFlag : list) {
618                                    if ((userId != mbThreadFlag.getUserId())) {
619                                            list = null;
620    
621                                            break;
622                                    }
623                            }
624                    }
625    
626                    if (list == null) {
627                            StringBundler query = null;
628    
629                            if (orderByComparator != null) {
630                                    query = new StringBundler(3 +
631                                                    (orderByComparator.getOrderByFields().length * 3));
632                            }
633                            else {
634                                    query = new StringBundler(2);
635                            }
636    
637                            query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
638    
639                            query.append(_FINDER_COLUMN_USERID_USERID_2);
640    
641                            if (orderByComparator != null) {
642                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
643                                            orderByComparator);
644                            }
645    
646                            String sql = query.toString();
647    
648                            Session session = null;
649    
650                            try {
651                                    session = openSession();
652    
653                                    Query q = session.createQuery(sql);
654    
655                                    QueryPos qPos = QueryPos.getInstance(q);
656    
657                                    qPos.add(userId);
658    
659                                    list = (List<MBThreadFlag>)QueryUtil.list(q, getDialect(),
660                                                    start, end);
661                            }
662                            catch (Exception e) {
663                                    throw processException(e);
664                            }
665                            finally {
666                                    if (list == null) {
667                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
668                                    }
669                                    else {
670                                            cacheResult(list);
671    
672                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
673                                    }
674    
675                                    closeSession(session);
676                            }
677                    }
678    
679                    return list;
680            }
681    
682            /**
683             * Returns the first message boards thread flag in the ordered set where userId = &#63;.
684             *
685             * @param userId the user ID
686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
687             * @return the first matching message boards thread flag
688             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
689             * @throws SystemException if a system exception occurred
690             */
691            public MBThreadFlag findByUserId_First(long userId,
692                    OrderByComparator orderByComparator)
693                    throws NoSuchThreadFlagException, SystemException {
694                    MBThreadFlag mbThreadFlag = fetchByUserId_First(userId,
695                                    orderByComparator);
696    
697                    if (mbThreadFlag != null) {
698                            return mbThreadFlag;
699                    }
700    
701                    StringBundler msg = new StringBundler(4);
702    
703                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
704    
705                    msg.append("userId=");
706                    msg.append(userId);
707    
708                    msg.append(StringPool.CLOSE_CURLY_BRACE);
709    
710                    throw new NoSuchThreadFlagException(msg.toString());
711            }
712    
713            /**
714             * Returns the first message boards thread flag in the ordered set where userId = &#63;.
715             *
716             * @param userId the user ID
717             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
718             * @return the first matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
719             * @throws SystemException if a system exception occurred
720             */
721            public MBThreadFlag fetchByUserId_First(long userId,
722                    OrderByComparator orderByComparator) throws SystemException {
723                    List<MBThreadFlag> list = findByUserId(userId, 0, 1, orderByComparator);
724    
725                    if (!list.isEmpty()) {
726                            return list.get(0);
727                    }
728    
729                    return null;
730            }
731    
732            /**
733             * Returns the last message boards thread flag in the ordered set where userId = &#63;.
734             *
735             * @param userId the user ID
736             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
737             * @return the last matching message boards thread flag
738             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
739             * @throws SystemException if a system exception occurred
740             */
741            public MBThreadFlag findByUserId_Last(long userId,
742                    OrderByComparator orderByComparator)
743                    throws NoSuchThreadFlagException, SystemException {
744                    MBThreadFlag mbThreadFlag = fetchByUserId_Last(userId, orderByComparator);
745    
746                    if (mbThreadFlag != null) {
747                            return mbThreadFlag;
748                    }
749    
750                    StringBundler msg = new StringBundler(4);
751    
752                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
753    
754                    msg.append("userId=");
755                    msg.append(userId);
756    
757                    msg.append(StringPool.CLOSE_CURLY_BRACE);
758    
759                    throw new NoSuchThreadFlagException(msg.toString());
760            }
761    
762            /**
763             * Returns the last message boards thread flag in the ordered set where userId = &#63;.
764             *
765             * @param userId the user ID
766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
767             * @return the last matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
768             * @throws SystemException if a system exception occurred
769             */
770            public MBThreadFlag fetchByUserId_Last(long userId,
771                    OrderByComparator orderByComparator) throws SystemException {
772                    int count = countByUserId(userId);
773    
774                    List<MBThreadFlag> list = findByUserId(userId, count - 1, count,
775                                    orderByComparator);
776    
777                    if (!list.isEmpty()) {
778                            return list.get(0);
779                    }
780    
781                    return null;
782            }
783    
784            /**
785             * Returns the message boards thread flags before and after the current message boards thread flag in the ordered set where userId = &#63;.
786             *
787             * @param threadFlagId the primary key of the current message boards thread flag
788             * @param userId the user ID
789             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
790             * @return the previous, current, and next message boards thread flag
791             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a message boards thread flag with the primary key could not be found
792             * @throws SystemException if a system exception occurred
793             */
794            public MBThreadFlag[] findByUserId_PrevAndNext(long threadFlagId,
795                    long userId, OrderByComparator orderByComparator)
796                    throws NoSuchThreadFlagException, SystemException {
797                    MBThreadFlag mbThreadFlag = findByPrimaryKey(threadFlagId);
798    
799                    Session session = null;
800    
801                    try {
802                            session = openSession();
803    
804                            MBThreadFlag[] array = new MBThreadFlagImpl[3];
805    
806                            array[0] = getByUserId_PrevAndNext(session, mbThreadFlag, userId,
807                                            orderByComparator, true);
808    
809                            array[1] = mbThreadFlag;
810    
811                            array[2] = getByUserId_PrevAndNext(session, mbThreadFlag, userId,
812                                            orderByComparator, false);
813    
814                            return array;
815                    }
816                    catch (Exception e) {
817                            throw processException(e);
818                    }
819                    finally {
820                            closeSession(session);
821                    }
822            }
823    
824            protected MBThreadFlag getByUserId_PrevAndNext(Session session,
825                    MBThreadFlag mbThreadFlag, long userId,
826                    OrderByComparator orderByComparator, boolean previous) {
827                    StringBundler query = null;
828    
829                    if (orderByComparator != null) {
830                            query = new StringBundler(6 +
831                                            (orderByComparator.getOrderByFields().length * 6));
832                    }
833                    else {
834                            query = new StringBundler(3);
835                    }
836    
837                    query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
838    
839                    query.append(_FINDER_COLUMN_USERID_USERID_2);
840    
841                    if (orderByComparator != null) {
842                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
843    
844                            if (orderByConditionFields.length > 0) {
845                                    query.append(WHERE_AND);
846                            }
847    
848                            for (int i = 0; i < orderByConditionFields.length; i++) {
849                                    query.append(_ORDER_BY_ENTITY_ALIAS);
850                                    query.append(orderByConditionFields[i]);
851    
852                                    if ((i + 1) < orderByConditionFields.length) {
853                                            if (orderByComparator.isAscending() ^ previous) {
854                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
855                                            }
856                                            else {
857                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
858                                            }
859                                    }
860                                    else {
861                                            if (orderByComparator.isAscending() ^ previous) {
862                                                    query.append(WHERE_GREATER_THAN);
863                                            }
864                                            else {
865                                                    query.append(WHERE_LESSER_THAN);
866                                            }
867                                    }
868                            }
869    
870                            query.append(ORDER_BY_CLAUSE);
871    
872                            String[] orderByFields = orderByComparator.getOrderByFields();
873    
874                            for (int i = 0; i < orderByFields.length; i++) {
875                                    query.append(_ORDER_BY_ENTITY_ALIAS);
876                                    query.append(orderByFields[i]);
877    
878                                    if ((i + 1) < orderByFields.length) {
879                                            if (orderByComparator.isAscending() ^ previous) {
880                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
881                                            }
882                                            else {
883                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
884                                            }
885                                    }
886                                    else {
887                                            if (orderByComparator.isAscending() ^ previous) {
888                                                    query.append(ORDER_BY_ASC);
889                                            }
890                                            else {
891                                                    query.append(ORDER_BY_DESC);
892                                            }
893                                    }
894                            }
895                    }
896    
897                    String sql = query.toString();
898    
899                    Query q = session.createQuery(sql);
900    
901                    q.setFirstResult(0);
902                    q.setMaxResults(2);
903    
904                    QueryPos qPos = QueryPos.getInstance(q);
905    
906                    qPos.add(userId);
907    
908                    if (orderByComparator != null) {
909                            Object[] values = orderByComparator.getOrderByConditionValues(mbThreadFlag);
910    
911                            for (Object value : values) {
912                                    qPos.add(value);
913                            }
914                    }
915    
916                    List<MBThreadFlag> list = q.list();
917    
918                    if (list.size() == 2) {
919                            return list.get(1);
920                    }
921                    else {
922                            return null;
923                    }
924            }
925    
926            /**
927             * Returns all the message boards thread flags where threadId = &#63;.
928             *
929             * @param threadId the thread ID
930             * @return the matching message boards thread flags
931             * @throws SystemException if a system exception occurred
932             */
933            public List<MBThreadFlag> findByThreadId(long threadId)
934                    throws SystemException {
935                    return findByThreadId(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
936                            null);
937            }
938    
939            /**
940             * Returns a range of all the message boards thread flags where threadId = &#63;.
941             *
942             * <p>
943             * 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.
944             * </p>
945             *
946             * @param threadId the thread ID
947             * @param start the lower bound of the range of message boards thread flags
948             * @param end the upper bound of the range of message boards thread flags (not inclusive)
949             * @return the range of matching message boards thread flags
950             * @throws SystemException if a system exception occurred
951             */
952            public List<MBThreadFlag> findByThreadId(long threadId, int start, int end)
953                    throws SystemException {
954                    return findByThreadId(threadId, start, end, null);
955            }
956    
957            /**
958             * Returns an ordered range of all the message boards thread flags where threadId = &#63;.
959             *
960             * <p>
961             * 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.
962             * </p>
963             *
964             * @param threadId the thread ID
965             * @param start the lower bound of the range of message boards thread flags
966             * @param end the upper bound of the range of message boards thread flags (not inclusive)
967             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
968             * @return the ordered range of matching message boards thread flags
969             * @throws SystemException if a system exception occurred
970             */
971            public List<MBThreadFlag> findByThreadId(long threadId, int start, int end,
972                    OrderByComparator orderByComparator) throws SystemException {
973                    FinderPath finderPath = null;
974                    Object[] finderArgs = null;
975    
976                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
977                                    (orderByComparator == null)) {
978                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID;
979                            finderArgs = new Object[] { threadId };
980                    }
981                    else {
982                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADID;
983                            finderArgs = new Object[] { threadId, start, end, orderByComparator };
984                    }
985    
986                    List<MBThreadFlag> list = (List<MBThreadFlag>)FinderCacheUtil.getResult(finderPath,
987                                    finderArgs, this);
988    
989                    if ((list != null) && !list.isEmpty()) {
990                            for (MBThreadFlag mbThreadFlag : list) {
991                                    if ((threadId != mbThreadFlag.getThreadId())) {
992                                            list = null;
993    
994                                            break;
995                                    }
996                            }
997                    }
998    
999                    if (list == null) {
1000                            StringBundler query = null;
1001    
1002                            if (orderByComparator != null) {
1003                                    query = new StringBundler(3 +
1004                                                    (orderByComparator.getOrderByFields().length * 3));
1005                            }
1006                            else {
1007                                    query = new StringBundler(2);
1008                            }
1009    
1010                            query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
1011    
1012                            query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1013    
1014                            if (orderByComparator != null) {
1015                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1016                                            orderByComparator);
1017                            }
1018    
1019                            String sql = query.toString();
1020    
1021                            Session session = null;
1022    
1023                            try {
1024                                    session = openSession();
1025    
1026                                    Query q = session.createQuery(sql);
1027    
1028                                    QueryPos qPos = QueryPos.getInstance(q);
1029    
1030                                    qPos.add(threadId);
1031    
1032                                    list = (List<MBThreadFlag>)QueryUtil.list(q, getDialect(),
1033                                                    start, end);
1034                            }
1035                            catch (Exception e) {
1036                                    throw processException(e);
1037                            }
1038                            finally {
1039                                    if (list == null) {
1040                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1041                                    }
1042                                    else {
1043                                            cacheResult(list);
1044    
1045                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1046                                    }
1047    
1048                                    closeSession(session);
1049                            }
1050                    }
1051    
1052                    return list;
1053            }
1054    
1055            /**
1056             * Returns the first message boards thread flag in the ordered set where threadId = &#63;.
1057             *
1058             * @param threadId the thread ID
1059             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1060             * @return the first matching message boards thread flag
1061             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
1062             * @throws SystemException if a system exception occurred
1063             */
1064            public MBThreadFlag findByThreadId_First(long threadId,
1065                    OrderByComparator orderByComparator)
1066                    throws NoSuchThreadFlagException, SystemException {
1067                    MBThreadFlag mbThreadFlag = fetchByThreadId_First(threadId,
1068                                    orderByComparator);
1069    
1070                    if (mbThreadFlag != null) {
1071                            return mbThreadFlag;
1072                    }
1073    
1074                    StringBundler msg = new StringBundler(4);
1075    
1076                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1077    
1078                    msg.append("threadId=");
1079                    msg.append(threadId);
1080    
1081                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1082    
1083                    throw new NoSuchThreadFlagException(msg.toString());
1084            }
1085    
1086            /**
1087             * Returns the first message boards thread flag in the ordered set where threadId = &#63;.
1088             *
1089             * @param threadId the thread ID
1090             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1091             * @return the first matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
1092             * @throws SystemException if a system exception occurred
1093             */
1094            public MBThreadFlag fetchByThreadId_First(long threadId,
1095                    OrderByComparator orderByComparator) throws SystemException {
1096                    List<MBThreadFlag> list = findByThreadId(threadId, 0, 1,
1097                                    orderByComparator);
1098    
1099                    if (!list.isEmpty()) {
1100                            return list.get(0);
1101                    }
1102    
1103                    return null;
1104            }
1105    
1106            /**
1107             * Returns the last message boards thread flag in the ordered set where threadId = &#63;.
1108             *
1109             * @param threadId the thread ID
1110             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1111             * @return the last matching message boards thread flag
1112             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
1113             * @throws SystemException if a system exception occurred
1114             */
1115            public MBThreadFlag findByThreadId_Last(long threadId,
1116                    OrderByComparator orderByComparator)
1117                    throws NoSuchThreadFlagException, SystemException {
1118                    MBThreadFlag mbThreadFlag = fetchByThreadId_Last(threadId,
1119                                    orderByComparator);
1120    
1121                    if (mbThreadFlag != null) {
1122                            return mbThreadFlag;
1123                    }
1124    
1125                    StringBundler msg = new StringBundler(4);
1126    
1127                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1128    
1129                    msg.append("threadId=");
1130                    msg.append(threadId);
1131    
1132                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1133    
1134                    throw new NoSuchThreadFlagException(msg.toString());
1135            }
1136    
1137            /**
1138             * Returns the last message boards thread flag in the ordered set where threadId = &#63;.
1139             *
1140             * @param threadId the thread ID
1141             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1142             * @return the last matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
1143             * @throws SystemException if a system exception occurred
1144             */
1145            public MBThreadFlag fetchByThreadId_Last(long threadId,
1146                    OrderByComparator orderByComparator) throws SystemException {
1147                    int count = countByThreadId(threadId);
1148    
1149                    List<MBThreadFlag> list = findByThreadId(threadId, count - 1, count,
1150                                    orderByComparator);
1151    
1152                    if (!list.isEmpty()) {
1153                            return list.get(0);
1154                    }
1155    
1156                    return null;
1157            }
1158    
1159            /**
1160             * Returns the message boards thread flags before and after the current message boards thread flag in the ordered set where threadId = &#63;.
1161             *
1162             * @param threadFlagId the primary key of the current message boards thread flag
1163             * @param threadId the thread ID
1164             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1165             * @return the previous, current, and next message boards thread flag
1166             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a message boards thread flag with the primary key could not be found
1167             * @throws SystemException if a system exception occurred
1168             */
1169            public MBThreadFlag[] findByThreadId_PrevAndNext(long threadFlagId,
1170                    long threadId, OrderByComparator orderByComparator)
1171                    throws NoSuchThreadFlagException, SystemException {
1172                    MBThreadFlag mbThreadFlag = findByPrimaryKey(threadFlagId);
1173    
1174                    Session session = null;
1175    
1176                    try {
1177                            session = openSession();
1178    
1179                            MBThreadFlag[] array = new MBThreadFlagImpl[3];
1180    
1181                            array[0] = getByThreadId_PrevAndNext(session, mbThreadFlag,
1182                                            threadId, orderByComparator, true);
1183    
1184                            array[1] = mbThreadFlag;
1185    
1186                            array[2] = getByThreadId_PrevAndNext(session, mbThreadFlag,
1187                                            threadId, orderByComparator, false);
1188    
1189                            return array;
1190                    }
1191                    catch (Exception e) {
1192                            throw processException(e);
1193                    }
1194                    finally {
1195                            closeSession(session);
1196                    }
1197            }
1198    
1199            protected MBThreadFlag getByThreadId_PrevAndNext(Session session,
1200                    MBThreadFlag mbThreadFlag, long threadId,
1201                    OrderByComparator orderByComparator, boolean previous) {
1202                    StringBundler query = null;
1203    
1204                    if (orderByComparator != null) {
1205                            query = new StringBundler(6 +
1206                                            (orderByComparator.getOrderByFields().length * 6));
1207                    }
1208                    else {
1209                            query = new StringBundler(3);
1210                    }
1211    
1212                    query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
1213    
1214                    query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1215    
1216                    if (orderByComparator != null) {
1217                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1218    
1219                            if (orderByConditionFields.length > 0) {
1220                                    query.append(WHERE_AND);
1221                            }
1222    
1223                            for (int i = 0; i < orderByConditionFields.length; i++) {
1224                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1225                                    query.append(orderByConditionFields[i]);
1226    
1227                                    if ((i + 1) < orderByConditionFields.length) {
1228                                            if (orderByComparator.isAscending() ^ previous) {
1229                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1230                                            }
1231                                            else {
1232                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1233                                            }
1234                                    }
1235                                    else {
1236                                            if (orderByComparator.isAscending() ^ previous) {
1237                                                    query.append(WHERE_GREATER_THAN);
1238                                            }
1239                                            else {
1240                                                    query.append(WHERE_LESSER_THAN);
1241                                            }
1242                                    }
1243                            }
1244    
1245                            query.append(ORDER_BY_CLAUSE);
1246    
1247                            String[] orderByFields = orderByComparator.getOrderByFields();
1248    
1249                            for (int i = 0; i < orderByFields.length; i++) {
1250                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1251                                    query.append(orderByFields[i]);
1252    
1253                                    if ((i + 1) < orderByFields.length) {
1254                                            if (orderByComparator.isAscending() ^ previous) {
1255                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1256                                            }
1257                                            else {
1258                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1259                                            }
1260                                    }
1261                                    else {
1262                                            if (orderByComparator.isAscending() ^ previous) {
1263                                                    query.append(ORDER_BY_ASC);
1264                                            }
1265                                            else {
1266                                                    query.append(ORDER_BY_DESC);
1267                                            }
1268                                    }
1269                            }
1270                    }
1271    
1272                    String sql = query.toString();
1273    
1274                    Query q = session.createQuery(sql);
1275    
1276                    q.setFirstResult(0);
1277                    q.setMaxResults(2);
1278    
1279                    QueryPos qPos = QueryPos.getInstance(q);
1280    
1281                    qPos.add(threadId);
1282    
1283                    if (orderByComparator != null) {
1284                            Object[] values = orderByComparator.getOrderByConditionValues(mbThreadFlag);
1285    
1286                            for (Object value : values) {
1287                                    qPos.add(value);
1288                            }
1289                    }
1290    
1291                    List<MBThreadFlag> list = q.list();
1292    
1293                    if (list.size() == 2) {
1294                            return list.get(1);
1295                    }
1296                    else {
1297                            return null;
1298                    }
1299            }
1300    
1301            /**
1302             * Returns the message boards thread flag where userId = &#63; and threadId = &#63; or throws a {@link com.liferay.portlet.messageboards.NoSuchThreadFlagException} if it could not be found.
1303             *
1304             * @param userId the user ID
1305             * @param threadId the thread ID
1306             * @return the matching message boards thread flag
1307             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
1308             * @throws SystemException if a system exception occurred
1309             */
1310            public MBThreadFlag findByU_T(long userId, long threadId)
1311                    throws NoSuchThreadFlagException, SystemException {
1312                    MBThreadFlag mbThreadFlag = fetchByU_T(userId, threadId);
1313    
1314                    if (mbThreadFlag == null) {
1315                            StringBundler msg = new StringBundler(6);
1316    
1317                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1318    
1319                            msg.append("userId=");
1320                            msg.append(userId);
1321    
1322                            msg.append(", threadId=");
1323                            msg.append(threadId);
1324    
1325                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1326    
1327                            if (_log.isWarnEnabled()) {
1328                                    _log.warn(msg.toString());
1329                            }
1330    
1331                            throw new NoSuchThreadFlagException(msg.toString());
1332                    }
1333    
1334                    return mbThreadFlag;
1335            }
1336    
1337            /**
1338             * Returns the message boards thread flag where userId = &#63; and threadId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1339             *
1340             * @param userId the user ID
1341             * @param threadId the thread ID
1342             * @return the matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
1343             * @throws SystemException if a system exception occurred
1344             */
1345            public MBThreadFlag fetchByU_T(long userId, long threadId)
1346                    throws SystemException {
1347                    return fetchByU_T(userId, threadId, true);
1348            }
1349    
1350            /**
1351             * Returns the message boards thread flag where userId = &#63; and threadId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1352             *
1353             * @param userId the user ID
1354             * @param threadId the thread ID
1355             * @param retrieveFromCache whether to use the finder cache
1356             * @return the matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
1357             * @throws SystemException if a system exception occurred
1358             */
1359            public MBThreadFlag fetchByU_T(long userId, long threadId,
1360                    boolean retrieveFromCache) throws SystemException {
1361                    Object[] finderArgs = new Object[] { userId, threadId };
1362    
1363                    Object result = null;
1364    
1365                    if (retrieveFromCache) {
1366                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_T,
1367                                            finderArgs, this);
1368                    }
1369    
1370                    if (result instanceof MBThreadFlag) {
1371                            MBThreadFlag mbThreadFlag = (MBThreadFlag)result;
1372    
1373                            if ((userId != mbThreadFlag.getUserId()) ||
1374                                            (threadId != mbThreadFlag.getThreadId())) {
1375                                    result = null;
1376                            }
1377                    }
1378    
1379                    if (result == null) {
1380                            StringBundler query = new StringBundler(3);
1381    
1382                            query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
1383    
1384                            query.append(_FINDER_COLUMN_U_T_USERID_2);
1385    
1386                            query.append(_FINDER_COLUMN_U_T_THREADID_2);
1387    
1388                            String sql = query.toString();
1389    
1390                            Session session = null;
1391    
1392                            try {
1393                                    session = openSession();
1394    
1395                                    Query q = session.createQuery(sql);
1396    
1397                                    QueryPos qPos = QueryPos.getInstance(q);
1398    
1399                                    qPos.add(userId);
1400    
1401                                    qPos.add(threadId);
1402    
1403                                    List<MBThreadFlag> list = q.list();
1404    
1405                                    result = list;
1406    
1407                                    MBThreadFlag mbThreadFlag = null;
1408    
1409                                    if (list.isEmpty()) {
1410                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
1411                                                    finderArgs, list);
1412                                    }
1413                                    else {
1414                                            mbThreadFlag = list.get(0);
1415    
1416                                            cacheResult(mbThreadFlag);
1417    
1418                                            if ((mbThreadFlag.getUserId() != userId) ||
1419                                                            (mbThreadFlag.getThreadId() != threadId)) {
1420                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
1421                                                            finderArgs, mbThreadFlag);
1422                                            }
1423                                    }
1424    
1425                                    return mbThreadFlag;
1426                            }
1427                            catch (Exception e) {
1428                                    throw processException(e);
1429                            }
1430                            finally {
1431                                    if (result == null) {
1432                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T,
1433                                                    finderArgs);
1434                                    }
1435    
1436                                    closeSession(session);
1437                            }
1438                    }
1439                    else {
1440                            if (result instanceof List<?>) {
1441                                    return null;
1442                            }
1443                            else {
1444                                    return (MBThreadFlag)result;
1445                            }
1446                    }
1447            }
1448    
1449            /**
1450             * Returns all the message boards thread flags.
1451             *
1452             * @return the message boards thread flags
1453             * @throws SystemException if a system exception occurred
1454             */
1455            public List<MBThreadFlag> findAll() throws SystemException {
1456                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1457            }
1458    
1459            /**
1460             * Returns a range of all the message boards thread flags.
1461             *
1462             * <p>
1463             * 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.
1464             * </p>
1465             *
1466             * @param start the lower bound of the range of message boards thread flags
1467             * @param end the upper bound of the range of message boards thread flags (not inclusive)
1468             * @return the range of message boards thread flags
1469             * @throws SystemException if a system exception occurred
1470             */
1471            public List<MBThreadFlag> findAll(int start, int end)
1472                    throws SystemException {
1473                    return findAll(start, end, null);
1474            }
1475    
1476            /**
1477             * Returns an ordered range of all the message boards thread flags.
1478             *
1479             * <p>
1480             * 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.
1481             * </p>
1482             *
1483             * @param start the lower bound of the range of message boards thread flags
1484             * @param end the upper bound of the range of message boards thread flags (not inclusive)
1485             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1486             * @return the ordered range of message boards thread flags
1487             * @throws SystemException if a system exception occurred
1488             */
1489            public List<MBThreadFlag> findAll(int start, int end,
1490                    OrderByComparator orderByComparator) throws SystemException {
1491                    FinderPath finderPath = null;
1492                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1493    
1494                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1495                                    (orderByComparator == null)) {
1496                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1497                            finderArgs = FINDER_ARGS_EMPTY;
1498                    }
1499                    else {
1500                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1501                            finderArgs = new Object[] { start, end, orderByComparator };
1502                    }
1503    
1504                    List<MBThreadFlag> list = (List<MBThreadFlag>)FinderCacheUtil.getResult(finderPath,
1505                                    finderArgs, this);
1506    
1507                    if (list == null) {
1508                            StringBundler query = null;
1509                            String sql = null;
1510    
1511                            if (orderByComparator != null) {
1512                                    query = new StringBundler(2 +
1513                                                    (orderByComparator.getOrderByFields().length * 3));
1514    
1515                                    query.append(_SQL_SELECT_MBTHREADFLAG);
1516    
1517                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1518                                            orderByComparator);
1519    
1520                                    sql = query.toString();
1521                            }
1522                            else {
1523                                    sql = _SQL_SELECT_MBTHREADFLAG;
1524                            }
1525    
1526                            Session session = null;
1527    
1528                            try {
1529                                    session = openSession();
1530    
1531                                    Query q = session.createQuery(sql);
1532    
1533                                    if (orderByComparator == null) {
1534                                            list = (List<MBThreadFlag>)QueryUtil.list(q, getDialect(),
1535                                                            start, end, false);
1536    
1537                                            Collections.sort(list);
1538                                    }
1539                                    else {
1540                                            list = (List<MBThreadFlag>)QueryUtil.list(q, getDialect(),
1541                                                            start, end);
1542                                    }
1543                            }
1544                            catch (Exception e) {
1545                                    throw processException(e);
1546                            }
1547                            finally {
1548                                    if (list == null) {
1549                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1550                                    }
1551                                    else {
1552                                            cacheResult(list);
1553    
1554                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1555                                    }
1556    
1557                                    closeSession(session);
1558                            }
1559                    }
1560    
1561                    return list;
1562            }
1563    
1564            /**
1565             * Removes all the message boards thread flags where userId = &#63; from the database.
1566             *
1567             * @param userId the user ID
1568             * @throws SystemException if a system exception occurred
1569             */
1570            public void removeByUserId(long userId) throws SystemException {
1571                    for (MBThreadFlag mbThreadFlag : findByUserId(userId)) {
1572                            remove(mbThreadFlag);
1573                    }
1574            }
1575    
1576            /**
1577             * Removes all the message boards thread flags where threadId = &#63; from the database.
1578             *
1579             * @param threadId the thread ID
1580             * @throws SystemException if a system exception occurred
1581             */
1582            public void removeByThreadId(long threadId) throws SystemException {
1583                    for (MBThreadFlag mbThreadFlag : findByThreadId(threadId)) {
1584                            remove(mbThreadFlag);
1585                    }
1586            }
1587    
1588            /**
1589             * Removes the message boards thread flag where userId = &#63; and threadId = &#63; from the database.
1590             *
1591             * @param userId the user ID
1592             * @param threadId the thread ID
1593             * @return the message boards thread flag that was removed
1594             * @throws SystemException if a system exception occurred
1595             */
1596            public MBThreadFlag removeByU_T(long userId, long threadId)
1597                    throws NoSuchThreadFlagException, SystemException {
1598                    MBThreadFlag mbThreadFlag = findByU_T(userId, threadId);
1599    
1600                    return remove(mbThreadFlag);
1601            }
1602    
1603            /**
1604             * Removes all the message boards thread flags from the database.
1605             *
1606             * @throws SystemException if a system exception occurred
1607             */
1608            public void removeAll() throws SystemException {
1609                    for (MBThreadFlag mbThreadFlag : findAll()) {
1610                            remove(mbThreadFlag);
1611                    }
1612            }
1613    
1614            /**
1615             * Returns the number of message boards thread flags where userId = &#63;.
1616             *
1617             * @param userId the user ID
1618             * @return the number of matching message boards thread flags
1619             * @throws SystemException if a system exception occurred
1620             */
1621            public int countByUserId(long userId) throws SystemException {
1622                    Object[] finderArgs = new Object[] { userId };
1623    
1624                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1625                                    finderArgs, this);
1626    
1627                    if (count == null) {
1628                            StringBundler query = new StringBundler(2);
1629    
1630                            query.append(_SQL_COUNT_MBTHREADFLAG_WHERE);
1631    
1632                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1633    
1634                            String sql = query.toString();
1635    
1636                            Session session = null;
1637    
1638                            try {
1639                                    session = openSession();
1640    
1641                                    Query q = session.createQuery(sql);
1642    
1643                                    QueryPos qPos = QueryPos.getInstance(q);
1644    
1645                                    qPos.add(userId);
1646    
1647                                    count = (Long)q.uniqueResult();
1648                            }
1649                            catch (Exception e) {
1650                                    throw processException(e);
1651                            }
1652                            finally {
1653                                    if (count == null) {
1654                                            count = Long.valueOf(0);
1655                                    }
1656    
1657                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1658                                            finderArgs, count);
1659    
1660                                    closeSession(session);
1661                            }
1662                    }
1663    
1664                    return count.intValue();
1665            }
1666    
1667            /**
1668             * Returns the number of message boards thread flags where threadId = &#63;.
1669             *
1670             * @param threadId the thread ID
1671             * @return the number of matching message boards thread flags
1672             * @throws SystemException if a system exception occurred
1673             */
1674            public int countByThreadId(long threadId) throws SystemException {
1675                    Object[] finderArgs = new Object[] { threadId };
1676    
1677                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADID,
1678                                    finderArgs, this);
1679    
1680                    if (count == null) {
1681                            StringBundler query = new StringBundler(2);
1682    
1683                            query.append(_SQL_COUNT_MBTHREADFLAG_WHERE);
1684    
1685                            query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1686    
1687                            String sql = query.toString();
1688    
1689                            Session session = null;
1690    
1691                            try {
1692                                    session = openSession();
1693    
1694                                    Query q = session.createQuery(sql);
1695    
1696                                    QueryPos qPos = QueryPos.getInstance(q);
1697    
1698                                    qPos.add(threadId);
1699    
1700                                    count = (Long)q.uniqueResult();
1701                            }
1702                            catch (Exception e) {
1703                                    throw processException(e);
1704                            }
1705                            finally {
1706                                    if (count == null) {
1707                                            count = Long.valueOf(0);
1708                                    }
1709    
1710                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADID,
1711                                            finderArgs, count);
1712    
1713                                    closeSession(session);
1714                            }
1715                    }
1716    
1717                    return count.intValue();
1718            }
1719    
1720            /**
1721             * Returns the number of message boards thread flags where userId = &#63; and threadId = &#63;.
1722             *
1723             * @param userId the user ID
1724             * @param threadId the thread ID
1725             * @return the number of matching message boards thread flags
1726             * @throws SystemException if a system exception occurred
1727             */
1728            public int countByU_T(long userId, long threadId) throws SystemException {
1729                    Object[] finderArgs = new Object[] { userId, threadId };
1730    
1731                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_T,
1732                                    finderArgs, this);
1733    
1734                    if (count == null) {
1735                            StringBundler query = new StringBundler(3);
1736    
1737                            query.append(_SQL_COUNT_MBTHREADFLAG_WHERE);
1738    
1739                            query.append(_FINDER_COLUMN_U_T_USERID_2);
1740    
1741                            query.append(_FINDER_COLUMN_U_T_THREADID_2);
1742    
1743                            String sql = query.toString();
1744    
1745                            Session session = null;
1746    
1747                            try {
1748                                    session = openSession();
1749    
1750                                    Query q = session.createQuery(sql);
1751    
1752                                    QueryPos qPos = QueryPos.getInstance(q);
1753    
1754                                    qPos.add(userId);
1755    
1756                                    qPos.add(threadId);
1757    
1758                                    count = (Long)q.uniqueResult();
1759                            }
1760                            catch (Exception e) {
1761                                    throw processException(e);
1762                            }
1763                            finally {
1764                                    if (count == null) {
1765                                            count = Long.valueOf(0);
1766                                    }
1767    
1768                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_T, finderArgs,
1769                                            count);
1770    
1771                                    closeSession(session);
1772                            }
1773                    }
1774    
1775                    return count.intValue();
1776            }
1777    
1778            /**
1779             * Returns the number of message boards thread flags.
1780             *
1781             * @return the number of message boards thread flags
1782             * @throws SystemException if a system exception occurred
1783             */
1784            public int countAll() throws SystemException {
1785                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1786                                    FINDER_ARGS_EMPTY, this);
1787    
1788                    if (count == null) {
1789                            Session session = null;
1790    
1791                            try {
1792                                    session = openSession();
1793    
1794                                    Query q = session.createQuery(_SQL_COUNT_MBTHREADFLAG);
1795    
1796                                    count = (Long)q.uniqueResult();
1797                            }
1798                            catch (Exception e) {
1799                                    throw processException(e);
1800                            }
1801                            finally {
1802                                    if (count == null) {
1803                                            count = Long.valueOf(0);
1804                                    }
1805    
1806                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1807                                            FINDER_ARGS_EMPTY, count);
1808    
1809                                    closeSession(session);
1810                            }
1811                    }
1812    
1813                    return count.intValue();
1814            }
1815    
1816            /**
1817             * Initializes the message boards thread flag persistence.
1818             */
1819            public void afterPropertiesSet() {
1820                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1821                                            com.liferay.portal.util.PropsUtil.get(
1822                                                    "value.object.listener.com.liferay.portlet.messageboards.model.MBThreadFlag")));
1823    
1824                    if (listenerClassNames.length > 0) {
1825                            try {
1826                                    List<ModelListener<MBThreadFlag>> listenersList = new ArrayList<ModelListener<MBThreadFlag>>();
1827    
1828                                    for (String listenerClassName : listenerClassNames) {
1829                                            listenersList.add((ModelListener<MBThreadFlag>)InstanceFactory.newInstance(
1830                                                            listenerClassName));
1831                                    }
1832    
1833                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1834                            }
1835                            catch (Exception e) {
1836                                    _log.error(e);
1837                            }
1838                    }
1839            }
1840    
1841            public void destroy() {
1842                    EntityCacheUtil.removeCache(MBThreadFlagImpl.class.getName());
1843                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1844                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1845            }
1846    
1847            @BeanReference(type = MBBanPersistence.class)
1848            protected MBBanPersistence mbBanPersistence;
1849            @BeanReference(type = MBCategoryPersistence.class)
1850            protected MBCategoryPersistence mbCategoryPersistence;
1851            @BeanReference(type = MBDiscussionPersistence.class)
1852            protected MBDiscussionPersistence mbDiscussionPersistence;
1853            @BeanReference(type = MBMailingListPersistence.class)
1854            protected MBMailingListPersistence mbMailingListPersistence;
1855            @BeanReference(type = MBMessagePersistence.class)
1856            protected MBMessagePersistence mbMessagePersistence;
1857            @BeanReference(type = MBStatsUserPersistence.class)
1858            protected MBStatsUserPersistence mbStatsUserPersistence;
1859            @BeanReference(type = MBThreadPersistence.class)
1860            protected MBThreadPersistence mbThreadPersistence;
1861            @BeanReference(type = MBThreadFlagPersistence.class)
1862            protected MBThreadFlagPersistence mbThreadFlagPersistence;
1863            @BeanReference(type = UserPersistence.class)
1864            protected UserPersistence userPersistence;
1865            private static final String _SQL_SELECT_MBTHREADFLAG = "SELECT mbThreadFlag FROM MBThreadFlag mbThreadFlag";
1866            private static final String _SQL_SELECT_MBTHREADFLAG_WHERE = "SELECT mbThreadFlag FROM MBThreadFlag mbThreadFlag WHERE ";
1867            private static final String _SQL_COUNT_MBTHREADFLAG = "SELECT COUNT(mbThreadFlag) FROM MBThreadFlag mbThreadFlag";
1868            private static final String _SQL_COUNT_MBTHREADFLAG_WHERE = "SELECT COUNT(mbThreadFlag) FROM MBThreadFlag mbThreadFlag WHERE ";
1869            private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbThreadFlag.userId = ?";
1870            private static final String _FINDER_COLUMN_THREADID_THREADID_2 = "mbThreadFlag.threadId = ?";
1871            private static final String _FINDER_COLUMN_U_T_USERID_2 = "mbThreadFlag.userId = ? AND ";
1872            private static final String _FINDER_COLUMN_U_T_THREADID_2 = "mbThreadFlag.threadId = ?";
1873            private static final String _ORDER_BY_ENTITY_ALIAS = "mbThreadFlag.";
1874            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBThreadFlag exists with the primary key ";
1875            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBThreadFlag exists with the key {";
1876            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1877            private static Log _log = LogFactoryUtil.getLog(MBThreadFlagPersistenceImpl.class);
1878            private static MBThreadFlag _nullMBThreadFlag = new MBThreadFlagImpl() {
1879                            @Override
1880                            public Object clone() {
1881                                    return this;
1882                            }
1883    
1884                            @Override
1885                            public CacheModel<MBThreadFlag> toCacheModel() {
1886                                    return _nullMBThreadFlagCacheModel;
1887                            }
1888                    };
1889    
1890            private static CacheModel<MBThreadFlag> _nullMBThreadFlagCacheModel = new CacheModel<MBThreadFlag>() {
1891                            public MBThreadFlag toEntityModel() {
1892                                    return _nullMBThreadFlag;
1893                            }
1894                    };
1895    }