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