001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.messageboards.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.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_WITH_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_WITHOUT_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    
416                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T, args);
417    
418                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
419                                            new Object[] {
420                                                    Long.valueOf(mbThreadFlag.getUserId()),
421                                                    Long.valueOf(mbThreadFlag.getThreadId())
422                                            }, mbThreadFlag);
423                            }
424                    }
425    
426                    return mbThreadFlag;
427            }
428    
429            protected MBThreadFlag toUnwrappedModel(MBThreadFlag mbThreadFlag) {
430                    if (mbThreadFlag instanceof MBThreadFlagImpl) {
431                            return mbThreadFlag;
432                    }
433    
434                    MBThreadFlagImpl mbThreadFlagImpl = new MBThreadFlagImpl();
435    
436                    mbThreadFlagImpl.setNew(mbThreadFlag.isNew());
437                    mbThreadFlagImpl.setPrimaryKey(mbThreadFlag.getPrimaryKey());
438    
439                    mbThreadFlagImpl.setThreadFlagId(mbThreadFlag.getThreadFlagId());
440                    mbThreadFlagImpl.setUserId(mbThreadFlag.getUserId());
441                    mbThreadFlagImpl.setModifiedDate(mbThreadFlag.getModifiedDate());
442                    mbThreadFlagImpl.setThreadId(mbThreadFlag.getThreadId());
443    
444                    return mbThreadFlagImpl;
445            }
446    
447            /**
448             * Returns the message boards thread flag with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
449             *
450             * @param primaryKey the primary key of the message boards thread flag
451             * @return the message boards thread flag
452             * @throws com.liferay.portal.NoSuchModelException if a message boards thread flag with the primary key could not be found
453             * @throws SystemException if a system exception occurred
454             */
455            @Override
456            public MBThreadFlag findByPrimaryKey(Serializable primaryKey)
457                    throws NoSuchModelException, SystemException {
458                    return findByPrimaryKey(((Long)primaryKey).longValue());
459            }
460    
461            /**
462             * 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.
463             *
464             * @param threadFlagId the primary key of the message boards thread flag
465             * @return the message boards thread flag
466             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a message boards thread flag with the primary key could not be found
467             * @throws SystemException if a system exception occurred
468             */
469            public MBThreadFlag findByPrimaryKey(long threadFlagId)
470                    throws NoSuchThreadFlagException, SystemException {
471                    MBThreadFlag mbThreadFlag = fetchByPrimaryKey(threadFlagId);
472    
473                    if (mbThreadFlag == null) {
474                            if (_log.isWarnEnabled()) {
475                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + threadFlagId);
476                            }
477    
478                            throw new NoSuchThreadFlagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
479                                    threadFlagId);
480                    }
481    
482                    return mbThreadFlag;
483            }
484    
485            /**
486             * Returns the message boards thread flag with the primary key or returns <code>null</code> if it could not be found.
487             *
488             * @param primaryKey the primary key of the message boards thread flag
489             * @return the message boards thread flag, or <code>null</code> if a message boards thread flag with the primary key could not be found
490             * @throws SystemException if a system exception occurred
491             */
492            @Override
493            public MBThreadFlag fetchByPrimaryKey(Serializable primaryKey)
494                    throws SystemException {
495                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
496            }
497    
498            /**
499             * Returns the message boards thread flag with the primary key or returns <code>null</code> if it could not be found.
500             *
501             * @param threadFlagId the primary key of the message boards thread flag
502             * @return the message boards thread flag, or <code>null</code> if a message boards thread flag with the primary key could not be found
503             * @throws SystemException if a system exception occurred
504             */
505            public MBThreadFlag fetchByPrimaryKey(long threadFlagId)
506                    throws SystemException {
507                    MBThreadFlag mbThreadFlag = (MBThreadFlag)EntityCacheUtil.getResult(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
508                                    MBThreadFlagImpl.class, threadFlagId);
509    
510                    if (mbThreadFlag == _nullMBThreadFlag) {
511                            return null;
512                    }
513    
514                    if (mbThreadFlag == null) {
515                            Session session = null;
516    
517                            boolean hasException = false;
518    
519                            try {
520                                    session = openSession();
521    
522                                    mbThreadFlag = (MBThreadFlag)session.get(MBThreadFlagImpl.class,
523                                                    Long.valueOf(threadFlagId));
524                            }
525                            catch (Exception e) {
526                                    hasException = true;
527    
528                                    throw processException(e);
529                            }
530                            finally {
531                                    if (mbThreadFlag != null) {
532                                            cacheResult(mbThreadFlag);
533                                    }
534                                    else if (!hasException) {
535                                            EntityCacheUtil.putResult(MBThreadFlagModelImpl.ENTITY_CACHE_ENABLED,
536                                                    MBThreadFlagImpl.class, threadFlagId, _nullMBThreadFlag);
537                                    }
538    
539                                    closeSession(session);
540                            }
541                    }
542    
543                    return mbThreadFlag;
544            }
545    
546            /**
547             * Returns all the message boards thread flags where userId = &#63;.
548             *
549             * @param userId the user ID
550             * @return the matching message boards thread flags
551             * @throws SystemException if a system exception occurred
552             */
553            public List<MBThreadFlag> findByUserId(long userId)
554                    throws SystemException {
555                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
556            }
557    
558            /**
559             * Returns a range of all the message boards thread flags where userId = &#63;.
560             *
561             * <p>
562             * 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.
563             * </p>
564             *
565             * @param userId the user ID
566             * @param start the lower bound of the range of message boards thread flags
567             * @param end the upper bound of the range of message boards thread flags (not inclusive)
568             * @return the range of matching message boards thread flags
569             * @throws SystemException if a system exception occurred
570             */
571            public List<MBThreadFlag> findByUserId(long userId, int start, int end)
572                    throws SystemException {
573                    return findByUserId(userId, start, end, null);
574            }
575    
576            /**
577             * Returns an ordered range of all the message boards thread flags where userId = &#63;.
578             *
579             * <p>
580             * 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.
581             * </p>
582             *
583             * @param userId the user ID
584             * @param start the lower bound of the range of message boards thread flags
585             * @param end the upper bound of the range of message boards thread flags (not inclusive)
586             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
587             * @return the ordered range of matching message boards thread flags
588             * @throws SystemException if a system exception occurred
589             */
590            public List<MBThreadFlag> findByUserId(long userId, int start, int end,
591                    OrderByComparator orderByComparator) throws SystemException {
592                    FinderPath finderPath = null;
593                    Object[] finderArgs = null;
594    
595                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
596                                    (orderByComparator == null)) {
597                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
598                            finderArgs = new Object[] { userId };
599                    }
600                    else {
601                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
602                            finderArgs = new Object[] { userId, start, end, orderByComparator };
603                    }
604    
605                    List<MBThreadFlag> list = (List<MBThreadFlag>)FinderCacheUtil.getResult(finderPath,
606                                    finderArgs, this);
607    
608                    if ((list != null) && !list.isEmpty()) {
609                            for (MBThreadFlag mbThreadFlag : list) {
610                                    if ((userId != mbThreadFlag.getUserId())) {
611                                            list = null;
612    
613                                            break;
614                                    }
615                            }
616                    }
617    
618                    if (list == null) {
619                            StringBundler query = null;
620    
621                            if (orderByComparator != null) {
622                                    query = new StringBundler(3 +
623                                                    (orderByComparator.getOrderByFields().length * 3));
624                            }
625                            else {
626                                    query = new StringBundler(2);
627                            }
628    
629                            query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
630    
631                            query.append(_FINDER_COLUMN_USERID_USERID_2);
632    
633                            if (orderByComparator != null) {
634                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
635                                            orderByComparator);
636                            }
637    
638                            String sql = query.toString();
639    
640                            Session session = null;
641    
642                            try {
643                                    session = openSession();
644    
645                                    Query q = session.createQuery(sql);
646    
647                                    QueryPos qPos = QueryPos.getInstance(q);
648    
649                                    qPos.add(userId);
650    
651                                    list = (List<MBThreadFlag>)QueryUtil.list(q, getDialect(),
652                                                    start, end);
653                            }
654                            catch (Exception e) {
655                                    throw processException(e);
656                            }
657                            finally {
658                                    if (list == null) {
659                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
660                                    }
661                                    else {
662                                            cacheResult(list);
663    
664                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
665                                    }
666    
667                                    closeSession(session);
668                            }
669                    }
670    
671                    return list;
672            }
673    
674            /**
675             * Returns the first message boards thread flag in the ordered set where userId = &#63;.
676             *
677             * @param userId the user ID
678             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
679             * @return the first matching message boards thread flag
680             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
681             * @throws SystemException if a system exception occurred
682             */
683            public MBThreadFlag findByUserId_First(long userId,
684                    OrderByComparator orderByComparator)
685                    throws NoSuchThreadFlagException, SystemException {
686                    MBThreadFlag mbThreadFlag = fetchByUserId_First(userId,
687                                    orderByComparator);
688    
689                    if (mbThreadFlag != null) {
690                            return mbThreadFlag;
691                    }
692    
693                    StringBundler msg = new StringBundler(4);
694    
695                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
696    
697                    msg.append("userId=");
698                    msg.append(userId);
699    
700                    msg.append(StringPool.CLOSE_CURLY_BRACE);
701    
702                    throw new NoSuchThreadFlagException(msg.toString());
703            }
704    
705            /**
706             * Returns the first message boards thread flag in the ordered set where userId = &#63;.
707             *
708             * @param userId the user ID
709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
710             * @return the first matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
711             * @throws SystemException if a system exception occurred
712             */
713            public MBThreadFlag fetchByUserId_First(long userId,
714                    OrderByComparator orderByComparator) throws SystemException {
715                    List<MBThreadFlag> list = findByUserId(userId, 0, 1, orderByComparator);
716    
717                    if (!list.isEmpty()) {
718                            return list.get(0);
719                    }
720    
721                    return null;
722            }
723    
724            /**
725             * Returns the last message boards thread flag in the ordered set where userId = &#63;.
726             *
727             * @param userId the user ID
728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
729             * @return the last matching message boards thread flag
730             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
731             * @throws SystemException if a system exception occurred
732             */
733            public MBThreadFlag findByUserId_Last(long userId,
734                    OrderByComparator orderByComparator)
735                    throws NoSuchThreadFlagException, SystemException {
736                    MBThreadFlag mbThreadFlag = fetchByUserId_Last(userId, orderByComparator);
737    
738                    if (mbThreadFlag != null) {
739                            return mbThreadFlag;
740                    }
741    
742                    StringBundler msg = new StringBundler(4);
743    
744                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
745    
746                    msg.append("userId=");
747                    msg.append(userId);
748    
749                    msg.append(StringPool.CLOSE_CURLY_BRACE);
750    
751                    throw new NoSuchThreadFlagException(msg.toString());
752            }
753    
754            /**
755             * Returns the last message boards thread flag in the ordered set where userId = &#63;.
756             *
757             * @param userId the user ID
758             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
759             * @return the last matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
760             * @throws SystemException if a system exception occurred
761             */
762            public MBThreadFlag fetchByUserId_Last(long userId,
763                    OrderByComparator orderByComparator) throws SystemException {
764                    int count = countByUserId(userId);
765    
766                    List<MBThreadFlag> list = findByUserId(userId, count - 1, count,
767                                    orderByComparator);
768    
769                    if (!list.isEmpty()) {
770                            return list.get(0);
771                    }
772    
773                    return null;
774            }
775    
776            /**
777             * Returns the message boards thread flags before and after the current message boards thread flag in the ordered set where userId = &#63;.
778             *
779             * @param threadFlagId the primary key of the current message boards thread flag
780             * @param userId the user ID
781             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
782             * @return the previous, current, and next message boards thread flag
783             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a message boards thread flag with the primary key could not be found
784             * @throws SystemException if a system exception occurred
785             */
786            public MBThreadFlag[] findByUserId_PrevAndNext(long threadFlagId,
787                    long userId, OrderByComparator orderByComparator)
788                    throws NoSuchThreadFlagException, SystemException {
789                    MBThreadFlag mbThreadFlag = findByPrimaryKey(threadFlagId);
790    
791                    Session session = null;
792    
793                    try {
794                            session = openSession();
795    
796                            MBThreadFlag[] array = new MBThreadFlagImpl[3];
797    
798                            array[0] = getByUserId_PrevAndNext(session, mbThreadFlag, userId,
799                                            orderByComparator, true);
800    
801                            array[1] = mbThreadFlag;
802    
803                            array[2] = getByUserId_PrevAndNext(session, mbThreadFlag, userId,
804                                            orderByComparator, false);
805    
806                            return array;
807                    }
808                    catch (Exception e) {
809                            throw processException(e);
810                    }
811                    finally {
812                            closeSession(session);
813                    }
814            }
815    
816            protected MBThreadFlag getByUserId_PrevAndNext(Session session,
817                    MBThreadFlag mbThreadFlag, long userId,
818                    OrderByComparator orderByComparator, boolean previous) {
819                    StringBundler query = null;
820    
821                    if (orderByComparator != null) {
822                            query = new StringBundler(6 +
823                                            (orderByComparator.getOrderByFields().length * 6));
824                    }
825                    else {
826                            query = new StringBundler(3);
827                    }
828    
829                    query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
830    
831                    query.append(_FINDER_COLUMN_USERID_USERID_2);
832    
833                    if (orderByComparator != null) {
834                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
835    
836                            if (orderByConditionFields.length > 0) {
837                                    query.append(WHERE_AND);
838                            }
839    
840                            for (int i = 0; i < orderByConditionFields.length; i++) {
841                                    query.append(_ORDER_BY_ENTITY_ALIAS);
842                                    query.append(orderByConditionFields[i]);
843    
844                                    if ((i + 1) < orderByConditionFields.length) {
845                                            if (orderByComparator.isAscending() ^ previous) {
846                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
847                                            }
848                                            else {
849                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
850                                            }
851                                    }
852                                    else {
853                                            if (orderByComparator.isAscending() ^ previous) {
854                                                    query.append(WHERE_GREATER_THAN);
855                                            }
856                                            else {
857                                                    query.append(WHERE_LESSER_THAN);
858                                            }
859                                    }
860                            }
861    
862                            query.append(ORDER_BY_CLAUSE);
863    
864                            String[] orderByFields = orderByComparator.getOrderByFields();
865    
866                            for (int i = 0; i < orderByFields.length; i++) {
867                                    query.append(_ORDER_BY_ENTITY_ALIAS);
868                                    query.append(orderByFields[i]);
869    
870                                    if ((i + 1) < orderByFields.length) {
871                                            if (orderByComparator.isAscending() ^ previous) {
872                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
873                                            }
874                                            else {
875                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
876                                            }
877                                    }
878                                    else {
879                                            if (orderByComparator.isAscending() ^ previous) {
880                                                    query.append(ORDER_BY_ASC);
881                                            }
882                                            else {
883                                                    query.append(ORDER_BY_DESC);
884                                            }
885                                    }
886                            }
887                    }
888    
889                    String sql = query.toString();
890    
891                    Query q = session.createQuery(sql);
892    
893                    q.setFirstResult(0);
894                    q.setMaxResults(2);
895    
896                    QueryPos qPos = QueryPos.getInstance(q);
897    
898                    qPos.add(userId);
899    
900                    if (orderByComparator != null) {
901                            Object[] values = orderByComparator.getOrderByConditionValues(mbThreadFlag);
902    
903                            for (Object value : values) {
904                                    qPos.add(value);
905                            }
906                    }
907    
908                    List<MBThreadFlag> list = q.list();
909    
910                    if (list.size() == 2) {
911                            return list.get(1);
912                    }
913                    else {
914                            return null;
915                    }
916            }
917    
918            /**
919             * Returns all the message boards thread flags where threadId = &#63;.
920             *
921             * @param threadId the thread ID
922             * @return the matching message boards thread flags
923             * @throws SystemException if a system exception occurred
924             */
925            public List<MBThreadFlag> findByThreadId(long threadId)
926                    throws SystemException {
927                    return findByThreadId(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
928                            null);
929            }
930    
931            /**
932             * Returns a range of all the message boards thread flags where threadId = &#63;.
933             *
934             * <p>
935             * 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.
936             * </p>
937             *
938             * @param threadId the thread ID
939             * @param start the lower bound of the range of message boards thread flags
940             * @param end the upper bound of the range of message boards thread flags (not inclusive)
941             * @return the range of matching message boards thread flags
942             * @throws SystemException if a system exception occurred
943             */
944            public List<MBThreadFlag> findByThreadId(long threadId, int start, int end)
945                    throws SystemException {
946                    return findByThreadId(threadId, start, end, null);
947            }
948    
949            /**
950             * Returns an ordered range of all the message boards thread flags where threadId = &#63;.
951             *
952             * <p>
953             * 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.
954             * </p>
955             *
956             * @param threadId the thread ID
957             * @param start the lower bound of the range of message boards thread flags
958             * @param end the upper bound of the range of message boards thread flags (not inclusive)
959             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
960             * @return the ordered range of matching message boards thread flags
961             * @throws SystemException if a system exception occurred
962             */
963            public List<MBThreadFlag> findByThreadId(long threadId, int start, int end,
964                    OrderByComparator orderByComparator) throws SystemException {
965                    FinderPath finderPath = null;
966                    Object[] finderArgs = null;
967    
968                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
969                                    (orderByComparator == null)) {
970                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID;
971                            finderArgs = new Object[] { threadId };
972                    }
973                    else {
974                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADID;
975                            finderArgs = new Object[] { threadId, start, end, orderByComparator };
976                    }
977    
978                    List<MBThreadFlag> list = (List<MBThreadFlag>)FinderCacheUtil.getResult(finderPath,
979                                    finderArgs, this);
980    
981                    if ((list != null) && !list.isEmpty()) {
982                            for (MBThreadFlag mbThreadFlag : list) {
983                                    if ((threadId != mbThreadFlag.getThreadId())) {
984                                            list = null;
985    
986                                            break;
987                                    }
988                            }
989                    }
990    
991                    if (list == null) {
992                            StringBundler query = null;
993    
994                            if (orderByComparator != null) {
995                                    query = new StringBundler(3 +
996                                                    (orderByComparator.getOrderByFields().length * 3));
997                            }
998                            else {
999                                    query = new StringBundler(2);
1000                            }
1001    
1002                            query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
1003    
1004                            query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1005    
1006                            if (orderByComparator != null) {
1007                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1008                                            orderByComparator);
1009                            }
1010    
1011                            String sql = query.toString();
1012    
1013                            Session session = null;
1014    
1015                            try {
1016                                    session = openSession();
1017    
1018                                    Query q = session.createQuery(sql);
1019    
1020                                    QueryPos qPos = QueryPos.getInstance(q);
1021    
1022                                    qPos.add(threadId);
1023    
1024                                    list = (List<MBThreadFlag>)QueryUtil.list(q, getDialect(),
1025                                                    start, end);
1026                            }
1027                            catch (Exception e) {
1028                                    throw processException(e);
1029                            }
1030                            finally {
1031                                    if (list == null) {
1032                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1033                                    }
1034                                    else {
1035                                            cacheResult(list);
1036    
1037                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1038                                    }
1039    
1040                                    closeSession(session);
1041                            }
1042                    }
1043    
1044                    return list;
1045            }
1046    
1047            /**
1048             * Returns the first message boards thread flag in the ordered set where threadId = &#63;.
1049             *
1050             * @param threadId the thread ID
1051             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1052             * @return the first matching message boards thread flag
1053             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
1054             * @throws SystemException if a system exception occurred
1055             */
1056            public MBThreadFlag findByThreadId_First(long threadId,
1057                    OrderByComparator orderByComparator)
1058                    throws NoSuchThreadFlagException, SystemException {
1059                    MBThreadFlag mbThreadFlag = fetchByThreadId_First(threadId,
1060                                    orderByComparator);
1061    
1062                    if (mbThreadFlag != null) {
1063                            return mbThreadFlag;
1064                    }
1065    
1066                    StringBundler msg = new StringBundler(4);
1067    
1068                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1069    
1070                    msg.append("threadId=");
1071                    msg.append(threadId);
1072    
1073                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1074    
1075                    throw new NoSuchThreadFlagException(msg.toString());
1076            }
1077    
1078            /**
1079             * Returns the first message boards thread flag in the ordered set where threadId = &#63;.
1080             *
1081             * @param threadId the thread ID
1082             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1083             * @return the first matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
1084             * @throws SystemException if a system exception occurred
1085             */
1086            public MBThreadFlag fetchByThreadId_First(long threadId,
1087                    OrderByComparator orderByComparator) throws SystemException {
1088                    List<MBThreadFlag> list = findByThreadId(threadId, 0, 1,
1089                                    orderByComparator);
1090    
1091                    if (!list.isEmpty()) {
1092                            return list.get(0);
1093                    }
1094    
1095                    return null;
1096            }
1097    
1098            /**
1099             * Returns the last message boards thread flag in the ordered set where threadId = &#63;.
1100             *
1101             * @param threadId the thread ID
1102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1103             * @return the last matching message boards thread flag
1104             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
1105             * @throws SystemException if a system exception occurred
1106             */
1107            public MBThreadFlag findByThreadId_Last(long threadId,
1108                    OrderByComparator orderByComparator)
1109                    throws NoSuchThreadFlagException, SystemException {
1110                    MBThreadFlag mbThreadFlag = fetchByThreadId_Last(threadId,
1111                                    orderByComparator);
1112    
1113                    if (mbThreadFlag != null) {
1114                            return mbThreadFlag;
1115                    }
1116    
1117                    StringBundler msg = new StringBundler(4);
1118    
1119                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1120    
1121                    msg.append("threadId=");
1122                    msg.append(threadId);
1123    
1124                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1125    
1126                    throw new NoSuchThreadFlagException(msg.toString());
1127            }
1128    
1129            /**
1130             * Returns the last message boards thread flag in the ordered set where threadId = &#63;.
1131             *
1132             * @param threadId the thread ID
1133             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1134             * @return the last matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
1135             * @throws SystemException if a system exception occurred
1136             */
1137            public MBThreadFlag fetchByThreadId_Last(long threadId,
1138                    OrderByComparator orderByComparator) throws SystemException {
1139                    int count = countByThreadId(threadId);
1140    
1141                    List<MBThreadFlag> list = findByThreadId(threadId, count - 1, count,
1142                                    orderByComparator);
1143    
1144                    if (!list.isEmpty()) {
1145                            return list.get(0);
1146                    }
1147    
1148                    return null;
1149            }
1150    
1151            /**
1152             * Returns the message boards thread flags before and after the current message boards thread flag in the ordered set where threadId = &#63;.
1153             *
1154             * @param threadFlagId the primary key of the current message boards thread flag
1155             * @param threadId the thread ID
1156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1157             * @return the previous, current, and next message boards thread flag
1158             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a message boards thread flag with the primary key could not be found
1159             * @throws SystemException if a system exception occurred
1160             */
1161            public MBThreadFlag[] findByThreadId_PrevAndNext(long threadFlagId,
1162                    long threadId, OrderByComparator orderByComparator)
1163                    throws NoSuchThreadFlagException, SystemException {
1164                    MBThreadFlag mbThreadFlag = findByPrimaryKey(threadFlagId);
1165    
1166                    Session session = null;
1167    
1168                    try {
1169                            session = openSession();
1170    
1171                            MBThreadFlag[] array = new MBThreadFlagImpl[3];
1172    
1173                            array[0] = getByThreadId_PrevAndNext(session, mbThreadFlag,
1174                                            threadId, orderByComparator, true);
1175    
1176                            array[1] = mbThreadFlag;
1177    
1178                            array[2] = getByThreadId_PrevAndNext(session, mbThreadFlag,
1179                                            threadId, orderByComparator, false);
1180    
1181                            return array;
1182                    }
1183                    catch (Exception e) {
1184                            throw processException(e);
1185                    }
1186                    finally {
1187                            closeSession(session);
1188                    }
1189            }
1190    
1191            protected MBThreadFlag getByThreadId_PrevAndNext(Session session,
1192                    MBThreadFlag mbThreadFlag, long threadId,
1193                    OrderByComparator orderByComparator, boolean previous) {
1194                    StringBundler query = null;
1195    
1196                    if (orderByComparator != null) {
1197                            query = new StringBundler(6 +
1198                                            (orderByComparator.getOrderByFields().length * 6));
1199                    }
1200                    else {
1201                            query = new StringBundler(3);
1202                    }
1203    
1204                    query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
1205    
1206                    query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1207    
1208                    if (orderByComparator != null) {
1209                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1210    
1211                            if (orderByConditionFields.length > 0) {
1212                                    query.append(WHERE_AND);
1213                            }
1214    
1215                            for (int i = 0; i < orderByConditionFields.length; i++) {
1216                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1217                                    query.append(orderByConditionFields[i]);
1218    
1219                                    if ((i + 1) < orderByConditionFields.length) {
1220                                            if (orderByComparator.isAscending() ^ previous) {
1221                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1222                                            }
1223                                            else {
1224                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1225                                            }
1226                                    }
1227                                    else {
1228                                            if (orderByComparator.isAscending() ^ previous) {
1229                                                    query.append(WHERE_GREATER_THAN);
1230                                            }
1231                                            else {
1232                                                    query.append(WHERE_LESSER_THAN);
1233                                            }
1234                                    }
1235                            }
1236    
1237                            query.append(ORDER_BY_CLAUSE);
1238    
1239                            String[] orderByFields = orderByComparator.getOrderByFields();
1240    
1241                            for (int i = 0; i < orderByFields.length; i++) {
1242                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1243                                    query.append(orderByFields[i]);
1244    
1245                                    if ((i + 1) < orderByFields.length) {
1246                                            if (orderByComparator.isAscending() ^ previous) {
1247                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1248                                            }
1249                                            else {
1250                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1251                                            }
1252                                    }
1253                                    else {
1254                                            if (orderByComparator.isAscending() ^ previous) {
1255                                                    query.append(ORDER_BY_ASC);
1256                                            }
1257                                            else {
1258                                                    query.append(ORDER_BY_DESC);
1259                                            }
1260                                    }
1261                            }
1262                    }
1263    
1264                    String sql = query.toString();
1265    
1266                    Query q = session.createQuery(sql);
1267    
1268                    q.setFirstResult(0);
1269                    q.setMaxResults(2);
1270    
1271                    QueryPos qPos = QueryPos.getInstance(q);
1272    
1273                    qPos.add(threadId);
1274    
1275                    if (orderByComparator != null) {
1276                            Object[] values = orderByComparator.getOrderByConditionValues(mbThreadFlag);
1277    
1278                            for (Object value : values) {
1279                                    qPos.add(value);
1280                            }
1281                    }
1282    
1283                    List<MBThreadFlag> list = q.list();
1284    
1285                    if (list.size() == 2) {
1286                            return list.get(1);
1287                    }
1288                    else {
1289                            return null;
1290                    }
1291            }
1292    
1293            /**
1294             * 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.
1295             *
1296             * @param userId the user ID
1297             * @param threadId the thread ID
1298             * @return the matching message boards thread flag
1299             * @throws com.liferay.portlet.messageboards.NoSuchThreadFlagException if a matching message boards thread flag could not be found
1300             * @throws SystemException if a system exception occurred
1301             */
1302            public MBThreadFlag findByU_T(long userId, long threadId)
1303                    throws NoSuchThreadFlagException, SystemException {
1304                    MBThreadFlag mbThreadFlag = fetchByU_T(userId, threadId);
1305    
1306                    if (mbThreadFlag == null) {
1307                            StringBundler msg = new StringBundler(6);
1308    
1309                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1310    
1311                            msg.append("userId=");
1312                            msg.append(userId);
1313    
1314                            msg.append(", threadId=");
1315                            msg.append(threadId);
1316    
1317                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1318    
1319                            if (_log.isWarnEnabled()) {
1320                                    _log.warn(msg.toString());
1321                            }
1322    
1323                            throw new NoSuchThreadFlagException(msg.toString());
1324                    }
1325    
1326                    return mbThreadFlag;
1327            }
1328    
1329            /**
1330             * 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.
1331             *
1332             * @param userId the user ID
1333             * @param threadId the thread ID
1334             * @return the matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
1335             * @throws SystemException if a system exception occurred
1336             */
1337            public MBThreadFlag fetchByU_T(long userId, long threadId)
1338                    throws SystemException {
1339                    return fetchByU_T(userId, threadId, true);
1340            }
1341    
1342            /**
1343             * 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.
1344             *
1345             * @param userId the user ID
1346             * @param threadId the thread ID
1347             * @param retrieveFromCache whether to use the finder cache
1348             * @return the matching message boards thread flag, or <code>null</code> if a matching message boards thread flag could not be found
1349             * @throws SystemException if a system exception occurred
1350             */
1351            public MBThreadFlag fetchByU_T(long userId, long threadId,
1352                    boolean retrieveFromCache) throws SystemException {
1353                    Object[] finderArgs = new Object[] { userId, threadId };
1354    
1355                    Object result = null;
1356    
1357                    if (retrieveFromCache) {
1358                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_T,
1359                                            finderArgs, this);
1360                    }
1361    
1362                    if (result instanceof MBThreadFlag) {
1363                            MBThreadFlag mbThreadFlag = (MBThreadFlag)result;
1364    
1365                            if ((userId != mbThreadFlag.getUserId()) ||
1366                                            (threadId != mbThreadFlag.getThreadId())) {
1367                                    result = null;
1368                            }
1369                    }
1370    
1371                    if (result == null) {
1372                            StringBundler query = new StringBundler(3);
1373    
1374                            query.append(_SQL_SELECT_MBTHREADFLAG_WHERE);
1375    
1376                            query.append(_FINDER_COLUMN_U_T_USERID_2);
1377    
1378                            query.append(_FINDER_COLUMN_U_T_THREADID_2);
1379    
1380                            String sql = query.toString();
1381    
1382                            Session session = null;
1383    
1384                            try {
1385                                    session = openSession();
1386    
1387                                    Query q = session.createQuery(sql);
1388    
1389                                    QueryPos qPos = QueryPos.getInstance(q);
1390    
1391                                    qPos.add(userId);
1392    
1393                                    qPos.add(threadId);
1394    
1395                                    List<MBThreadFlag> list = q.list();
1396    
1397                                    result = list;
1398    
1399                                    MBThreadFlag mbThreadFlag = null;
1400    
1401                                    if (list.isEmpty()) {
1402                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
1403                                                    finderArgs, list);
1404                                    }
1405                                    else {
1406                                            mbThreadFlag = list.get(0);
1407    
1408                                            cacheResult(mbThreadFlag);
1409    
1410                                            if ((mbThreadFlag.getUserId() != userId) ||
1411                                                            (mbThreadFlag.getThreadId() != threadId)) {
1412                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
1413                                                            finderArgs, mbThreadFlag);
1414                                            }
1415                                    }
1416    
1417                                    return mbThreadFlag;
1418                            }
1419                            catch (Exception e) {
1420                                    throw processException(e);
1421                            }
1422                            finally {
1423                                    if (result == null) {
1424                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T,
1425                                                    finderArgs);
1426                                    }
1427    
1428                                    closeSession(session);
1429                            }
1430                    }
1431                    else {
1432                            if (result instanceof List<?>) {
1433                                    return null;
1434                            }
1435                            else {
1436                                    return (MBThreadFlag)result;
1437                            }
1438                    }
1439            }
1440    
1441            /**
1442             * Returns all the message boards thread flags.
1443             *
1444             * @return the message boards thread flags
1445             * @throws SystemException if a system exception occurred
1446             */
1447            public List<MBThreadFlag> findAll() throws SystemException {
1448                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1449            }
1450    
1451            /**
1452             * Returns a range of all the message boards thread flags.
1453             *
1454             * <p>
1455             * 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.
1456             * </p>
1457             *
1458             * @param start the lower bound of the range of message boards thread flags
1459             * @param end the upper bound of the range of message boards thread flags (not inclusive)
1460             * @return the range of message boards thread flags
1461             * @throws SystemException if a system exception occurred
1462             */
1463            public List<MBThreadFlag> findAll(int start, int end)
1464                    throws SystemException {
1465                    return findAll(start, end, null);
1466            }
1467    
1468            /**
1469             * Returns an ordered range of all the message boards thread flags.
1470             *
1471             * <p>
1472             * 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.
1473             * </p>
1474             *
1475             * @param start the lower bound of the range of message boards thread flags
1476             * @param end the upper bound of the range of message boards thread flags (not inclusive)
1477             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1478             * @return the ordered range of message boards thread flags
1479             * @throws SystemException if a system exception occurred
1480             */
1481            public List<MBThreadFlag> findAll(int start, int end,
1482                    OrderByComparator orderByComparator) throws SystemException {
1483                    FinderPath finderPath = null;
1484                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1485    
1486                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1487                                    (orderByComparator == null)) {
1488                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1489                            finderArgs = FINDER_ARGS_EMPTY;
1490                    }
1491                    else {
1492                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1493                            finderArgs = new Object[] { start, end, orderByComparator };
1494                    }
1495    
1496                    List<MBThreadFlag> list = (List<MBThreadFlag>)FinderCacheUtil.getResult(finderPath,
1497                                    finderArgs, this);
1498    
1499                    if (list == null) {
1500                            StringBundler query = null;
1501                            String sql = null;
1502    
1503                            if (orderByComparator != null) {
1504                                    query = new StringBundler(2 +
1505                                                    (orderByComparator.getOrderByFields().length * 3));
1506    
1507                                    query.append(_SQL_SELECT_MBTHREADFLAG);
1508    
1509                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1510                                            orderByComparator);
1511    
1512                                    sql = query.toString();
1513                            }
1514                            else {
1515                                    sql = _SQL_SELECT_MBTHREADFLAG;
1516                            }
1517    
1518                            Session session = null;
1519    
1520                            try {
1521                                    session = openSession();
1522    
1523                                    Query q = session.createQuery(sql);
1524    
1525                                    if (orderByComparator == null) {
1526                                            list = (List<MBThreadFlag>)QueryUtil.list(q, getDialect(),
1527                                                            start, end, false);
1528    
1529                                            Collections.sort(list);
1530                                    }
1531                                    else {
1532                                            list = (List<MBThreadFlag>)QueryUtil.list(q, getDialect(),
1533                                                            start, end);
1534                                    }
1535                            }
1536                            catch (Exception e) {
1537                                    throw processException(e);
1538                            }
1539                            finally {
1540                                    if (list == null) {
1541                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1542                                    }
1543                                    else {
1544                                            cacheResult(list);
1545    
1546                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1547                                    }
1548    
1549                                    closeSession(session);
1550                            }
1551                    }
1552    
1553                    return list;
1554            }
1555    
1556            /**
1557             * Removes all the message boards thread flags where userId = &#63; from the database.
1558             *
1559             * @param userId the user ID
1560             * @throws SystemException if a system exception occurred
1561             */
1562            public void removeByUserId(long userId) throws SystemException {
1563                    for (MBThreadFlag mbThreadFlag : findByUserId(userId)) {
1564                            remove(mbThreadFlag);
1565                    }
1566            }
1567    
1568            /**
1569             * Removes all the message boards thread flags where threadId = &#63; from the database.
1570             *
1571             * @param threadId the thread ID
1572             * @throws SystemException if a system exception occurred
1573             */
1574            public void removeByThreadId(long threadId) throws SystemException {
1575                    for (MBThreadFlag mbThreadFlag : findByThreadId(threadId)) {
1576                            remove(mbThreadFlag);
1577                    }
1578            }
1579    
1580            /**
1581             * Removes the message boards thread flag where userId = &#63; and threadId = &#63; from the database.
1582             *
1583             * @param userId the user ID
1584             * @param threadId the thread ID
1585             * @return the message boards thread flag that was removed
1586             * @throws SystemException if a system exception occurred
1587             */
1588            public MBThreadFlag removeByU_T(long userId, long threadId)
1589                    throws NoSuchThreadFlagException, SystemException {
1590                    MBThreadFlag mbThreadFlag = findByU_T(userId, threadId);
1591    
1592                    return remove(mbThreadFlag);
1593            }
1594    
1595            /**
1596             * Removes all the message boards thread flags from the database.
1597             *
1598             * @throws SystemException if a system exception occurred
1599             */
1600            public void removeAll() throws SystemException {
1601                    for (MBThreadFlag mbThreadFlag : findAll()) {
1602                            remove(mbThreadFlag);
1603                    }
1604            }
1605    
1606            /**
1607             * Returns the number of message boards thread flags where userId = &#63;.
1608             *
1609             * @param userId the user ID
1610             * @return the number of matching message boards thread flags
1611             * @throws SystemException if a system exception occurred
1612             */
1613            public int countByUserId(long userId) throws SystemException {
1614                    Object[] finderArgs = new Object[] { userId };
1615    
1616                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1617                                    finderArgs, this);
1618    
1619                    if (count == null) {
1620                            StringBundler query = new StringBundler(2);
1621    
1622                            query.append(_SQL_COUNT_MBTHREADFLAG_WHERE);
1623    
1624                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1625    
1626                            String sql = query.toString();
1627    
1628                            Session session = null;
1629    
1630                            try {
1631                                    session = openSession();
1632    
1633                                    Query q = session.createQuery(sql);
1634    
1635                                    QueryPos qPos = QueryPos.getInstance(q);
1636    
1637                                    qPos.add(userId);
1638    
1639                                    count = (Long)q.uniqueResult();
1640                            }
1641                            catch (Exception e) {
1642                                    throw processException(e);
1643                            }
1644                            finally {
1645                                    if (count == null) {
1646                                            count = Long.valueOf(0);
1647                                    }
1648    
1649                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1650                                            finderArgs, count);
1651    
1652                                    closeSession(session);
1653                            }
1654                    }
1655    
1656                    return count.intValue();
1657            }
1658    
1659            /**
1660             * Returns the number of message boards thread flags where threadId = &#63;.
1661             *
1662             * @param threadId the thread ID
1663             * @return the number of matching message boards thread flags
1664             * @throws SystemException if a system exception occurred
1665             */
1666            public int countByThreadId(long threadId) throws SystemException {
1667                    Object[] finderArgs = new Object[] { threadId };
1668    
1669                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADID,
1670                                    finderArgs, this);
1671    
1672                    if (count == null) {
1673                            StringBundler query = new StringBundler(2);
1674    
1675                            query.append(_SQL_COUNT_MBTHREADFLAG_WHERE);
1676    
1677                            query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1678    
1679                            String sql = query.toString();
1680    
1681                            Session session = null;
1682    
1683                            try {
1684                                    session = openSession();
1685    
1686                                    Query q = session.createQuery(sql);
1687    
1688                                    QueryPos qPos = QueryPos.getInstance(q);
1689    
1690                                    qPos.add(threadId);
1691    
1692                                    count = (Long)q.uniqueResult();
1693                            }
1694                            catch (Exception e) {
1695                                    throw processException(e);
1696                            }
1697                            finally {
1698                                    if (count == null) {
1699                                            count = Long.valueOf(0);
1700                                    }
1701    
1702                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADID,
1703                                            finderArgs, count);
1704    
1705                                    closeSession(session);
1706                            }
1707                    }
1708    
1709                    return count.intValue();
1710            }
1711    
1712            /**
1713             * Returns the number of message boards thread flags where userId = &#63; and threadId = &#63;.
1714             *
1715             * @param userId the user ID
1716             * @param threadId the thread ID
1717             * @return the number of matching message boards thread flags
1718             * @throws SystemException if a system exception occurred
1719             */
1720            public int countByU_T(long userId, long threadId) throws SystemException {
1721                    Object[] finderArgs = new Object[] { userId, threadId };
1722    
1723                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_T,
1724                                    finderArgs, this);
1725    
1726                    if (count == null) {
1727                            StringBundler query = new StringBundler(3);
1728    
1729                            query.append(_SQL_COUNT_MBTHREADFLAG_WHERE);
1730    
1731                            query.append(_FINDER_COLUMN_U_T_USERID_2);
1732    
1733                            query.append(_FINDER_COLUMN_U_T_THREADID_2);
1734    
1735                            String sql = query.toString();
1736    
1737                            Session session = null;
1738    
1739                            try {
1740                                    session = openSession();
1741    
1742                                    Query q = session.createQuery(sql);
1743    
1744                                    QueryPos qPos = QueryPos.getInstance(q);
1745    
1746                                    qPos.add(userId);
1747    
1748                                    qPos.add(threadId);
1749    
1750                                    count = (Long)q.uniqueResult();
1751                            }
1752                            catch (Exception e) {
1753                                    throw processException(e);
1754                            }
1755                            finally {
1756                                    if (count == null) {
1757                                            count = Long.valueOf(0);
1758                                    }
1759    
1760                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_T, finderArgs,
1761                                            count);
1762    
1763                                    closeSession(session);
1764                            }
1765                    }
1766    
1767                    return count.intValue();
1768            }
1769    
1770            /**
1771             * Returns the number of message boards thread flags.
1772             *
1773             * @return the number of message boards thread flags
1774             * @throws SystemException if a system exception occurred
1775             */
1776            public int countAll() throws SystemException {
1777                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1778                                    FINDER_ARGS_EMPTY, this);
1779    
1780                    if (count == null) {
1781                            Session session = null;
1782    
1783                            try {
1784                                    session = openSession();
1785    
1786                                    Query q = session.createQuery(_SQL_COUNT_MBTHREADFLAG);
1787    
1788                                    count = (Long)q.uniqueResult();
1789                            }
1790                            catch (Exception e) {
1791                                    throw processException(e);
1792                            }
1793                            finally {
1794                                    if (count == null) {
1795                                            count = Long.valueOf(0);
1796                                    }
1797    
1798                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1799                                            FINDER_ARGS_EMPTY, count);
1800    
1801                                    closeSession(session);
1802                            }
1803                    }
1804    
1805                    return count.intValue();
1806            }
1807    
1808            /**
1809             * Initializes the message boards thread flag persistence.
1810             */
1811            public void afterPropertiesSet() {
1812                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1813                                            com.liferay.portal.util.PropsUtil.get(
1814                                                    "value.object.listener.com.liferay.portlet.messageboards.model.MBThreadFlag")));
1815    
1816                    if (listenerClassNames.length > 0) {
1817                            try {
1818                                    List<ModelListener<MBThreadFlag>> listenersList = new ArrayList<ModelListener<MBThreadFlag>>();
1819    
1820                                    for (String listenerClassName : listenerClassNames) {
1821                                            listenersList.add((ModelListener<MBThreadFlag>)InstanceFactory.newInstance(
1822                                                            listenerClassName));
1823                                    }
1824    
1825                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1826                            }
1827                            catch (Exception e) {
1828                                    _log.error(e);
1829                            }
1830                    }
1831            }
1832    
1833            public void destroy() {
1834                    EntityCacheUtil.removeCache(MBThreadFlagImpl.class.getName());
1835                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1836                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1837            }
1838    
1839            @BeanReference(type = MBBanPersistence.class)
1840            protected MBBanPersistence mbBanPersistence;
1841            @BeanReference(type = MBCategoryPersistence.class)
1842            protected MBCategoryPersistence mbCategoryPersistence;
1843            @BeanReference(type = MBDiscussionPersistence.class)
1844            protected MBDiscussionPersistence mbDiscussionPersistence;
1845            @BeanReference(type = MBMailingListPersistence.class)
1846            protected MBMailingListPersistence mbMailingListPersistence;
1847            @BeanReference(type = MBMessagePersistence.class)
1848            protected MBMessagePersistence mbMessagePersistence;
1849            @BeanReference(type = MBStatsUserPersistence.class)
1850            protected MBStatsUserPersistence mbStatsUserPersistence;
1851            @BeanReference(type = MBThreadPersistence.class)
1852            protected MBThreadPersistence mbThreadPersistence;
1853            @BeanReference(type = MBThreadFlagPersistence.class)
1854            protected MBThreadFlagPersistence mbThreadFlagPersistence;
1855            @BeanReference(type = ResourcePersistence.class)
1856            protected ResourcePersistence resourcePersistence;
1857            @BeanReference(type = UserPersistence.class)
1858            protected UserPersistence userPersistence;
1859            private static final String _SQL_SELECT_MBTHREADFLAG = "SELECT mbThreadFlag FROM MBThreadFlag mbThreadFlag";
1860            private static final String _SQL_SELECT_MBTHREADFLAG_WHERE = "SELECT mbThreadFlag FROM MBThreadFlag mbThreadFlag WHERE ";
1861            private static final String _SQL_COUNT_MBTHREADFLAG = "SELECT COUNT(mbThreadFlag) FROM MBThreadFlag mbThreadFlag";
1862            private static final String _SQL_COUNT_MBTHREADFLAG_WHERE = "SELECT COUNT(mbThreadFlag) FROM MBThreadFlag mbThreadFlag WHERE ";
1863            private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbThreadFlag.userId = ?";
1864            private static final String _FINDER_COLUMN_THREADID_THREADID_2 = "mbThreadFlag.threadId = ?";
1865            private static final String _FINDER_COLUMN_U_T_USERID_2 = "mbThreadFlag.userId = ? AND ";
1866            private static final String _FINDER_COLUMN_U_T_THREADID_2 = "mbThreadFlag.threadId = ?";
1867            private static final String _ORDER_BY_ENTITY_ALIAS = "mbThreadFlag.";
1868            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBThreadFlag exists with the primary key ";
1869            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBThreadFlag exists with the key {";
1870            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1871            private static Log _log = LogFactoryUtil.getLog(MBThreadFlagPersistenceImpl.class);
1872            private static MBThreadFlag _nullMBThreadFlag = new MBThreadFlagImpl() {
1873                            @Override
1874                            public Object clone() {
1875                                    return this;
1876                            }
1877    
1878                            @Override
1879                            public CacheModel<MBThreadFlag> toCacheModel() {
1880                                    return _nullMBThreadFlagCacheModel;
1881                            }
1882                    };
1883    
1884            private static CacheModel<MBThreadFlag> _nullMBThreadFlagCacheModel = new CacheModel<MBThreadFlag>() {
1885                            public MBThreadFlag toEntityModel() {
1886                                    return _nullMBThreadFlag;
1887                            }
1888                    };
1889    }