001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.messageboards.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.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.ModelListener;
037    import com.liferay.portal.service.persistence.BatchSessionUtil;
038    import com.liferay.portal.service.persistence.ResourcePersistence;
039    import com.liferay.portal.service.persistence.UserPersistence;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.messageboards.NoSuchMessageFlagException;
043    import com.liferay.portlet.messageboards.model.MBMessageFlag;
044    import com.liferay.portlet.messageboards.model.impl.MBMessageFlagImpl;
045    import com.liferay.portlet.messageboards.model.impl.MBMessageFlagModelImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.List;
052    
053    /**
054     * @author    Brian Wing Shun Chan
055     * @see       MBMessageFlagPersistence
056     * @see       MBMessageFlagUtil
057     * @generated
058     */
059    public class MBMessageFlagPersistenceImpl extends BasePersistenceImpl<MBMessageFlag>
060            implements MBMessageFlagPersistence {
061            public static final String FINDER_CLASS_NAME_ENTITY = MBMessageFlagImpl.class.getName();
062            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
063                    ".List";
064            public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
065                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
066                            FINDER_CLASS_NAME_LIST, "findByUserId",
067                            new String[] {
068                                    Long.class.getName(),
069                                    
070                            "java.lang.Integer", "java.lang.Integer",
071                                    "com.liferay.portal.kernel.util.OrderByComparator"
072                            });
073            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
074                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
075                            FINDER_CLASS_NAME_LIST, "countByUserId",
076                            new String[] { Long.class.getName() });
077            public static final FinderPath FINDER_PATH_FIND_BY_THREADID = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
078                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
079                            FINDER_CLASS_NAME_LIST, "findByThreadId",
080                            new String[] {
081                                    Long.class.getName(),
082                                    
083                            "java.lang.Integer", "java.lang.Integer",
084                                    "com.liferay.portal.kernel.util.OrderByComparator"
085                            });
086            public static final FinderPath FINDER_PATH_COUNT_BY_THREADID = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
087                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
088                            FINDER_CLASS_NAME_LIST, "countByThreadId",
089                            new String[] { Long.class.getName() });
090            public static final FinderPath FINDER_PATH_FIND_BY_MESSAGEID = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
091                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
092                            FINDER_CLASS_NAME_LIST, "findByMessageId",
093                            new String[] {
094                                    Long.class.getName(),
095                                    
096                            "java.lang.Integer", "java.lang.Integer",
097                                    "com.liferay.portal.kernel.util.OrderByComparator"
098                            });
099            public static final FinderPath FINDER_PATH_COUNT_BY_MESSAGEID = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
100                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
101                            FINDER_CLASS_NAME_LIST, "countByMessageId",
102                            new String[] { Long.class.getName() });
103            public static final FinderPath FINDER_PATH_FIND_BY_T_F = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
104                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
105                            FINDER_CLASS_NAME_LIST, "findByT_F",
106                            new String[] {
107                                    Long.class.getName(), Integer.class.getName(),
108                                    
109                            "java.lang.Integer", "java.lang.Integer",
110                                    "com.liferay.portal.kernel.util.OrderByComparator"
111                            });
112            public static final FinderPath FINDER_PATH_COUNT_BY_T_F = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
113                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
114                            FINDER_CLASS_NAME_LIST, "countByT_F",
115                            new String[] { Long.class.getName(), Integer.class.getName() });
116            public static final FinderPath FINDER_PATH_FIND_BY_M_F = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
117                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
118                            FINDER_CLASS_NAME_LIST, "findByM_F",
119                            new String[] {
120                                    Long.class.getName(), Integer.class.getName(),
121                                    
122                            "java.lang.Integer", "java.lang.Integer",
123                                    "com.liferay.portal.kernel.util.OrderByComparator"
124                            });
125            public static final FinderPath FINDER_PATH_COUNT_BY_M_F = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
126                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
127                            FINDER_CLASS_NAME_LIST, "countByM_F",
128                            new String[] { Long.class.getName(), Integer.class.getName() });
129            public static final FinderPath FINDER_PATH_FIND_BY_U_T_F = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
130                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
131                            FINDER_CLASS_NAME_LIST, "findByU_T_F",
132                            new String[] {
133                                    Long.class.getName(), Long.class.getName(),
134                                    Integer.class.getName(),
135                                    
136                            "java.lang.Integer", "java.lang.Integer",
137                                    "com.liferay.portal.kernel.util.OrderByComparator"
138                            });
139            public static final FinderPath FINDER_PATH_COUNT_BY_U_T_F = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
140                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
141                            FINDER_CLASS_NAME_LIST, "countByU_T_F",
142                            new String[] {
143                                    Long.class.getName(), Long.class.getName(),
144                                    Integer.class.getName()
145                            });
146            public static final FinderPath FINDER_PATH_FETCH_BY_U_M_F = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
147                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
148                            FINDER_CLASS_NAME_ENTITY, "fetchByU_M_F",
149                            new String[] {
150                                    Long.class.getName(), Long.class.getName(),
151                                    Integer.class.getName()
152                            });
153            public static final FinderPath FINDER_PATH_COUNT_BY_U_M_F = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
154                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
155                            FINDER_CLASS_NAME_LIST, "countByU_M_F",
156                            new String[] {
157                                    Long.class.getName(), Long.class.getName(),
158                                    Integer.class.getName()
159                            });
160            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
161                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
162                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
163            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
164                            MBMessageFlagModelImpl.FINDER_CACHE_ENABLED,
165                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
166    
167            public void cacheResult(MBMessageFlag mbMessageFlag) {
168                    EntityCacheUtil.putResult(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
169                            MBMessageFlagImpl.class, mbMessageFlag.getPrimaryKey(),
170                            mbMessageFlag);
171    
172                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_M_F,
173                            new Object[] {
174                                    new Long(mbMessageFlag.getUserId()),
175                                    new Long(mbMessageFlag.getMessageId()),
176                                    new Integer(mbMessageFlag.getFlag())
177                            }, mbMessageFlag);
178            }
179    
180            public void cacheResult(List<MBMessageFlag> mbMessageFlags) {
181                    for (MBMessageFlag mbMessageFlag : mbMessageFlags) {
182                            if (EntityCacheUtil.getResult(
183                                                    MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
184                                                    MBMessageFlagImpl.class, mbMessageFlag.getPrimaryKey(),
185                                                    this) == null) {
186                                    cacheResult(mbMessageFlag);
187                            }
188                    }
189            }
190    
191            public void clearCache() {
192                    CacheRegistryUtil.clear(MBMessageFlagImpl.class.getName());
193                    EntityCacheUtil.clearCache(MBMessageFlagImpl.class.getName());
194                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
195                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
196            }
197    
198            public void clearCache(MBMessageFlag mbMessageFlag) {
199                    EntityCacheUtil.removeResult(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
200                            MBMessageFlagImpl.class, mbMessageFlag.getPrimaryKey());
201    
202                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_M_F,
203                            new Object[] {
204                                    new Long(mbMessageFlag.getUserId()),
205                                    new Long(mbMessageFlag.getMessageId()),
206                                    new Integer(mbMessageFlag.getFlag())
207                            });
208            }
209    
210            public MBMessageFlag create(long messageFlagId) {
211                    MBMessageFlag mbMessageFlag = new MBMessageFlagImpl();
212    
213                    mbMessageFlag.setNew(true);
214                    mbMessageFlag.setPrimaryKey(messageFlagId);
215    
216                    return mbMessageFlag;
217            }
218    
219            public MBMessageFlag remove(Serializable primaryKey)
220                    throws NoSuchModelException, SystemException {
221                    return remove(((Long)primaryKey).longValue());
222            }
223    
224            public MBMessageFlag remove(long messageFlagId)
225                    throws NoSuchMessageFlagException, SystemException {
226                    Session session = null;
227    
228                    try {
229                            session = openSession();
230    
231                            MBMessageFlag mbMessageFlag = (MBMessageFlag)session.get(MBMessageFlagImpl.class,
232                                            new Long(messageFlagId));
233    
234                            if (mbMessageFlag == null) {
235                                    if (_log.isWarnEnabled()) {
236                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + messageFlagId);
237                                    }
238    
239                                    throw new NoSuchMessageFlagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
240                                            messageFlagId);
241                            }
242    
243                            return remove(mbMessageFlag);
244                    }
245                    catch (NoSuchMessageFlagException nsee) {
246                            throw nsee;
247                    }
248                    catch (Exception e) {
249                            throw processException(e);
250                    }
251                    finally {
252                            closeSession(session);
253                    }
254            }
255    
256            protected MBMessageFlag removeImpl(MBMessageFlag mbMessageFlag)
257                    throws SystemException {
258                    mbMessageFlag = toUnwrappedModel(mbMessageFlag);
259    
260                    Session session = null;
261    
262                    try {
263                            session = openSession();
264    
265                            if (mbMessageFlag.isCachedModel() || BatchSessionUtil.isEnabled()) {
266                                    Object staleObject = session.get(MBMessageFlagImpl.class,
267                                                    mbMessageFlag.getPrimaryKeyObj());
268    
269                                    if (staleObject != null) {
270                                            session.evict(staleObject);
271                                    }
272                            }
273    
274                            session.delete(mbMessageFlag);
275    
276                            session.flush();
277                    }
278                    catch (Exception e) {
279                            throw processException(e);
280                    }
281                    finally {
282                            closeSession(session);
283                    }
284    
285                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
286    
287                    MBMessageFlagModelImpl mbMessageFlagModelImpl = (MBMessageFlagModelImpl)mbMessageFlag;
288    
289                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_M_F,
290                            new Object[] {
291                                    new Long(mbMessageFlagModelImpl.getOriginalUserId()),
292                                    new Long(mbMessageFlagModelImpl.getOriginalMessageId()),
293                                    new Integer(mbMessageFlagModelImpl.getOriginalFlag())
294                            });
295    
296                    EntityCacheUtil.removeResult(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
297                            MBMessageFlagImpl.class, mbMessageFlag.getPrimaryKey());
298    
299                    return mbMessageFlag;
300            }
301    
302            public MBMessageFlag updateImpl(
303                    com.liferay.portlet.messageboards.model.MBMessageFlag mbMessageFlag,
304                    boolean merge) throws SystemException {
305                    mbMessageFlag = toUnwrappedModel(mbMessageFlag);
306    
307                    boolean isNew = mbMessageFlag.isNew();
308    
309                    MBMessageFlagModelImpl mbMessageFlagModelImpl = (MBMessageFlagModelImpl)mbMessageFlag;
310    
311                    Session session = null;
312    
313                    try {
314                            session = openSession();
315    
316                            BatchSessionUtil.update(session, mbMessageFlag, merge);
317    
318                            mbMessageFlag.setNew(false);
319                    }
320                    catch (Exception e) {
321                            throw processException(e);
322                    }
323                    finally {
324                            closeSession(session);
325                    }
326    
327                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
328    
329                    EntityCacheUtil.putResult(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
330                            MBMessageFlagImpl.class, mbMessageFlag.getPrimaryKey(),
331                            mbMessageFlag);
332    
333                    if (!isNew &&
334                                    ((mbMessageFlag.getUserId() != mbMessageFlagModelImpl.getOriginalUserId()) ||
335                                    (mbMessageFlag.getMessageId() != mbMessageFlagModelImpl.getOriginalMessageId()) ||
336                                    (mbMessageFlag.getFlag() != mbMessageFlagModelImpl.getOriginalFlag()))) {
337                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_M_F,
338                                    new Object[] {
339                                            new Long(mbMessageFlagModelImpl.getOriginalUserId()),
340                                            new Long(mbMessageFlagModelImpl.getOriginalMessageId()),
341                                            new Integer(mbMessageFlagModelImpl.getOriginalFlag())
342                                    });
343                    }
344    
345                    if (isNew ||
346                                    ((mbMessageFlag.getUserId() != mbMessageFlagModelImpl.getOriginalUserId()) ||
347                                    (mbMessageFlag.getMessageId() != mbMessageFlagModelImpl.getOriginalMessageId()) ||
348                                    (mbMessageFlag.getFlag() != mbMessageFlagModelImpl.getOriginalFlag()))) {
349                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_M_F,
350                                    new Object[] {
351                                            new Long(mbMessageFlag.getUserId()),
352                                            new Long(mbMessageFlag.getMessageId()),
353                                            new Integer(mbMessageFlag.getFlag())
354                                    }, mbMessageFlag);
355                    }
356    
357                    return mbMessageFlag;
358            }
359    
360            protected MBMessageFlag toUnwrappedModel(MBMessageFlag mbMessageFlag) {
361                    if (mbMessageFlag instanceof MBMessageFlagImpl) {
362                            return mbMessageFlag;
363                    }
364    
365                    MBMessageFlagImpl mbMessageFlagImpl = new MBMessageFlagImpl();
366    
367                    mbMessageFlagImpl.setNew(mbMessageFlag.isNew());
368                    mbMessageFlagImpl.setPrimaryKey(mbMessageFlag.getPrimaryKey());
369    
370                    mbMessageFlagImpl.setMessageFlagId(mbMessageFlag.getMessageFlagId());
371                    mbMessageFlagImpl.setUserId(mbMessageFlag.getUserId());
372                    mbMessageFlagImpl.setModifiedDate(mbMessageFlag.getModifiedDate());
373                    mbMessageFlagImpl.setThreadId(mbMessageFlag.getThreadId());
374                    mbMessageFlagImpl.setMessageId(mbMessageFlag.getMessageId());
375                    mbMessageFlagImpl.setFlag(mbMessageFlag.getFlag());
376    
377                    return mbMessageFlagImpl;
378            }
379    
380            public MBMessageFlag findByPrimaryKey(Serializable primaryKey)
381                    throws NoSuchModelException, SystemException {
382                    return findByPrimaryKey(((Long)primaryKey).longValue());
383            }
384    
385            public MBMessageFlag findByPrimaryKey(long messageFlagId)
386                    throws NoSuchMessageFlagException, SystemException {
387                    MBMessageFlag mbMessageFlag = fetchByPrimaryKey(messageFlagId);
388    
389                    if (mbMessageFlag == null) {
390                            if (_log.isWarnEnabled()) {
391                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + messageFlagId);
392                            }
393    
394                            throw new NoSuchMessageFlagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
395                                    messageFlagId);
396                    }
397    
398                    return mbMessageFlag;
399            }
400    
401            public MBMessageFlag fetchByPrimaryKey(Serializable primaryKey)
402                    throws SystemException {
403                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
404            }
405    
406            public MBMessageFlag fetchByPrimaryKey(long messageFlagId)
407                    throws SystemException {
408                    MBMessageFlag mbMessageFlag = (MBMessageFlag)EntityCacheUtil.getResult(MBMessageFlagModelImpl.ENTITY_CACHE_ENABLED,
409                                    MBMessageFlagImpl.class, messageFlagId, this);
410    
411                    if (mbMessageFlag == null) {
412                            Session session = null;
413    
414                            try {
415                                    session = openSession();
416    
417                                    mbMessageFlag = (MBMessageFlag)session.get(MBMessageFlagImpl.class,
418                                                    new Long(messageFlagId));
419                            }
420                            catch (Exception e) {
421                                    throw processException(e);
422                            }
423                            finally {
424                                    if (mbMessageFlag != null) {
425                                            cacheResult(mbMessageFlag);
426                                    }
427    
428                                    closeSession(session);
429                            }
430                    }
431    
432                    return mbMessageFlag;
433            }
434    
435            public List<MBMessageFlag> findByUserId(long userId)
436                    throws SystemException {
437                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
438            }
439    
440            public List<MBMessageFlag> findByUserId(long userId, int start, int end)
441                    throws SystemException {
442                    return findByUserId(userId, start, end, null);
443            }
444    
445            public List<MBMessageFlag> findByUserId(long userId, int start, int end,
446                    OrderByComparator orderByComparator) throws SystemException {
447                    Object[] finderArgs = new Object[] {
448                                    userId,
449                                    
450                                    String.valueOf(start), String.valueOf(end),
451                                    String.valueOf(orderByComparator)
452                            };
453    
454                    List<MBMessageFlag> list = (List<MBMessageFlag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
455                                    finderArgs, this);
456    
457                    if (list == null) {
458                            Session session = null;
459    
460                            try {
461                                    session = openSession();
462    
463                                    StringBundler query = null;
464    
465                                    if (orderByComparator != null) {
466                                            query = new StringBundler(3 +
467                                                            (orderByComparator.getOrderByFields().length * 3));
468                                    }
469                                    else {
470                                            query = new StringBundler(2);
471                                    }
472    
473                                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
474    
475                                    query.append(_FINDER_COLUMN_USERID_USERID_2);
476    
477                                    if (orderByComparator != null) {
478                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
479                                                    orderByComparator);
480                                    }
481    
482                                    String sql = query.toString();
483    
484                                    Query q = session.createQuery(sql);
485    
486                                    QueryPos qPos = QueryPos.getInstance(q);
487    
488                                    qPos.add(userId);
489    
490                                    list = (List<MBMessageFlag>)QueryUtil.list(q, getDialect(),
491                                                    start, end);
492                            }
493                            catch (Exception e) {
494                                    throw processException(e);
495                            }
496                            finally {
497                                    if (list == null) {
498                                            list = new ArrayList<MBMessageFlag>();
499                                    }
500    
501                                    cacheResult(list);
502    
503                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
504                                            finderArgs, list);
505    
506                                    closeSession(session);
507                            }
508                    }
509    
510                    return list;
511            }
512    
513            public MBMessageFlag findByUserId_First(long userId,
514                    OrderByComparator orderByComparator)
515                    throws NoSuchMessageFlagException, SystemException {
516                    List<MBMessageFlag> list = findByUserId(userId, 0, 1, orderByComparator);
517    
518                    if (list.isEmpty()) {
519                            StringBundler msg = new StringBundler(4);
520    
521                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
522    
523                            msg.append("userId=");
524                            msg.append(userId);
525    
526                            msg.append(StringPool.CLOSE_CURLY_BRACE);
527    
528                            throw new NoSuchMessageFlagException(msg.toString());
529                    }
530                    else {
531                            return list.get(0);
532                    }
533            }
534    
535            public MBMessageFlag findByUserId_Last(long userId,
536                    OrderByComparator orderByComparator)
537                    throws NoSuchMessageFlagException, SystemException {
538                    int count = countByUserId(userId);
539    
540                    List<MBMessageFlag> list = findByUserId(userId, count - 1, count,
541                                    orderByComparator);
542    
543                    if (list.isEmpty()) {
544                            StringBundler msg = new StringBundler(4);
545    
546                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
547    
548                            msg.append("userId=");
549                            msg.append(userId);
550    
551                            msg.append(StringPool.CLOSE_CURLY_BRACE);
552    
553                            throw new NoSuchMessageFlagException(msg.toString());
554                    }
555                    else {
556                            return list.get(0);
557                    }
558            }
559    
560            public MBMessageFlag[] findByUserId_PrevAndNext(long messageFlagId,
561                    long userId, OrderByComparator orderByComparator)
562                    throws NoSuchMessageFlagException, SystemException {
563                    MBMessageFlag mbMessageFlag = findByPrimaryKey(messageFlagId);
564    
565                    Session session = null;
566    
567                    try {
568                            session = openSession();
569    
570                            MBMessageFlag[] array = new MBMessageFlagImpl[3];
571    
572                            array[0] = getByUserId_PrevAndNext(session, mbMessageFlag, userId,
573                                            orderByComparator, true);
574    
575                            array[1] = mbMessageFlag;
576    
577                            array[2] = getByUserId_PrevAndNext(session, mbMessageFlag, userId,
578                                            orderByComparator, false);
579    
580                            return array;
581                    }
582                    catch (Exception e) {
583                            throw processException(e);
584                    }
585                    finally {
586                            closeSession(session);
587                    }
588            }
589    
590            protected MBMessageFlag getByUserId_PrevAndNext(Session session,
591                    MBMessageFlag mbMessageFlag, long userId,
592                    OrderByComparator orderByComparator, boolean previous) {
593                    StringBundler query = null;
594    
595                    if (orderByComparator != null) {
596                            query = new StringBundler(6 +
597                                            (orderByComparator.getOrderByFields().length * 6));
598                    }
599                    else {
600                            query = new StringBundler(3);
601                    }
602    
603                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
604    
605                    query.append(_FINDER_COLUMN_USERID_USERID_2);
606    
607                    if (orderByComparator != null) {
608                            String[] orderByFields = orderByComparator.getOrderByFields();
609    
610                            if (orderByFields.length > 0) {
611                                    query.append(WHERE_AND);
612                            }
613    
614                            for (int i = 0; i < orderByFields.length; i++) {
615                                    query.append(_ORDER_BY_ENTITY_ALIAS);
616                                    query.append(orderByFields[i]);
617    
618                                    if ((i + 1) < orderByFields.length) {
619                                            if (orderByComparator.isAscending() ^ previous) {
620                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
621                                            }
622                                            else {
623                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
624                                            }
625                                    }
626                                    else {
627                                            if (orderByComparator.isAscending() ^ previous) {
628                                                    query.append(WHERE_GREATER_THAN);
629                                            }
630                                            else {
631                                                    query.append(WHERE_LESSER_THAN);
632                                            }
633                                    }
634                            }
635    
636                            query.append(ORDER_BY_CLAUSE);
637    
638                            for (int i = 0; i < orderByFields.length; i++) {
639                                    query.append(_ORDER_BY_ENTITY_ALIAS);
640                                    query.append(orderByFields[i]);
641    
642                                    if ((i + 1) < orderByFields.length) {
643                                            if (orderByComparator.isAscending() ^ previous) {
644                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
645                                            }
646                                            else {
647                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
648                                            }
649                                    }
650                                    else {
651                                            if (orderByComparator.isAscending() ^ previous) {
652                                                    query.append(ORDER_BY_ASC);
653                                            }
654                                            else {
655                                                    query.append(ORDER_BY_DESC);
656                                            }
657                                    }
658                            }
659                    }
660    
661                    String sql = query.toString();
662    
663                    Query q = session.createQuery(sql);
664    
665                    q.setFirstResult(0);
666                    q.setMaxResults(2);
667    
668                    QueryPos qPos = QueryPos.getInstance(q);
669    
670                    qPos.add(userId);
671    
672                    if (orderByComparator != null) {
673                            Object[] values = orderByComparator.getOrderByValues(mbMessageFlag);
674    
675                            for (Object value : values) {
676                                    qPos.add(value);
677                            }
678                    }
679    
680                    List<MBMessageFlag> list = q.list();
681    
682                    if (list.size() == 2) {
683                            return list.get(1);
684                    }
685                    else {
686                            return null;
687                    }
688            }
689    
690            public List<MBMessageFlag> findByThreadId(long threadId)
691                    throws SystemException {
692                    return findByThreadId(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
693                            null);
694            }
695    
696            public List<MBMessageFlag> findByThreadId(long threadId, int start, int end)
697                    throws SystemException {
698                    return findByThreadId(threadId, start, end, null);
699            }
700    
701            public List<MBMessageFlag> findByThreadId(long threadId, int start,
702                    int end, OrderByComparator orderByComparator) throws SystemException {
703                    Object[] finderArgs = new Object[] {
704                                    threadId,
705                                    
706                                    String.valueOf(start), String.valueOf(end),
707                                    String.valueOf(orderByComparator)
708                            };
709    
710                    List<MBMessageFlag> list = (List<MBMessageFlag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_THREADID,
711                                    finderArgs, this);
712    
713                    if (list == null) {
714                            Session session = null;
715    
716                            try {
717                                    session = openSession();
718    
719                                    StringBundler query = null;
720    
721                                    if (orderByComparator != null) {
722                                            query = new StringBundler(3 +
723                                                            (orderByComparator.getOrderByFields().length * 3));
724                                    }
725                                    else {
726                                            query = new StringBundler(2);
727                                    }
728    
729                                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
730    
731                                    query.append(_FINDER_COLUMN_THREADID_THREADID_2);
732    
733                                    if (orderByComparator != null) {
734                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
735                                                    orderByComparator);
736                                    }
737    
738                                    String sql = query.toString();
739    
740                                    Query q = session.createQuery(sql);
741    
742                                    QueryPos qPos = QueryPos.getInstance(q);
743    
744                                    qPos.add(threadId);
745    
746                                    list = (List<MBMessageFlag>)QueryUtil.list(q, getDialect(),
747                                                    start, end);
748                            }
749                            catch (Exception e) {
750                                    throw processException(e);
751                            }
752                            finally {
753                                    if (list == null) {
754                                            list = new ArrayList<MBMessageFlag>();
755                                    }
756    
757                                    cacheResult(list);
758    
759                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_THREADID,
760                                            finderArgs, list);
761    
762                                    closeSession(session);
763                            }
764                    }
765    
766                    return list;
767            }
768    
769            public MBMessageFlag findByThreadId_First(long threadId,
770                    OrderByComparator orderByComparator)
771                    throws NoSuchMessageFlagException, SystemException {
772                    List<MBMessageFlag> list = findByThreadId(threadId, 0, 1,
773                                    orderByComparator);
774    
775                    if (list.isEmpty()) {
776                            StringBundler msg = new StringBundler(4);
777    
778                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
779    
780                            msg.append("threadId=");
781                            msg.append(threadId);
782    
783                            msg.append(StringPool.CLOSE_CURLY_BRACE);
784    
785                            throw new NoSuchMessageFlagException(msg.toString());
786                    }
787                    else {
788                            return list.get(0);
789                    }
790            }
791    
792            public MBMessageFlag findByThreadId_Last(long threadId,
793                    OrderByComparator orderByComparator)
794                    throws NoSuchMessageFlagException, SystemException {
795                    int count = countByThreadId(threadId);
796    
797                    List<MBMessageFlag> list = findByThreadId(threadId, count - 1, count,
798                                    orderByComparator);
799    
800                    if (list.isEmpty()) {
801                            StringBundler msg = new StringBundler(4);
802    
803                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
804    
805                            msg.append("threadId=");
806                            msg.append(threadId);
807    
808                            msg.append(StringPool.CLOSE_CURLY_BRACE);
809    
810                            throw new NoSuchMessageFlagException(msg.toString());
811                    }
812                    else {
813                            return list.get(0);
814                    }
815            }
816    
817            public MBMessageFlag[] findByThreadId_PrevAndNext(long messageFlagId,
818                    long threadId, OrderByComparator orderByComparator)
819                    throws NoSuchMessageFlagException, SystemException {
820                    MBMessageFlag mbMessageFlag = findByPrimaryKey(messageFlagId);
821    
822                    Session session = null;
823    
824                    try {
825                            session = openSession();
826    
827                            MBMessageFlag[] array = new MBMessageFlagImpl[3];
828    
829                            array[0] = getByThreadId_PrevAndNext(session, mbMessageFlag,
830                                            threadId, orderByComparator, true);
831    
832                            array[1] = mbMessageFlag;
833    
834                            array[2] = getByThreadId_PrevAndNext(session, mbMessageFlag,
835                                            threadId, orderByComparator, false);
836    
837                            return array;
838                    }
839                    catch (Exception e) {
840                            throw processException(e);
841                    }
842                    finally {
843                            closeSession(session);
844                    }
845            }
846    
847            protected MBMessageFlag getByThreadId_PrevAndNext(Session session,
848                    MBMessageFlag mbMessageFlag, long threadId,
849                    OrderByComparator orderByComparator, boolean previous) {
850                    StringBundler query = null;
851    
852                    if (orderByComparator != null) {
853                            query = new StringBundler(6 +
854                                            (orderByComparator.getOrderByFields().length * 6));
855                    }
856                    else {
857                            query = new StringBundler(3);
858                    }
859    
860                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
861    
862                    query.append(_FINDER_COLUMN_THREADID_THREADID_2);
863    
864                    if (orderByComparator != null) {
865                            String[] orderByFields = orderByComparator.getOrderByFields();
866    
867                            if (orderByFields.length > 0) {
868                                    query.append(WHERE_AND);
869                            }
870    
871                            for (int i = 0; i < orderByFields.length; i++) {
872                                    query.append(_ORDER_BY_ENTITY_ALIAS);
873                                    query.append(orderByFields[i]);
874    
875                                    if ((i + 1) < orderByFields.length) {
876                                            if (orderByComparator.isAscending() ^ previous) {
877                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
878                                            }
879                                            else {
880                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
881                                            }
882                                    }
883                                    else {
884                                            if (orderByComparator.isAscending() ^ previous) {
885                                                    query.append(WHERE_GREATER_THAN);
886                                            }
887                                            else {
888                                                    query.append(WHERE_LESSER_THAN);
889                                            }
890                                    }
891                            }
892    
893                            query.append(ORDER_BY_CLAUSE);
894    
895                            for (int i = 0; i < orderByFields.length; i++) {
896                                    query.append(_ORDER_BY_ENTITY_ALIAS);
897                                    query.append(orderByFields[i]);
898    
899                                    if ((i + 1) < orderByFields.length) {
900                                            if (orderByComparator.isAscending() ^ previous) {
901                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
902                                            }
903                                            else {
904                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
905                                            }
906                                    }
907                                    else {
908                                            if (orderByComparator.isAscending() ^ previous) {
909                                                    query.append(ORDER_BY_ASC);
910                                            }
911                                            else {
912                                                    query.append(ORDER_BY_DESC);
913                                            }
914                                    }
915                            }
916                    }
917    
918                    String sql = query.toString();
919    
920                    Query q = session.createQuery(sql);
921    
922                    q.setFirstResult(0);
923                    q.setMaxResults(2);
924    
925                    QueryPos qPos = QueryPos.getInstance(q);
926    
927                    qPos.add(threadId);
928    
929                    if (orderByComparator != null) {
930                            Object[] values = orderByComparator.getOrderByValues(mbMessageFlag);
931    
932                            for (Object value : values) {
933                                    qPos.add(value);
934                            }
935                    }
936    
937                    List<MBMessageFlag> list = q.list();
938    
939                    if (list.size() == 2) {
940                            return list.get(1);
941                    }
942                    else {
943                            return null;
944                    }
945            }
946    
947            public List<MBMessageFlag> findByMessageId(long messageId)
948                    throws SystemException {
949                    return findByMessageId(messageId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
950                            null);
951            }
952    
953            public List<MBMessageFlag> findByMessageId(long messageId, int start,
954                    int end) throws SystemException {
955                    return findByMessageId(messageId, start, end, null);
956            }
957    
958            public List<MBMessageFlag> findByMessageId(long messageId, int start,
959                    int end, OrderByComparator orderByComparator) throws SystemException {
960                    Object[] finderArgs = new Object[] {
961                                    messageId,
962                                    
963                                    String.valueOf(start), String.valueOf(end),
964                                    String.valueOf(orderByComparator)
965                            };
966    
967                    List<MBMessageFlag> list = (List<MBMessageFlag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_MESSAGEID,
968                                    finderArgs, this);
969    
970                    if (list == null) {
971                            Session session = null;
972    
973                            try {
974                                    session = openSession();
975    
976                                    StringBundler query = null;
977    
978                                    if (orderByComparator != null) {
979                                            query = new StringBundler(3 +
980                                                            (orderByComparator.getOrderByFields().length * 3));
981                                    }
982                                    else {
983                                            query = new StringBundler(2);
984                                    }
985    
986                                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
987    
988                                    query.append(_FINDER_COLUMN_MESSAGEID_MESSAGEID_2);
989    
990                                    if (orderByComparator != null) {
991                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
992                                                    orderByComparator);
993                                    }
994    
995                                    String sql = query.toString();
996    
997                                    Query q = session.createQuery(sql);
998    
999                                    QueryPos qPos = QueryPos.getInstance(q);
1000    
1001                                    qPos.add(messageId);
1002    
1003                                    list = (List<MBMessageFlag>)QueryUtil.list(q, getDialect(),
1004                                                    start, end);
1005                            }
1006                            catch (Exception e) {
1007                                    throw processException(e);
1008                            }
1009                            finally {
1010                                    if (list == null) {
1011                                            list = new ArrayList<MBMessageFlag>();
1012                                    }
1013    
1014                                    cacheResult(list);
1015    
1016                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_MESSAGEID,
1017                                            finderArgs, list);
1018    
1019                                    closeSession(session);
1020                            }
1021                    }
1022    
1023                    return list;
1024            }
1025    
1026            public MBMessageFlag findByMessageId_First(long messageId,
1027                    OrderByComparator orderByComparator)
1028                    throws NoSuchMessageFlagException, SystemException {
1029                    List<MBMessageFlag> list = findByMessageId(messageId, 0, 1,
1030                                    orderByComparator);
1031    
1032                    if (list.isEmpty()) {
1033                            StringBundler msg = new StringBundler(4);
1034    
1035                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1036    
1037                            msg.append("messageId=");
1038                            msg.append(messageId);
1039    
1040                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1041    
1042                            throw new NoSuchMessageFlagException(msg.toString());
1043                    }
1044                    else {
1045                            return list.get(0);
1046                    }
1047            }
1048    
1049            public MBMessageFlag findByMessageId_Last(long messageId,
1050                    OrderByComparator orderByComparator)
1051                    throws NoSuchMessageFlagException, SystemException {
1052                    int count = countByMessageId(messageId);
1053    
1054                    List<MBMessageFlag> list = findByMessageId(messageId, count - 1, count,
1055                                    orderByComparator);
1056    
1057                    if (list.isEmpty()) {
1058                            StringBundler msg = new StringBundler(4);
1059    
1060                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1061    
1062                            msg.append("messageId=");
1063                            msg.append(messageId);
1064    
1065                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1066    
1067                            throw new NoSuchMessageFlagException(msg.toString());
1068                    }
1069                    else {
1070                            return list.get(0);
1071                    }
1072            }
1073    
1074            public MBMessageFlag[] findByMessageId_PrevAndNext(long messageFlagId,
1075                    long messageId, OrderByComparator orderByComparator)
1076                    throws NoSuchMessageFlagException, SystemException {
1077                    MBMessageFlag mbMessageFlag = findByPrimaryKey(messageFlagId);
1078    
1079                    Session session = null;
1080    
1081                    try {
1082                            session = openSession();
1083    
1084                            MBMessageFlag[] array = new MBMessageFlagImpl[3];
1085    
1086                            array[0] = getByMessageId_PrevAndNext(session, mbMessageFlag,
1087                                            messageId, orderByComparator, true);
1088    
1089                            array[1] = mbMessageFlag;
1090    
1091                            array[2] = getByMessageId_PrevAndNext(session, mbMessageFlag,
1092                                            messageId, orderByComparator, false);
1093    
1094                            return array;
1095                    }
1096                    catch (Exception e) {
1097                            throw processException(e);
1098                    }
1099                    finally {
1100                            closeSession(session);
1101                    }
1102            }
1103    
1104            protected MBMessageFlag getByMessageId_PrevAndNext(Session session,
1105                    MBMessageFlag mbMessageFlag, long messageId,
1106                    OrderByComparator orderByComparator, boolean previous) {
1107                    StringBundler query = null;
1108    
1109                    if (orderByComparator != null) {
1110                            query = new StringBundler(6 +
1111                                            (orderByComparator.getOrderByFields().length * 6));
1112                    }
1113                    else {
1114                            query = new StringBundler(3);
1115                    }
1116    
1117                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
1118    
1119                    query.append(_FINDER_COLUMN_MESSAGEID_MESSAGEID_2);
1120    
1121                    if (orderByComparator != null) {
1122                            String[] orderByFields = orderByComparator.getOrderByFields();
1123    
1124                            if (orderByFields.length > 0) {
1125                                    query.append(WHERE_AND);
1126                            }
1127    
1128                            for (int i = 0; i < orderByFields.length; i++) {
1129                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1130                                    query.append(orderByFields[i]);
1131    
1132                                    if ((i + 1) < orderByFields.length) {
1133                                            if (orderByComparator.isAscending() ^ previous) {
1134                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1135                                            }
1136                                            else {
1137                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1138                                            }
1139                                    }
1140                                    else {
1141                                            if (orderByComparator.isAscending() ^ previous) {
1142                                                    query.append(WHERE_GREATER_THAN);
1143                                            }
1144                                            else {
1145                                                    query.append(WHERE_LESSER_THAN);
1146                                            }
1147                                    }
1148                            }
1149    
1150                            query.append(ORDER_BY_CLAUSE);
1151    
1152                            for (int i = 0; i < orderByFields.length; i++) {
1153                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1154                                    query.append(orderByFields[i]);
1155    
1156                                    if ((i + 1) < orderByFields.length) {
1157                                            if (orderByComparator.isAscending() ^ previous) {
1158                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1159                                            }
1160                                            else {
1161                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1162                                            }
1163                                    }
1164                                    else {
1165                                            if (orderByComparator.isAscending() ^ previous) {
1166                                                    query.append(ORDER_BY_ASC);
1167                                            }
1168                                            else {
1169                                                    query.append(ORDER_BY_DESC);
1170                                            }
1171                                    }
1172                            }
1173                    }
1174    
1175                    String sql = query.toString();
1176    
1177                    Query q = session.createQuery(sql);
1178    
1179                    q.setFirstResult(0);
1180                    q.setMaxResults(2);
1181    
1182                    QueryPos qPos = QueryPos.getInstance(q);
1183    
1184                    qPos.add(messageId);
1185    
1186                    if (orderByComparator != null) {
1187                            Object[] values = orderByComparator.getOrderByValues(mbMessageFlag);
1188    
1189                            for (Object value : values) {
1190                                    qPos.add(value);
1191                            }
1192                    }
1193    
1194                    List<MBMessageFlag> list = q.list();
1195    
1196                    if (list.size() == 2) {
1197                            return list.get(1);
1198                    }
1199                    else {
1200                            return null;
1201                    }
1202            }
1203    
1204            public List<MBMessageFlag> findByT_F(long threadId, int flag)
1205                    throws SystemException {
1206                    return findByT_F(threadId, flag, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1207                            null);
1208            }
1209    
1210            public List<MBMessageFlag> findByT_F(long threadId, int flag, int start,
1211                    int end) throws SystemException {
1212                    return findByT_F(threadId, flag, start, end, null);
1213            }
1214    
1215            public List<MBMessageFlag> findByT_F(long threadId, int flag, int start,
1216                    int end, OrderByComparator orderByComparator) throws SystemException {
1217                    Object[] finderArgs = new Object[] {
1218                                    threadId, flag,
1219                                    
1220                                    String.valueOf(start), String.valueOf(end),
1221                                    String.valueOf(orderByComparator)
1222                            };
1223    
1224                    List<MBMessageFlag> list = (List<MBMessageFlag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_F,
1225                                    finderArgs, this);
1226    
1227                    if (list == null) {
1228                            Session session = null;
1229    
1230                            try {
1231                                    session = openSession();
1232    
1233                                    StringBundler query = null;
1234    
1235                                    if (orderByComparator != null) {
1236                                            query = new StringBundler(4 +
1237                                                            (orderByComparator.getOrderByFields().length * 3));
1238                                    }
1239                                    else {
1240                                            query = new StringBundler(3);
1241                                    }
1242    
1243                                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
1244    
1245                                    query.append(_FINDER_COLUMN_T_F_THREADID_2);
1246    
1247                                    query.append(_FINDER_COLUMN_T_F_FLAG_2);
1248    
1249                                    if (orderByComparator != null) {
1250                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1251                                                    orderByComparator);
1252                                    }
1253    
1254                                    String sql = query.toString();
1255    
1256                                    Query q = session.createQuery(sql);
1257    
1258                                    QueryPos qPos = QueryPos.getInstance(q);
1259    
1260                                    qPos.add(threadId);
1261    
1262                                    qPos.add(flag);
1263    
1264                                    list = (List<MBMessageFlag>)QueryUtil.list(q, getDialect(),
1265                                                    start, end);
1266                            }
1267                            catch (Exception e) {
1268                                    throw processException(e);
1269                            }
1270                            finally {
1271                                    if (list == null) {
1272                                            list = new ArrayList<MBMessageFlag>();
1273                                    }
1274    
1275                                    cacheResult(list);
1276    
1277                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_F, finderArgs,
1278                                            list);
1279    
1280                                    closeSession(session);
1281                            }
1282                    }
1283    
1284                    return list;
1285            }
1286    
1287            public MBMessageFlag findByT_F_First(long threadId, int flag,
1288                    OrderByComparator orderByComparator)
1289                    throws NoSuchMessageFlagException, SystemException {
1290                    List<MBMessageFlag> list = findByT_F(threadId, flag, 0, 1,
1291                                    orderByComparator);
1292    
1293                    if (list.isEmpty()) {
1294                            StringBundler msg = new StringBundler(6);
1295    
1296                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1297    
1298                            msg.append("threadId=");
1299                            msg.append(threadId);
1300    
1301                            msg.append(", flag=");
1302                            msg.append(flag);
1303    
1304                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1305    
1306                            throw new NoSuchMessageFlagException(msg.toString());
1307                    }
1308                    else {
1309                            return list.get(0);
1310                    }
1311            }
1312    
1313            public MBMessageFlag findByT_F_Last(long threadId, int flag,
1314                    OrderByComparator orderByComparator)
1315                    throws NoSuchMessageFlagException, SystemException {
1316                    int count = countByT_F(threadId, flag);
1317    
1318                    List<MBMessageFlag> list = findByT_F(threadId, flag, count - 1, count,
1319                                    orderByComparator);
1320    
1321                    if (list.isEmpty()) {
1322                            StringBundler msg = new StringBundler(6);
1323    
1324                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1325    
1326                            msg.append("threadId=");
1327                            msg.append(threadId);
1328    
1329                            msg.append(", flag=");
1330                            msg.append(flag);
1331    
1332                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1333    
1334                            throw new NoSuchMessageFlagException(msg.toString());
1335                    }
1336                    else {
1337                            return list.get(0);
1338                    }
1339            }
1340    
1341            public MBMessageFlag[] findByT_F_PrevAndNext(long messageFlagId,
1342                    long threadId, int flag, OrderByComparator orderByComparator)
1343                    throws NoSuchMessageFlagException, SystemException {
1344                    MBMessageFlag mbMessageFlag = findByPrimaryKey(messageFlagId);
1345    
1346                    Session session = null;
1347    
1348                    try {
1349                            session = openSession();
1350    
1351                            MBMessageFlag[] array = new MBMessageFlagImpl[3];
1352    
1353                            array[0] = getByT_F_PrevAndNext(session, mbMessageFlag, threadId,
1354                                            flag, orderByComparator, true);
1355    
1356                            array[1] = mbMessageFlag;
1357    
1358                            array[2] = getByT_F_PrevAndNext(session, mbMessageFlag, threadId,
1359                                            flag, orderByComparator, false);
1360    
1361                            return array;
1362                    }
1363                    catch (Exception e) {
1364                            throw processException(e);
1365                    }
1366                    finally {
1367                            closeSession(session);
1368                    }
1369            }
1370    
1371            protected MBMessageFlag getByT_F_PrevAndNext(Session session,
1372                    MBMessageFlag mbMessageFlag, long threadId, int flag,
1373                    OrderByComparator orderByComparator, boolean previous) {
1374                    StringBundler query = null;
1375    
1376                    if (orderByComparator != null) {
1377                            query = new StringBundler(6 +
1378                                            (orderByComparator.getOrderByFields().length * 6));
1379                    }
1380                    else {
1381                            query = new StringBundler(3);
1382                    }
1383    
1384                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
1385    
1386                    query.append(_FINDER_COLUMN_T_F_THREADID_2);
1387    
1388                    query.append(_FINDER_COLUMN_T_F_FLAG_2);
1389    
1390                    if (orderByComparator != null) {
1391                            String[] orderByFields = orderByComparator.getOrderByFields();
1392    
1393                            if (orderByFields.length > 0) {
1394                                    query.append(WHERE_AND);
1395                            }
1396    
1397                            for (int i = 0; i < orderByFields.length; i++) {
1398                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1399                                    query.append(orderByFields[i]);
1400    
1401                                    if ((i + 1) < orderByFields.length) {
1402                                            if (orderByComparator.isAscending() ^ previous) {
1403                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1404                                            }
1405                                            else {
1406                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1407                                            }
1408                                    }
1409                                    else {
1410                                            if (orderByComparator.isAscending() ^ previous) {
1411                                                    query.append(WHERE_GREATER_THAN);
1412                                            }
1413                                            else {
1414                                                    query.append(WHERE_LESSER_THAN);
1415                                            }
1416                                    }
1417                            }
1418    
1419                            query.append(ORDER_BY_CLAUSE);
1420    
1421                            for (int i = 0; i < orderByFields.length; i++) {
1422                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1423                                    query.append(orderByFields[i]);
1424    
1425                                    if ((i + 1) < orderByFields.length) {
1426                                            if (orderByComparator.isAscending() ^ previous) {
1427                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1428                                            }
1429                                            else {
1430                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1431                                            }
1432                                    }
1433                                    else {
1434                                            if (orderByComparator.isAscending() ^ previous) {
1435                                                    query.append(ORDER_BY_ASC);
1436                                            }
1437                                            else {
1438                                                    query.append(ORDER_BY_DESC);
1439                                            }
1440                                    }
1441                            }
1442                    }
1443    
1444                    String sql = query.toString();
1445    
1446                    Query q = session.createQuery(sql);
1447    
1448                    q.setFirstResult(0);
1449                    q.setMaxResults(2);
1450    
1451                    QueryPos qPos = QueryPos.getInstance(q);
1452    
1453                    qPos.add(threadId);
1454    
1455                    qPos.add(flag);
1456    
1457                    if (orderByComparator != null) {
1458                            Object[] values = orderByComparator.getOrderByValues(mbMessageFlag);
1459    
1460                            for (Object value : values) {
1461                                    qPos.add(value);
1462                            }
1463                    }
1464    
1465                    List<MBMessageFlag> list = q.list();
1466    
1467                    if (list.size() == 2) {
1468                            return list.get(1);
1469                    }
1470                    else {
1471                            return null;
1472                    }
1473            }
1474    
1475            public List<MBMessageFlag> findByM_F(long messageId, int flag)
1476                    throws SystemException {
1477                    return findByM_F(messageId, flag, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1478                            null);
1479            }
1480    
1481            public List<MBMessageFlag> findByM_F(long messageId, int flag, int start,
1482                    int end) throws SystemException {
1483                    return findByM_F(messageId, flag, start, end, null);
1484            }
1485    
1486            public List<MBMessageFlag> findByM_F(long messageId, int flag, int start,
1487                    int end, OrderByComparator orderByComparator) throws SystemException {
1488                    Object[] finderArgs = new Object[] {
1489                                    messageId, flag,
1490                                    
1491                                    String.valueOf(start), String.valueOf(end),
1492                                    String.valueOf(orderByComparator)
1493                            };
1494    
1495                    List<MBMessageFlag> list = (List<MBMessageFlag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_M_F,
1496                                    finderArgs, this);
1497    
1498                    if (list == null) {
1499                            Session session = null;
1500    
1501                            try {
1502                                    session = openSession();
1503    
1504                                    StringBundler query = null;
1505    
1506                                    if (orderByComparator != null) {
1507                                            query = new StringBundler(4 +
1508                                                            (orderByComparator.getOrderByFields().length * 3));
1509                                    }
1510                                    else {
1511                                            query = new StringBundler(3);
1512                                    }
1513    
1514                                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
1515    
1516                                    query.append(_FINDER_COLUMN_M_F_MESSAGEID_2);
1517    
1518                                    query.append(_FINDER_COLUMN_M_F_FLAG_2);
1519    
1520                                    if (orderByComparator != null) {
1521                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1522                                                    orderByComparator);
1523                                    }
1524    
1525                                    String sql = query.toString();
1526    
1527                                    Query q = session.createQuery(sql);
1528    
1529                                    QueryPos qPos = QueryPos.getInstance(q);
1530    
1531                                    qPos.add(messageId);
1532    
1533                                    qPos.add(flag);
1534    
1535                                    list = (List<MBMessageFlag>)QueryUtil.list(q, getDialect(),
1536                                                    start, end);
1537                            }
1538                            catch (Exception e) {
1539                                    throw processException(e);
1540                            }
1541                            finally {
1542                                    if (list == null) {
1543                                            list = new ArrayList<MBMessageFlag>();
1544                                    }
1545    
1546                                    cacheResult(list);
1547    
1548                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_M_F, finderArgs,
1549                                            list);
1550    
1551                                    closeSession(session);
1552                            }
1553                    }
1554    
1555                    return list;
1556            }
1557    
1558            public MBMessageFlag findByM_F_First(long messageId, int flag,
1559                    OrderByComparator orderByComparator)
1560                    throws NoSuchMessageFlagException, SystemException {
1561                    List<MBMessageFlag> list = findByM_F(messageId, flag, 0, 1,
1562                                    orderByComparator);
1563    
1564                    if (list.isEmpty()) {
1565                            StringBundler msg = new StringBundler(6);
1566    
1567                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1568    
1569                            msg.append("messageId=");
1570                            msg.append(messageId);
1571    
1572                            msg.append(", flag=");
1573                            msg.append(flag);
1574    
1575                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1576    
1577                            throw new NoSuchMessageFlagException(msg.toString());
1578                    }
1579                    else {
1580                            return list.get(0);
1581                    }
1582            }
1583    
1584            public MBMessageFlag findByM_F_Last(long messageId, int flag,
1585                    OrderByComparator orderByComparator)
1586                    throws NoSuchMessageFlagException, SystemException {
1587                    int count = countByM_F(messageId, flag);
1588    
1589                    List<MBMessageFlag> list = findByM_F(messageId, flag, count - 1, count,
1590                                    orderByComparator);
1591    
1592                    if (list.isEmpty()) {
1593                            StringBundler msg = new StringBundler(6);
1594    
1595                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1596    
1597                            msg.append("messageId=");
1598                            msg.append(messageId);
1599    
1600                            msg.append(", flag=");
1601                            msg.append(flag);
1602    
1603                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1604    
1605                            throw new NoSuchMessageFlagException(msg.toString());
1606                    }
1607                    else {
1608                            return list.get(0);
1609                    }
1610            }
1611    
1612            public MBMessageFlag[] findByM_F_PrevAndNext(long messageFlagId,
1613                    long messageId, int flag, OrderByComparator orderByComparator)
1614                    throws NoSuchMessageFlagException, SystemException {
1615                    MBMessageFlag mbMessageFlag = findByPrimaryKey(messageFlagId);
1616    
1617                    Session session = null;
1618    
1619                    try {
1620                            session = openSession();
1621    
1622                            MBMessageFlag[] array = new MBMessageFlagImpl[3];
1623    
1624                            array[0] = getByM_F_PrevAndNext(session, mbMessageFlag, messageId,
1625                                            flag, orderByComparator, true);
1626    
1627                            array[1] = mbMessageFlag;
1628    
1629                            array[2] = getByM_F_PrevAndNext(session, mbMessageFlag, messageId,
1630                                            flag, orderByComparator, false);
1631    
1632                            return array;
1633                    }
1634                    catch (Exception e) {
1635                            throw processException(e);
1636                    }
1637                    finally {
1638                            closeSession(session);
1639                    }
1640            }
1641    
1642            protected MBMessageFlag getByM_F_PrevAndNext(Session session,
1643                    MBMessageFlag mbMessageFlag, long messageId, int flag,
1644                    OrderByComparator orderByComparator, boolean previous) {
1645                    StringBundler query = null;
1646    
1647                    if (orderByComparator != null) {
1648                            query = new StringBundler(6 +
1649                                            (orderByComparator.getOrderByFields().length * 6));
1650                    }
1651                    else {
1652                            query = new StringBundler(3);
1653                    }
1654    
1655                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
1656    
1657                    query.append(_FINDER_COLUMN_M_F_MESSAGEID_2);
1658    
1659                    query.append(_FINDER_COLUMN_M_F_FLAG_2);
1660    
1661                    if (orderByComparator != null) {
1662                            String[] orderByFields = orderByComparator.getOrderByFields();
1663    
1664                            if (orderByFields.length > 0) {
1665                                    query.append(WHERE_AND);
1666                            }
1667    
1668                            for (int i = 0; i < orderByFields.length; i++) {
1669                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1670                                    query.append(orderByFields[i]);
1671    
1672                                    if ((i + 1) < orderByFields.length) {
1673                                            if (orderByComparator.isAscending() ^ previous) {
1674                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1675                                            }
1676                                            else {
1677                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1678                                            }
1679                                    }
1680                                    else {
1681                                            if (orderByComparator.isAscending() ^ previous) {
1682                                                    query.append(WHERE_GREATER_THAN);
1683                                            }
1684                                            else {
1685                                                    query.append(WHERE_LESSER_THAN);
1686                                            }
1687                                    }
1688                            }
1689    
1690                            query.append(ORDER_BY_CLAUSE);
1691    
1692                            for (int i = 0; i < orderByFields.length; i++) {
1693                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1694                                    query.append(orderByFields[i]);
1695    
1696                                    if ((i + 1) < orderByFields.length) {
1697                                            if (orderByComparator.isAscending() ^ previous) {
1698                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1699                                            }
1700                                            else {
1701                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1702                                            }
1703                                    }
1704                                    else {
1705                                            if (orderByComparator.isAscending() ^ previous) {
1706                                                    query.append(ORDER_BY_ASC);
1707                                            }
1708                                            else {
1709                                                    query.append(ORDER_BY_DESC);
1710                                            }
1711                                    }
1712                            }
1713                    }
1714    
1715                    String sql = query.toString();
1716    
1717                    Query q = session.createQuery(sql);
1718    
1719                    q.setFirstResult(0);
1720                    q.setMaxResults(2);
1721    
1722                    QueryPos qPos = QueryPos.getInstance(q);
1723    
1724                    qPos.add(messageId);
1725    
1726                    qPos.add(flag);
1727    
1728                    if (orderByComparator != null) {
1729                            Object[] values = orderByComparator.getOrderByValues(mbMessageFlag);
1730    
1731                            for (Object value : values) {
1732                                    qPos.add(value);
1733                            }
1734                    }
1735    
1736                    List<MBMessageFlag> list = q.list();
1737    
1738                    if (list.size() == 2) {
1739                            return list.get(1);
1740                    }
1741                    else {
1742                            return null;
1743                    }
1744            }
1745    
1746            public List<MBMessageFlag> findByU_T_F(long userId, long threadId, int flag)
1747                    throws SystemException {
1748                    return findByU_T_F(userId, threadId, flag, QueryUtil.ALL_POS,
1749                            QueryUtil.ALL_POS, null);
1750            }
1751    
1752            public List<MBMessageFlag> findByU_T_F(long userId, long threadId,
1753                    int flag, int start, int end) throws SystemException {
1754                    return findByU_T_F(userId, threadId, flag, start, end, null);
1755            }
1756    
1757            public List<MBMessageFlag> findByU_T_F(long userId, long threadId,
1758                    int flag, int start, int end, OrderByComparator orderByComparator)
1759                    throws SystemException {
1760                    Object[] finderArgs = new Object[] {
1761                                    userId, threadId, flag,
1762                                    
1763                                    String.valueOf(start), String.valueOf(end),
1764                                    String.valueOf(orderByComparator)
1765                            };
1766    
1767                    List<MBMessageFlag> list = (List<MBMessageFlag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_T_F,
1768                                    finderArgs, this);
1769    
1770                    if (list == null) {
1771                            Session session = null;
1772    
1773                            try {
1774                                    session = openSession();
1775    
1776                                    StringBundler query = null;
1777    
1778                                    if (orderByComparator != null) {
1779                                            query = new StringBundler(5 +
1780                                                            (orderByComparator.getOrderByFields().length * 3));
1781                                    }
1782                                    else {
1783                                            query = new StringBundler(4);
1784                                    }
1785    
1786                                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
1787    
1788                                    query.append(_FINDER_COLUMN_U_T_F_USERID_2);
1789    
1790                                    query.append(_FINDER_COLUMN_U_T_F_THREADID_2);
1791    
1792                                    query.append(_FINDER_COLUMN_U_T_F_FLAG_2);
1793    
1794                                    if (orderByComparator != null) {
1795                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1796                                                    orderByComparator);
1797                                    }
1798    
1799                                    String sql = query.toString();
1800    
1801                                    Query q = session.createQuery(sql);
1802    
1803                                    QueryPos qPos = QueryPos.getInstance(q);
1804    
1805                                    qPos.add(userId);
1806    
1807                                    qPos.add(threadId);
1808    
1809                                    qPos.add(flag);
1810    
1811                                    list = (List<MBMessageFlag>)QueryUtil.list(q, getDialect(),
1812                                                    start, end);
1813                            }
1814                            catch (Exception e) {
1815                                    throw processException(e);
1816                            }
1817                            finally {
1818                                    if (list == null) {
1819                                            list = new ArrayList<MBMessageFlag>();
1820                                    }
1821    
1822                                    cacheResult(list);
1823    
1824                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_T_F,
1825                                            finderArgs, list);
1826    
1827                                    closeSession(session);
1828                            }
1829                    }
1830    
1831                    return list;
1832            }
1833    
1834            public MBMessageFlag findByU_T_F_First(long userId, long threadId,
1835                    int flag, OrderByComparator orderByComparator)
1836                    throws NoSuchMessageFlagException, SystemException {
1837                    List<MBMessageFlag> list = findByU_T_F(userId, threadId, flag, 0, 1,
1838                                    orderByComparator);
1839    
1840                    if (list.isEmpty()) {
1841                            StringBundler msg = new StringBundler(8);
1842    
1843                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1844    
1845                            msg.append("userId=");
1846                            msg.append(userId);
1847    
1848                            msg.append(", threadId=");
1849                            msg.append(threadId);
1850    
1851                            msg.append(", flag=");
1852                            msg.append(flag);
1853    
1854                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1855    
1856                            throw new NoSuchMessageFlagException(msg.toString());
1857                    }
1858                    else {
1859                            return list.get(0);
1860                    }
1861            }
1862    
1863            public MBMessageFlag findByU_T_F_Last(long userId, long threadId, int flag,
1864                    OrderByComparator orderByComparator)
1865                    throws NoSuchMessageFlagException, SystemException {
1866                    int count = countByU_T_F(userId, threadId, flag);
1867    
1868                    List<MBMessageFlag> list = findByU_T_F(userId, threadId, flag,
1869                                    count - 1, count, orderByComparator);
1870    
1871                    if (list.isEmpty()) {
1872                            StringBundler msg = new StringBundler(8);
1873    
1874                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1875    
1876                            msg.append("userId=");
1877                            msg.append(userId);
1878    
1879                            msg.append(", threadId=");
1880                            msg.append(threadId);
1881    
1882                            msg.append(", flag=");
1883                            msg.append(flag);
1884    
1885                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1886    
1887                            throw new NoSuchMessageFlagException(msg.toString());
1888                    }
1889                    else {
1890                            return list.get(0);
1891                    }
1892            }
1893    
1894            public MBMessageFlag[] findByU_T_F_PrevAndNext(long messageFlagId,
1895                    long userId, long threadId, int flag,
1896                    OrderByComparator orderByComparator)
1897                    throws NoSuchMessageFlagException, SystemException {
1898                    MBMessageFlag mbMessageFlag = findByPrimaryKey(messageFlagId);
1899    
1900                    Session session = null;
1901    
1902                    try {
1903                            session = openSession();
1904    
1905                            MBMessageFlag[] array = new MBMessageFlagImpl[3];
1906    
1907                            array[0] = getByU_T_F_PrevAndNext(session, mbMessageFlag, userId,
1908                                            threadId, flag, orderByComparator, true);
1909    
1910                            array[1] = mbMessageFlag;
1911    
1912                            array[2] = getByU_T_F_PrevAndNext(session, mbMessageFlag, userId,
1913                                            threadId, flag, orderByComparator, false);
1914    
1915                            return array;
1916                    }
1917                    catch (Exception e) {
1918                            throw processException(e);
1919                    }
1920                    finally {
1921                            closeSession(session);
1922                    }
1923            }
1924    
1925            protected MBMessageFlag getByU_T_F_PrevAndNext(Session session,
1926                    MBMessageFlag mbMessageFlag, long userId, long threadId, int flag,
1927                    OrderByComparator orderByComparator, boolean previous) {
1928                    StringBundler query = null;
1929    
1930                    if (orderByComparator != null) {
1931                            query = new StringBundler(6 +
1932                                            (orderByComparator.getOrderByFields().length * 6));
1933                    }
1934                    else {
1935                            query = new StringBundler(3);
1936                    }
1937    
1938                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
1939    
1940                    query.append(_FINDER_COLUMN_U_T_F_USERID_2);
1941    
1942                    query.append(_FINDER_COLUMN_U_T_F_THREADID_2);
1943    
1944                    query.append(_FINDER_COLUMN_U_T_F_FLAG_2);
1945    
1946                    if (orderByComparator != null) {
1947                            String[] orderByFields = orderByComparator.getOrderByFields();
1948    
1949                            if (orderByFields.length > 0) {
1950                                    query.append(WHERE_AND);
1951                            }
1952    
1953                            for (int i = 0; i < orderByFields.length; i++) {
1954                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1955                                    query.append(orderByFields[i]);
1956    
1957                                    if ((i + 1) < orderByFields.length) {
1958                                            if (orderByComparator.isAscending() ^ previous) {
1959                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1960                                            }
1961                                            else {
1962                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1963                                            }
1964                                    }
1965                                    else {
1966                                            if (orderByComparator.isAscending() ^ previous) {
1967                                                    query.append(WHERE_GREATER_THAN);
1968                                            }
1969                                            else {
1970                                                    query.append(WHERE_LESSER_THAN);
1971                                            }
1972                                    }
1973                            }
1974    
1975                            query.append(ORDER_BY_CLAUSE);
1976    
1977                            for (int i = 0; i < orderByFields.length; i++) {
1978                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1979                                    query.append(orderByFields[i]);
1980    
1981                                    if ((i + 1) < orderByFields.length) {
1982                                            if (orderByComparator.isAscending() ^ previous) {
1983                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1984                                            }
1985                                            else {
1986                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1987                                            }
1988                                    }
1989                                    else {
1990                                            if (orderByComparator.isAscending() ^ previous) {
1991                                                    query.append(ORDER_BY_ASC);
1992                                            }
1993                                            else {
1994                                                    query.append(ORDER_BY_DESC);
1995                                            }
1996                                    }
1997                            }
1998                    }
1999    
2000                    String sql = query.toString();
2001    
2002                    Query q = session.createQuery(sql);
2003    
2004                    q.setFirstResult(0);
2005                    q.setMaxResults(2);
2006    
2007                    QueryPos qPos = QueryPos.getInstance(q);
2008    
2009                    qPos.add(userId);
2010    
2011                    qPos.add(threadId);
2012    
2013                    qPos.add(flag);
2014    
2015                    if (orderByComparator != null) {
2016                            Object[] values = orderByComparator.getOrderByValues(mbMessageFlag);
2017    
2018                            for (Object value : values) {
2019                                    qPos.add(value);
2020                            }
2021                    }
2022    
2023                    List<MBMessageFlag> list = q.list();
2024    
2025                    if (list.size() == 2) {
2026                            return list.get(1);
2027                    }
2028                    else {
2029                            return null;
2030                    }
2031            }
2032    
2033            public MBMessageFlag findByU_M_F(long userId, long messageId, int flag)
2034                    throws NoSuchMessageFlagException, SystemException {
2035                    MBMessageFlag mbMessageFlag = fetchByU_M_F(userId, messageId, flag);
2036    
2037                    if (mbMessageFlag == null) {
2038                            StringBundler msg = new StringBundler(8);
2039    
2040                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2041    
2042                            msg.append("userId=");
2043                            msg.append(userId);
2044    
2045                            msg.append(", messageId=");
2046                            msg.append(messageId);
2047    
2048                            msg.append(", flag=");
2049                            msg.append(flag);
2050    
2051                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2052    
2053                            if (_log.isWarnEnabled()) {
2054                                    _log.warn(msg.toString());
2055                            }
2056    
2057                            throw new NoSuchMessageFlagException(msg.toString());
2058                    }
2059    
2060                    return mbMessageFlag;
2061            }
2062    
2063            public MBMessageFlag fetchByU_M_F(long userId, long messageId, int flag)
2064                    throws SystemException {
2065                    return fetchByU_M_F(userId, messageId, flag, true);
2066            }
2067    
2068            public MBMessageFlag fetchByU_M_F(long userId, long messageId, int flag,
2069                    boolean retrieveFromCache) throws SystemException {
2070                    Object[] finderArgs = new Object[] { userId, messageId, flag };
2071    
2072                    Object result = null;
2073    
2074                    if (retrieveFromCache) {
2075                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_M_F,
2076                                            finderArgs, this);
2077                    }
2078    
2079                    if (result == null) {
2080                            Session session = null;
2081    
2082                            try {
2083                                    session = openSession();
2084    
2085                                    StringBundler query = new StringBundler(4);
2086    
2087                                    query.append(_SQL_SELECT_MBMESSAGEFLAG_WHERE);
2088    
2089                                    query.append(_FINDER_COLUMN_U_M_F_USERID_2);
2090    
2091                                    query.append(_FINDER_COLUMN_U_M_F_MESSAGEID_2);
2092    
2093                                    query.append(_FINDER_COLUMN_U_M_F_FLAG_2);
2094    
2095                                    String sql = query.toString();
2096    
2097                                    Query q = session.createQuery(sql);
2098    
2099                                    QueryPos qPos = QueryPos.getInstance(q);
2100    
2101                                    qPos.add(userId);
2102    
2103                                    qPos.add(messageId);
2104    
2105                                    qPos.add(flag);
2106    
2107                                    List<MBMessageFlag> list = q.list();
2108    
2109                                    result = list;
2110    
2111                                    MBMessageFlag mbMessageFlag = null;
2112    
2113                                    if (list.isEmpty()) {
2114                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_M_F,
2115                                                    finderArgs, list);
2116                                    }
2117                                    else {
2118                                            mbMessageFlag = list.get(0);
2119    
2120                                            cacheResult(mbMessageFlag);
2121    
2122                                            if ((mbMessageFlag.getUserId() != userId) ||
2123                                                            (mbMessageFlag.getMessageId() != messageId) ||
2124                                                            (mbMessageFlag.getFlag() != flag)) {
2125                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_M_F,
2126                                                            finderArgs, mbMessageFlag);
2127                                            }
2128                                    }
2129    
2130                                    return mbMessageFlag;
2131                            }
2132                            catch (Exception e) {
2133                                    throw processException(e);
2134                            }
2135                            finally {
2136                                    if (result == null) {
2137                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_M_F,
2138                                                    finderArgs, new ArrayList<MBMessageFlag>());
2139                                    }
2140    
2141                                    closeSession(session);
2142                            }
2143                    }
2144                    else {
2145                            if (result instanceof List<?>) {
2146                                    return null;
2147                            }
2148                            else {
2149                                    return (MBMessageFlag)result;
2150                            }
2151                    }
2152            }
2153    
2154            public List<MBMessageFlag> findAll() throws SystemException {
2155                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2156            }
2157    
2158            public List<MBMessageFlag> findAll(int start, int end)
2159                    throws SystemException {
2160                    return findAll(start, end, null);
2161            }
2162    
2163            public List<MBMessageFlag> findAll(int start, int end,
2164                    OrderByComparator orderByComparator) throws SystemException {
2165                    Object[] finderArgs = new Object[] {
2166                                    String.valueOf(start), String.valueOf(end),
2167                                    String.valueOf(orderByComparator)
2168                            };
2169    
2170                    List<MBMessageFlag> list = (List<MBMessageFlag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2171                                    finderArgs, this);
2172    
2173                    if (list == null) {
2174                            Session session = null;
2175    
2176                            try {
2177                                    session = openSession();
2178    
2179                                    StringBundler query = null;
2180                                    String sql = null;
2181    
2182                                    if (orderByComparator != null) {
2183                                            query = new StringBundler(2 +
2184                                                            (orderByComparator.getOrderByFields().length * 3));
2185    
2186                                            query.append(_SQL_SELECT_MBMESSAGEFLAG);
2187    
2188                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2189                                                    orderByComparator);
2190    
2191                                            sql = query.toString();
2192                                    }
2193                                    else {
2194                                            sql = _SQL_SELECT_MBMESSAGEFLAG;
2195                                    }
2196    
2197                                    Query q = session.createQuery(sql);
2198    
2199                                    if (orderByComparator == null) {
2200                                            list = (List<MBMessageFlag>)QueryUtil.list(q, getDialect(),
2201                                                            start, end, false);
2202    
2203                                            Collections.sort(list);
2204                                    }
2205                                    else {
2206                                            list = (List<MBMessageFlag>)QueryUtil.list(q, getDialect(),
2207                                                            start, end);
2208                                    }
2209                            }
2210                            catch (Exception e) {
2211                                    throw processException(e);
2212                            }
2213                            finally {
2214                                    if (list == null) {
2215                                            list = new ArrayList<MBMessageFlag>();
2216                                    }
2217    
2218                                    cacheResult(list);
2219    
2220                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2221    
2222                                    closeSession(session);
2223                            }
2224                    }
2225    
2226                    return list;
2227            }
2228    
2229            public void removeByUserId(long userId) throws SystemException {
2230                    for (MBMessageFlag mbMessageFlag : findByUserId(userId)) {
2231                            remove(mbMessageFlag);
2232                    }
2233            }
2234    
2235            public void removeByThreadId(long threadId) throws SystemException {
2236                    for (MBMessageFlag mbMessageFlag : findByThreadId(threadId)) {
2237                            remove(mbMessageFlag);
2238                    }
2239            }
2240    
2241            public void removeByMessageId(long messageId) throws SystemException {
2242                    for (MBMessageFlag mbMessageFlag : findByMessageId(messageId)) {
2243                            remove(mbMessageFlag);
2244                    }
2245            }
2246    
2247            public void removeByT_F(long threadId, int flag) throws SystemException {
2248                    for (MBMessageFlag mbMessageFlag : findByT_F(threadId, flag)) {
2249                            remove(mbMessageFlag);
2250                    }
2251            }
2252    
2253            public void removeByM_F(long messageId, int flag) throws SystemException {
2254                    for (MBMessageFlag mbMessageFlag : findByM_F(messageId, flag)) {
2255                            remove(mbMessageFlag);
2256                    }
2257            }
2258    
2259            public void removeByU_T_F(long userId, long threadId, int flag)
2260                    throws SystemException {
2261                    for (MBMessageFlag mbMessageFlag : findByU_T_F(userId, threadId, flag)) {
2262                            remove(mbMessageFlag);
2263                    }
2264            }
2265    
2266            public void removeByU_M_F(long userId, long messageId, int flag)
2267                    throws NoSuchMessageFlagException, SystemException {
2268                    MBMessageFlag mbMessageFlag = findByU_M_F(userId, messageId, flag);
2269    
2270                    remove(mbMessageFlag);
2271            }
2272    
2273            public void removeAll() throws SystemException {
2274                    for (MBMessageFlag mbMessageFlag : findAll()) {
2275                            remove(mbMessageFlag);
2276                    }
2277            }
2278    
2279            public int countByUserId(long userId) throws SystemException {
2280                    Object[] finderArgs = new Object[] { userId };
2281    
2282                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2283                                    finderArgs, this);
2284    
2285                    if (count == null) {
2286                            Session session = null;
2287    
2288                            try {
2289                                    session = openSession();
2290    
2291                                    StringBundler query = new StringBundler(2);
2292    
2293                                    query.append(_SQL_COUNT_MBMESSAGEFLAG_WHERE);
2294    
2295                                    query.append(_FINDER_COLUMN_USERID_USERID_2);
2296    
2297                                    String sql = query.toString();
2298    
2299                                    Query q = session.createQuery(sql);
2300    
2301                                    QueryPos qPos = QueryPos.getInstance(q);
2302    
2303                                    qPos.add(userId);
2304    
2305                                    count = (Long)q.uniqueResult();
2306                            }
2307                            catch (Exception e) {
2308                                    throw processException(e);
2309                            }
2310                            finally {
2311                                    if (count == null) {
2312                                            count = Long.valueOf(0);
2313                                    }
2314    
2315                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2316                                            finderArgs, count);
2317    
2318                                    closeSession(session);
2319                            }
2320                    }
2321    
2322                    return count.intValue();
2323            }
2324    
2325            public int countByThreadId(long threadId) throws SystemException {
2326                    Object[] finderArgs = new Object[] { threadId };
2327    
2328                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADID,
2329                                    finderArgs, this);
2330    
2331                    if (count == null) {
2332                            Session session = null;
2333    
2334                            try {
2335                                    session = openSession();
2336    
2337                                    StringBundler query = new StringBundler(2);
2338    
2339                                    query.append(_SQL_COUNT_MBMESSAGEFLAG_WHERE);
2340    
2341                                    query.append(_FINDER_COLUMN_THREADID_THREADID_2);
2342    
2343                                    String sql = query.toString();
2344    
2345                                    Query q = session.createQuery(sql);
2346    
2347                                    QueryPos qPos = QueryPos.getInstance(q);
2348    
2349                                    qPos.add(threadId);
2350    
2351                                    count = (Long)q.uniqueResult();
2352                            }
2353                            catch (Exception e) {
2354                                    throw processException(e);
2355                            }
2356                            finally {
2357                                    if (count == null) {
2358                                            count = Long.valueOf(0);
2359                                    }
2360    
2361                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADID,
2362                                            finderArgs, count);
2363    
2364                                    closeSession(session);
2365                            }
2366                    }
2367    
2368                    return count.intValue();
2369            }
2370    
2371            public int countByMessageId(long messageId) throws SystemException {
2372                    Object[] finderArgs = new Object[] { messageId };
2373    
2374                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MESSAGEID,
2375                                    finderArgs, this);
2376    
2377                    if (count == null) {
2378                            Session session = null;
2379    
2380                            try {
2381                                    session = openSession();
2382    
2383                                    StringBundler query = new StringBundler(2);
2384    
2385                                    query.append(_SQL_COUNT_MBMESSAGEFLAG_WHERE);
2386    
2387                                    query.append(_FINDER_COLUMN_MESSAGEID_MESSAGEID_2);
2388    
2389                                    String sql = query.toString();
2390    
2391                                    Query q = session.createQuery(sql);
2392    
2393                                    QueryPos qPos = QueryPos.getInstance(q);
2394    
2395                                    qPos.add(messageId);
2396    
2397                                    count = (Long)q.uniqueResult();
2398                            }
2399                            catch (Exception e) {
2400                                    throw processException(e);
2401                            }
2402                            finally {
2403                                    if (count == null) {
2404                                            count = Long.valueOf(0);
2405                                    }
2406    
2407                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MESSAGEID,
2408                                            finderArgs, count);
2409    
2410                                    closeSession(session);
2411                            }
2412                    }
2413    
2414                    return count.intValue();
2415            }
2416    
2417            public int countByT_F(long threadId, int flag) throws SystemException {
2418                    Object[] finderArgs = new Object[] { threadId, flag };
2419    
2420                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_F,
2421                                    finderArgs, this);
2422    
2423                    if (count == null) {
2424                            Session session = null;
2425    
2426                            try {
2427                                    session = openSession();
2428    
2429                                    StringBundler query = new StringBundler(3);
2430    
2431                                    query.append(_SQL_COUNT_MBMESSAGEFLAG_WHERE);
2432    
2433                                    query.append(_FINDER_COLUMN_T_F_THREADID_2);
2434    
2435                                    query.append(_FINDER_COLUMN_T_F_FLAG_2);
2436    
2437                                    String sql = query.toString();
2438    
2439                                    Query q = session.createQuery(sql);
2440    
2441                                    QueryPos qPos = QueryPos.getInstance(q);
2442    
2443                                    qPos.add(threadId);
2444    
2445                                    qPos.add(flag);
2446    
2447                                    count = (Long)q.uniqueResult();
2448                            }
2449                            catch (Exception e) {
2450                                    throw processException(e);
2451                            }
2452                            finally {
2453                                    if (count == null) {
2454                                            count = Long.valueOf(0);
2455                                    }
2456    
2457                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_F, finderArgs,
2458                                            count);
2459    
2460                                    closeSession(session);
2461                            }
2462                    }
2463    
2464                    return count.intValue();
2465            }
2466    
2467            public int countByM_F(long messageId, int flag) throws SystemException {
2468                    Object[] finderArgs = new Object[] { messageId, flag };
2469    
2470                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_M_F,
2471                                    finderArgs, this);
2472    
2473                    if (count == null) {
2474                            Session session = null;
2475    
2476                            try {
2477                                    session = openSession();
2478    
2479                                    StringBundler query = new StringBundler(3);
2480    
2481                                    query.append(_SQL_COUNT_MBMESSAGEFLAG_WHERE);
2482    
2483                                    query.append(_FINDER_COLUMN_M_F_MESSAGEID_2);
2484    
2485                                    query.append(_FINDER_COLUMN_M_F_FLAG_2);
2486    
2487                                    String sql = query.toString();
2488    
2489                                    Query q = session.createQuery(sql);
2490    
2491                                    QueryPos qPos = QueryPos.getInstance(q);
2492    
2493                                    qPos.add(messageId);
2494    
2495                                    qPos.add(flag);
2496    
2497                                    count = (Long)q.uniqueResult();
2498                            }
2499                            catch (Exception e) {
2500                                    throw processException(e);
2501                            }
2502                            finally {
2503                                    if (count == null) {
2504                                            count = Long.valueOf(0);
2505                                    }
2506    
2507                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_M_F, finderArgs,
2508                                            count);
2509    
2510                                    closeSession(session);
2511                            }
2512                    }
2513    
2514                    return count.intValue();
2515            }
2516    
2517            public int countByU_T_F(long userId, long threadId, int flag)
2518                    throws SystemException {
2519                    Object[] finderArgs = new Object[] { userId, threadId, flag };
2520    
2521                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_T_F,
2522                                    finderArgs, this);
2523    
2524                    if (count == null) {
2525                            Session session = null;
2526    
2527                            try {
2528                                    session = openSession();
2529    
2530                                    StringBundler query = new StringBundler(4);
2531    
2532                                    query.append(_SQL_COUNT_MBMESSAGEFLAG_WHERE);
2533    
2534                                    query.append(_FINDER_COLUMN_U_T_F_USERID_2);
2535    
2536                                    query.append(_FINDER_COLUMN_U_T_F_THREADID_2);
2537    
2538                                    query.append(_FINDER_COLUMN_U_T_F_FLAG_2);
2539    
2540                                    String sql = query.toString();
2541    
2542                                    Query q = session.createQuery(sql);
2543    
2544                                    QueryPos qPos = QueryPos.getInstance(q);
2545    
2546                                    qPos.add(userId);
2547    
2548                                    qPos.add(threadId);
2549    
2550                                    qPos.add(flag);
2551    
2552                                    count = (Long)q.uniqueResult();
2553                            }
2554                            catch (Exception e) {
2555                                    throw processException(e);
2556                            }
2557                            finally {
2558                                    if (count == null) {
2559                                            count = Long.valueOf(0);
2560                                    }
2561    
2562                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_T_F,
2563                                            finderArgs, count);
2564    
2565                                    closeSession(session);
2566                            }
2567                    }
2568    
2569                    return count.intValue();
2570            }
2571    
2572            public int countByU_M_F(long userId, long messageId, int flag)
2573                    throws SystemException {
2574                    Object[] finderArgs = new Object[] { userId, messageId, flag };
2575    
2576                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_M_F,
2577                                    finderArgs, this);
2578    
2579                    if (count == null) {
2580                            Session session = null;
2581    
2582                            try {
2583                                    session = openSession();
2584    
2585                                    StringBundler query = new StringBundler(4);
2586    
2587                                    query.append(_SQL_COUNT_MBMESSAGEFLAG_WHERE);
2588    
2589                                    query.append(_FINDER_COLUMN_U_M_F_USERID_2);
2590    
2591                                    query.append(_FINDER_COLUMN_U_M_F_MESSAGEID_2);
2592    
2593                                    query.append(_FINDER_COLUMN_U_M_F_FLAG_2);
2594    
2595                                    String sql = query.toString();
2596    
2597                                    Query q = session.createQuery(sql);
2598    
2599                                    QueryPos qPos = QueryPos.getInstance(q);
2600    
2601                                    qPos.add(userId);
2602    
2603                                    qPos.add(messageId);
2604    
2605                                    qPos.add(flag);
2606    
2607                                    count = (Long)q.uniqueResult();
2608                            }
2609                            catch (Exception e) {
2610                                    throw processException(e);
2611                            }
2612                            finally {
2613                                    if (count == null) {
2614                                            count = Long.valueOf(0);
2615                                    }
2616    
2617                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_M_F,
2618                                            finderArgs, count);
2619    
2620                                    closeSession(session);
2621                            }
2622                    }
2623    
2624                    return count.intValue();
2625            }
2626    
2627            public int countAll() throws SystemException {
2628                    Object[] finderArgs = new Object[0];
2629    
2630                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2631                                    finderArgs, this);
2632    
2633                    if (count == null) {
2634                            Session session = null;
2635    
2636                            try {
2637                                    session = openSession();
2638    
2639                                    Query q = session.createQuery(_SQL_COUNT_MBMESSAGEFLAG);
2640    
2641                                    count = (Long)q.uniqueResult();
2642                            }
2643                            catch (Exception e) {
2644                                    throw processException(e);
2645                            }
2646                            finally {
2647                                    if (count == null) {
2648                                            count = Long.valueOf(0);
2649                                    }
2650    
2651                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2652                                            count);
2653    
2654                                    closeSession(session);
2655                            }
2656                    }
2657    
2658                    return count.intValue();
2659            }
2660    
2661            public void afterPropertiesSet() {
2662                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2663                                            com.liferay.portal.util.PropsUtil.get(
2664                                                    "value.object.listener.com.liferay.portlet.messageboards.model.MBMessageFlag")));
2665    
2666                    if (listenerClassNames.length > 0) {
2667                            try {
2668                                    List<ModelListener<MBMessageFlag>> listenersList = new ArrayList<ModelListener<MBMessageFlag>>();
2669    
2670                                    for (String listenerClassName : listenerClassNames) {
2671                                            listenersList.add((ModelListener<MBMessageFlag>)InstanceFactory.newInstance(
2672                                                            listenerClassName));
2673                                    }
2674    
2675                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2676                            }
2677                            catch (Exception e) {
2678                                    _log.error(e);
2679                            }
2680                    }
2681            }
2682    
2683            @BeanReference(type = MBBanPersistence.class)
2684            protected MBBanPersistence mbBanPersistence;
2685            @BeanReference(type = MBCategoryPersistence.class)
2686            protected MBCategoryPersistence mbCategoryPersistence;
2687            @BeanReference(type = MBDiscussionPersistence.class)
2688            protected MBDiscussionPersistence mbDiscussionPersistence;
2689            @BeanReference(type = MBMailingListPersistence.class)
2690            protected MBMailingListPersistence mbMailingListPersistence;
2691            @BeanReference(type = MBMessagePersistence.class)
2692            protected MBMessagePersistence mbMessagePersistence;
2693            @BeanReference(type = MBMessageFlagPersistence.class)
2694            protected MBMessageFlagPersistence mbMessageFlagPersistence;
2695            @BeanReference(type = MBStatsUserPersistence.class)
2696            protected MBStatsUserPersistence mbStatsUserPersistence;
2697            @BeanReference(type = MBThreadPersistence.class)
2698            protected MBThreadPersistence mbThreadPersistence;
2699            @BeanReference(type = ResourcePersistence.class)
2700            protected ResourcePersistence resourcePersistence;
2701            @BeanReference(type = UserPersistence.class)
2702            protected UserPersistence userPersistence;
2703            private static final String _SQL_SELECT_MBMESSAGEFLAG = "SELECT mbMessageFlag FROM MBMessageFlag mbMessageFlag";
2704            private static final String _SQL_SELECT_MBMESSAGEFLAG_WHERE = "SELECT mbMessageFlag FROM MBMessageFlag mbMessageFlag WHERE ";
2705            private static final String _SQL_COUNT_MBMESSAGEFLAG = "SELECT COUNT(mbMessageFlag) FROM MBMessageFlag mbMessageFlag";
2706            private static final String _SQL_COUNT_MBMESSAGEFLAG_WHERE = "SELECT COUNT(mbMessageFlag) FROM MBMessageFlag mbMessageFlag WHERE ";
2707            private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbMessageFlag.userId = ?";
2708            private static final String _FINDER_COLUMN_THREADID_THREADID_2 = "mbMessageFlag.threadId = ?";
2709            private static final String _FINDER_COLUMN_MESSAGEID_MESSAGEID_2 = "mbMessageFlag.messageId = ?";
2710            private static final String _FINDER_COLUMN_T_F_THREADID_2 = "mbMessageFlag.threadId = ? AND ";
2711            private static final String _FINDER_COLUMN_T_F_FLAG_2 = "mbMessageFlag.flag = ?";
2712            private static final String _FINDER_COLUMN_M_F_MESSAGEID_2 = "mbMessageFlag.messageId = ? AND ";
2713            private static final String _FINDER_COLUMN_M_F_FLAG_2 = "mbMessageFlag.flag = ?";
2714            private static final String _FINDER_COLUMN_U_T_F_USERID_2 = "mbMessageFlag.userId = ? AND ";
2715            private static final String _FINDER_COLUMN_U_T_F_THREADID_2 = "mbMessageFlag.threadId = ? AND ";
2716            private static final String _FINDER_COLUMN_U_T_F_FLAG_2 = "mbMessageFlag.flag = ?";
2717            private static final String _FINDER_COLUMN_U_M_F_USERID_2 = "mbMessageFlag.userId = ? AND ";
2718            private static final String _FINDER_COLUMN_U_M_F_MESSAGEID_2 = "mbMessageFlag.messageId = ? AND ";
2719            private static final String _FINDER_COLUMN_U_M_F_FLAG_2 = "mbMessageFlag.flag = ?";
2720            private static final String _ORDER_BY_ENTITY_ALIAS = "mbMessageFlag.";
2721            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMessageFlag exists with the primary key ";
2722            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMessageFlag exists with the key {";
2723            private static Log _log = LogFactoryUtil.getLog(MBMessageFlagPersistenceImpl.class);
2724    }