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