001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.messageboards.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.GetterUtil;
030    import com.liferay.portal.kernel.util.InstanceFactory;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.UnmodifiableList;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
039    
040    import com.liferay.portlet.messageboards.NoSuchBanException;
041    import com.liferay.portlet.messageboards.model.MBBan;
042    import com.liferay.portlet.messageboards.model.impl.MBBanImpl;
043    import com.liferay.portlet.messageboards.model.impl.MBBanModelImpl;
044    
045    import java.io.Serializable;
046    
047    import java.util.ArrayList;
048    import java.util.Collections;
049    import java.util.List;
050    
051    /**
052     * The persistence implementation for the message boards ban service.
053     *
054     * <p>
055     * Caching information and settings can be found in <code>portal.properties</code>
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see MBBanPersistence
060     * @see MBBanUtil
061     * @generated
062     */
063    public class MBBanPersistenceImpl extends BasePersistenceImpl<MBBan>
064            implements MBBanPersistence {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. Always use {@link MBBanUtil} to access the message boards ban persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
069             */
070            public static final String FINDER_CLASS_NAME_ENTITY = MBBanImpl.class.getName();
071            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072                    ".List1";
073            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List2";
075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
076                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
077                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
078            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
079                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
082                            MBBanModelImpl.FINDER_CACHE_ENABLED, Long.class,
083                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
085                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
087                            new String[] {
088                                    Long.class.getName(),
089                                    
090                            Integer.class.getName(), Integer.class.getName(),
091                                    OrderByComparator.class.getName()
092                            });
093            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
094                    new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
095                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
097                            new String[] { Long.class.getName() },
098                            MBBanModelImpl.GROUPID_COLUMN_BITMASK);
099            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
100                            MBBanModelImpl.FINDER_CACHE_ENABLED, Long.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
102                            new String[] { Long.class.getName() });
103    
104            /**
105             * Returns all the message boards bans where groupId = &#63;.
106             *
107             * @param groupId the group ID
108             * @return the matching message boards bans
109             * @throws SystemException if a system exception occurred
110             */
111            public List<MBBan> findByGroupId(long groupId) throws SystemException {
112                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
113            }
114    
115            /**
116             * Returns a range of all the message boards bans where groupId = &#63;.
117             *
118             * <p>
119             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.messageboards.model.impl.MBBanModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
120             * </p>
121             *
122             * @param groupId the group ID
123             * @param start the lower bound of the range of message boards bans
124             * @param end the upper bound of the range of message boards bans (not inclusive)
125             * @return the range of matching message boards bans
126             * @throws SystemException if a system exception occurred
127             */
128            public List<MBBan> findByGroupId(long groupId, int start, int end)
129                    throws SystemException {
130                    return findByGroupId(groupId, start, end, null);
131            }
132    
133            /**
134             * Returns an ordered range of all the message boards bans where groupId = &#63;.
135             *
136             * <p>
137             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.messageboards.model.impl.MBBanModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
138             * </p>
139             *
140             * @param groupId the group ID
141             * @param start the lower bound of the range of message boards bans
142             * @param end the upper bound of the range of message boards bans (not inclusive)
143             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
144             * @return the ordered range of matching message boards bans
145             * @throws SystemException if a system exception occurred
146             */
147            public List<MBBan> findByGroupId(long groupId, int start, int end,
148                    OrderByComparator orderByComparator) throws SystemException {
149                    boolean pagination = true;
150                    FinderPath finderPath = null;
151                    Object[] finderArgs = null;
152    
153                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
154                                    (orderByComparator == null)) {
155                            pagination = false;
156                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
157                            finderArgs = new Object[] { groupId };
158                    }
159                    else {
160                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
161                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
162                    }
163    
164                    List<MBBan> list = (List<MBBan>)FinderCacheUtil.getResult(finderPath,
165                                    finderArgs, this);
166    
167                    if ((list != null) && !list.isEmpty()) {
168                            for (MBBan mbBan : list) {
169                                    if ((groupId != mbBan.getGroupId())) {
170                                            list = null;
171    
172                                            break;
173                                    }
174                            }
175                    }
176    
177                    if (list == null) {
178                            StringBundler query = null;
179    
180                            if (orderByComparator != null) {
181                                    query = new StringBundler(3 +
182                                                    (orderByComparator.getOrderByFields().length * 3));
183                            }
184                            else {
185                                    query = new StringBundler(3);
186                            }
187    
188                            query.append(_SQL_SELECT_MBBAN_WHERE);
189    
190                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
191    
192                            if (orderByComparator != null) {
193                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
194                                            orderByComparator);
195                            }
196                            else
197                             if (pagination) {
198                                    query.append(MBBanModelImpl.ORDER_BY_JPQL);
199                            }
200    
201                            String sql = query.toString();
202    
203                            Session session = null;
204    
205                            try {
206                                    session = openSession();
207    
208                                    Query q = session.createQuery(sql);
209    
210                                    QueryPos qPos = QueryPos.getInstance(q);
211    
212                                    qPos.add(groupId);
213    
214                                    if (!pagination) {
215                                            list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
216                                                            end, false);
217    
218                                            Collections.sort(list);
219    
220                                            list = new UnmodifiableList<MBBan>(list);
221                                    }
222                                    else {
223                                            list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
224                                                            end);
225                                    }
226    
227                                    cacheResult(list);
228    
229                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
230                            }
231                            catch (Exception e) {
232                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
233    
234                                    throw processException(e);
235                            }
236                            finally {
237                                    closeSession(session);
238                            }
239                    }
240    
241                    return list;
242            }
243    
244            /**
245             * Returns the first message boards ban in the ordered set where groupId = &#63;.
246             *
247             * @param groupId the group ID
248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
249             * @return the first matching message boards ban
250             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a matching message boards ban could not be found
251             * @throws SystemException if a system exception occurred
252             */
253            public MBBan findByGroupId_First(long groupId,
254                    OrderByComparator orderByComparator)
255                    throws NoSuchBanException, SystemException {
256                    MBBan mbBan = fetchByGroupId_First(groupId, orderByComparator);
257    
258                    if (mbBan != null) {
259                            return mbBan;
260                    }
261    
262                    StringBundler msg = new StringBundler(4);
263    
264                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
265    
266                    msg.append("groupId=");
267                    msg.append(groupId);
268    
269                    msg.append(StringPool.CLOSE_CURLY_BRACE);
270    
271                    throw new NoSuchBanException(msg.toString());
272            }
273    
274            /**
275             * Returns the first message boards ban in the ordered set where groupId = &#63;.
276             *
277             * @param groupId the group ID
278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
279             * @return the first matching message boards ban, or <code>null</code> if a matching message boards ban could not be found
280             * @throws SystemException if a system exception occurred
281             */
282            public MBBan fetchByGroupId_First(long groupId,
283                    OrderByComparator orderByComparator) throws SystemException {
284                    List<MBBan> list = findByGroupId(groupId, 0, 1, orderByComparator);
285    
286                    if (!list.isEmpty()) {
287                            return list.get(0);
288                    }
289    
290                    return null;
291            }
292    
293            /**
294             * Returns the last message boards ban in the ordered set where groupId = &#63;.
295             *
296             * @param groupId the group ID
297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
298             * @return the last matching message boards ban
299             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a matching message boards ban could not be found
300             * @throws SystemException if a system exception occurred
301             */
302            public MBBan findByGroupId_Last(long groupId,
303                    OrderByComparator orderByComparator)
304                    throws NoSuchBanException, SystemException {
305                    MBBan mbBan = fetchByGroupId_Last(groupId, orderByComparator);
306    
307                    if (mbBan != null) {
308                            return mbBan;
309                    }
310    
311                    StringBundler msg = new StringBundler(4);
312    
313                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
314    
315                    msg.append("groupId=");
316                    msg.append(groupId);
317    
318                    msg.append(StringPool.CLOSE_CURLY_BRACE);
319    
320                    throw new NoSuchBanException(msg.toString());
321            }
322    
323            /**
324             * Returns the last message boards ban in the ordered set where groupId = &#63;.
325             *
326             * @param groupId the group ID
327             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
328             * @return the last matching message boards ban, or <code>null</code> if a matching message boards ban could not be found
329             * @throws SystemException if a system exception occurred
330             */
331            public MBBan fetchByGroupId_Last(long groupId,
332                    OrderByComparator orderByComparator) throws SystemException {
333                    int count = countByGroupId(groupId);
334    
335                    List<MBBan> list = findByGroupId(groupId, count - 1, count,
336                                    orderByComparator);
337    
338                    if (!list.isEmpty()) {
339                            return list.get(0);
340                    }
341    
342                    return null;
343            }
344    
345            /**
346             * Returns the message boards bans before and after the current message boards ban in the ordered set where groupId = &#63;.
347             *
348             * @param banId the primary key of the current message boards ban
349             * @param groupId the group ID
350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
351             * @return the previous, current, and next message boards ban
352             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a message boards ban with the primary key could not be found
353             * @throws SystemException if a system exception occurred
354             */
355            public MBBan[] findByGroupId_PrevAndNext(long banId, long groupId,
356                    OrderByComparator orderByComparator)
357                    throws NoSuchBanException, SystemException {
358                    MBBan mbBan = findByPrimaryKey(banId);
359    
360                    Session session = null;
361    
362                    try {
363                            session = openSession();
364    
365                            MBBan[] array = new MBBanImpl[3];
366    
367                            array[0] = getByGroupId_PrevAndNext(session, mbBan, groupId,
368                                            orderByComparator, true);
369    
370                            array[1] = mbBan;
371    
372                            array[2] = getByGroupId_PrevAndNext(session, mbBan, groupId,
373                                            orderByComparator, false);
374    
375                            return array;
376                    }
377                    catch (Exception e) {
378                            throw processException(e);
379                    }
380                    finally {
381                            closeSession(session);
382                    }
383            }
384    
385            protected MBBan getByGroupId_PrevAndNext(Session session, MBBan mbBan,
386                    long groupId, OrderByComparator orderByComparator, boolean previous) {
387                    StringBundler query = null;
388    
389                    if (orderByComparator != null) {
390                            query = new StringBundler(6 +
391                                            (orderByComparator.getOrderByFields().length * 6));
392                    }
393                    else {
394                            query = new StringBundler(3);
395                    }
396    
397                    query.append(_SQL_SELECT_MBBAN_WHERE);
398    
399                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
400    
401                    if (orderByComparator != null) {
402                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
403    
404                            if (orderByConditionFields.length > 0) {
405                                    query.append(WHERE_AND);
406                            }
407    
408                            for (int i = 0; i < orderByConditionFields.length; i++) {
409                                    query.append(_ORDER_BY_ENTITY_ALIAS);
410                                    query.append(orderByConditionFields[i]);
411    
412                                    if ((i + 1) < orderByConditionFields.length) {
413                                            if (orderByComparator.isAscending() ^ previous) {
414                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
415                                            }
416                                            else {
417                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
418                                            }
419                                    }
420                                    else {
421                                            if (orderByComparator.isAscending() ^ previous) {
422                                                    query.append(WHERE_GREATER_THAN);
423                                            }
424                                            else {
425                                                    query.append(WHERE_LESSER_THAN);
426                                            }
427                                    }
428                            }
429    
430                            query.append(ORDER_BY_CLAUSE);
431    
432                            String[] orderByFields = orderByComparator.getOrderByFields();
433    
434                            for (int i = 0; i < orderByFields.length; i++) {
435                                    query.append(_ORDER_BY_ENTITY_ALIAS);
436                                    query.append(orderByFields[i]);
437    
438                                    if ((i + 1) < orderByFields.length) {
439                                            if (orderByComparator.isAscending() ^ previous) {
440                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
441                                            }
442                                            else {
443                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
444                                            }
445                                    }
446                                    else {
447                                            if (orderByComparator.isAscending() ^ previous) {
448                                                    query.append(ORDER_BY_ASC);
449                                            }
450                                            else {
451                                                    query.append(ORDER_BY_DESC);
452                                            }
453                                    }
454                            }
455                    }
456                    else {
457                            query.append(MBBanModelImpl.ORDER_BY_JPQL);
458                    }
459    
460                    String sql = query.toString();
461    
462                    Query q = session.createQuery(sql);
463    
464                    q.setFirstResult(0);
465                    q.setMaxResults(2);
466    
467                    QueryPos qPos = QueryPos.getInstance(q);
468    
469                    qPos.add(groupId);
470    
471                    if (orderByComparator != null) {
472                            Object[] values = orderByComparator.getOrderByConditionValues(mbBan);
473    
474                            for (Object value : values) {
475                                    qPos.add(value);
476                            }
477                    }
478    
479                    List<MBBan> list = q.list();
480    
481                    if (list.size() == 2) {
482                            return list.get(1);
483                    }
484                    else {
485                            return null;
486                    }
487            }
488    
489            /**
490             * Removes all the message boards bans where groupId = &#63; from the database.
491             *
492             * @param groupId the group ID
493             * @throws SystemException if a system exception occurred
494             */
495            public void removeByGroupId(long groupId) throws SystemException {
496                    for (MBBan mbBan : findByGroupId(groupId, QueryUtil.ALL_POS,
497                                    QueryUtil.ALL_POS, null)) {
498                            remove(mbBan);
499                    }
500            }
501    
502            /**
503             * Returns the number of message boards bans where groupId = &#63;.
504             *
505             * @param groupId the group ID
506             * @return the number of matching message boards bans
507             * @throws SystemException if a system exception occurred
508             */
509            public int countByGroupId(long groupId) throws SystemException {
510                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
511    
512                    Object[] finderArgs = new Object[] { groupId };
513    
514                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
515                                    this);
516    
517                    if (count == null) {
518                            StringBundler query = new StringBundler(2);
519    
520                            query.append(_SQL_COUNT_MBBAN_WHERE);
521    
522                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
523    
524                            String sql = query.toString();
525    
526                            Session session = null;
527    
528                            try {
529                                    session = openSession();
530    
531                                    Query q = session.createQuery(sql);
532    
533                                    QueryPos qPos = QueryPos.getInstance(q);
534    
535                                    qPos.add(groupId);
536    
537                                    count = (Long)q.uniqueResult();
538    
539                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
540                            }
541                            catch (Exception e) {
542                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
543    
544                                    throw processException(e);
545                            }
546                            finally {
547                                    closeSession(session);
548                            }
549                    }
550    
551                    return count.intValue();
552            }
553    
554            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbBan.groupId = ?";
555            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
556                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
557                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
558                            new String[] {
559                                    Long.class.getName(),
560                                    
561                            Integer.class.getName(), Integer.class.getName(),
562                                    OrderByComparator.class.getName()
563                            });
564            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
565                    new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
566                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
567                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
568                            new String[] { Long.class.getName() },
569                            MBBanModelImpl.USERID_COLUMN_BITMASK);
570            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
571                            MBBanModelImpl.FINDER_CACHE_ENABLED, Long.class,
572                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
573                            new String[] { Long.class.getName() });
574    
575            /**
576             * Returns all the message boards bans where userId = &#63;.
577             *
578             * @param userId the user ID
579             * @return the matching message boards bans
580             * @throws SystemException if a system exception occurred
581             */
582            public List<MBBan> findByUserId(long userId) throws SystemException {
583                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
584            }
585    
586            /**
587             * Returns a range of all the message boards bans where userId = &#63;.
588             *
589             * <p>
590             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.messageboards.model.impl.MBBanModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
591             * </p>
592             *
593             * @param userId the user ID
594             * @param start the lower bound of the range of message boards bans
595             * @param end the upper bound of the range of message boards bans (not inclusive)
596             * @return the range of matching message boards bans
597             * @throws SystemException if a system exception occurred
598             */
599            public List<MBBan> findByUserId(long userId, int start, int end)
600                    throws SystemException {
601                    return findByUserId(userId, start, end, null);
602            }
603    
604            /**
605             * Returns an ordered range of all the message boards bans where userId = &#63;.
606             *
607             * <p>
608             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.messageboards.model.impl.MBBanModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
609             * </p>
610             *
611             * @param userId the user ID
612             * @param start the lower bound of the range of message boards bans
613             * @param end the upper bound of the range of message boards bans (not inclusive)
614             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
615             * @return the ordered range of matching message boards bans
616             * @throws SystemException if a system exception occurred
617             */
618            public List<MBBan> findByUserId(long userId, int start, int end,
619                    OrderByComparator orderByComparator) throws SystemException {
620                    boolean pagination = true;
621                    FinderPath finderPath = null;
622                    Object[] finderArgs = null;
623    
624                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
625                                    (orderByComparator == null)) {
626                            pagination = false;
627                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
628                            finderArgs = new Object[] { userId };
629                    }
630                    else {
631                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
632                            finderArgs = new Object[] { userId, start, end, orderByComparator };
633                    }
634    
635                    List<MBBan> list = (List<MBBan>)FinderCacheUtil.getResult(finderPath,
636                                    finderArgs, this);
637    
638                    if ((list != null) && !list.isEmpty()) {
639                            for (MBBan mbBan : list) {
640                                    if ((userId != mbBan.getUserId())) {
641                                            list = null;
642    
643                                            break;
644                                    }
645                            }
646                    }
647    
648                    if (list == null) {
649                            StringBundler query = null;
650    
651                            if (orderByComparator != null) {
652                                    query = new StringBundler(3 +
653                                                    (orderByComparator.getOrderByFields().length * 3));
654                            }
655                            else {
656                                    query = new StringBundler(3);
657                            }
658    
659                            query.append(_SQL_SELECT_MBBAN_WHERE);
660    
661                            query.append(_FINDER_COLUMN_USERID_USERID_2);
662    
663                            if (orderByComparator != null) {
664                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
665                                            orderByComparator);
666                            }
667                            else
668                             if (pagination) {
669                                    query.append(MBBanModelImpl.ORDER_BY_JPQL);
670                            }
671    
672                            String sql = query.toString();
673    
674                            Session session = null;
675    
676                            try {
677                                    session = openSession();
678    
679                                    Query q = session.createQuery(sql);
680    
681                                    QueryPos qPos = QueryPos.getInstance(q);
682    
683                                    qPos.add(userId);
684    
685                                    if (!pagination) {
686                                            list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
687                                                            end, false);
688    
689                                            Collections.sort(list);
690    
691                                            list = new UnmodifiableList<MBBan>(list);
692                                    }
693                                    else {
694                                            list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
695                                                            end);
696                                    }
697    
698                                    cacheResult(list);
699    
700                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
701                            }
702                            catch (Exception e) {
703                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
704    
705                                    throw processException(e);
706                            }
707                            finally {
708                                    closeSession(session);
709                            }
710                    }
711    
712                    return list;
713            }
714    
715            /**
716             * Returns the first message boards ban in the ordered set where userId = &#63;.
717             *
718             * @param userId the user ID
719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
720             * @return the first matching message boards ban
721             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a matching message boards ban could not be found
722             * @throws SystemException if a system exception occurred
723             */
724            public MBBan findByUserId_First(long userId,
725                    OrderByComparator orderByComparator)
726                    throws NoSuchBanException, SystemException {
727                    MBBan mbBan = fetchByUserId_First(userId, orderByComparator);
728    
729                    if (mbBan != null) {
730                            return mbBan;
731                    }
732    
733                    StringBundler msg = new StringBundler(4);
734    
735                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
736    
737                    msg.append("userId=");
738                    msg.append(userId);
739    
740                    msg.append(StringPool.CLOSE_CURLY_BRACE);
741    
742                    throw new NoSuchBanException(msg.toString());
743            }
744    
745            /**
746             * Returns the first message boards ban in the ordered set where userId = &#63;.
747             *
748             * @param userId the user ID
749             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
750             * @return the first matching message boards ban, or <code>null</code> if a matching message boards ban could not be found
751             * @throws SystemException if a system exception occurred
752             */
753            public MBBan fetchByUserId_First(long userId,
754                    OrderByComparator orderByComparator) throws SystemException {
755                    List<MBBan> list = findByUserId(userId, 0, 1, orderByComparator);
756    
757                    if (!list.isEmpty()) {
758                            return list.get(0);
759                    }
760    
761                    return null;
762            }
763    
764            /**
765             * Returns the last message boards ban in the ordered set where userId = &#63;.
766             *
767             * @param userId the user ID
768             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
769             * @return the last matching message boards ban
770             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a matching message boards ban could not be found
771             * @throws SystemException if a system exception occurred
772             */
773            public MBBan findByUserId_Last(long userId,
774                    OrderByComparator orderByComparator)
775                    throws NoSuchBanException, SystemException {
776                    MBBan mbBan = fetchByUserId_Last(userId, orderByComparator);
777    
778                    if (mbBan != null) {
779                            return mbBan;
780                    }
781    
782                    StringBundler msg = new StringBundler(4);
783    
784                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
785    
786                    msg.append("userId=");
787                    msg.append(userId);
788    
789                    msg.append(StringPool.CLOSE_CURLY_BRACE);
790    
791                    throw new NoSuchBanException(msg.toString());
792            }
793    
794            /**
795             * Returns the last message boards ban in the ordered set where userId = &#63;.
796             *
797             * @param userId the user ID
798             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
799             * @return the last matching message boards ban, or <code>null</code> if a matching message boards ban could not be found
800             * @throws SystemException if a system exception occurred
801             */
802            public MBBan fetchByUserId_Last(long userId,
803                    OrderByComparator orderByComparator) throws SystemException {
804                    int count = countByUserId(userId);
805    
806                    List<MBBan> list = findByUserId(userId, count - 1, count,
807                                    orderByComparator);
808    
809                    if (!list.isEmpty()) {
810                            return list.get(0);
811                    }
812    
813                    return null;
814            }
815    
816            /**
817             * Returns the message boards bans before and after the current message boards ban in the ordered set where userId = &#63;.
818             *
819             * @param banId the primary key of the current message boards ban
820             * @param userId the user ID
821             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
822             * @return the previous, current, and next message boards ban
823             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a message boards ban with the primary key could not be found
824             * @throws SystemException if a system exception occurred
825             */
826            public MBBan[] findByUserId_PrevAndNext(long banId, long userId,
827                    OrderByComparator orderByComparator)
828                    throws NoSuchBanException, SystemException {
829                    MBBan mbBan = findByPrimaryKey(banId);
830    
831                    Session session = null;
832    
833                    try {
834                            session = openSession();
835    
836                            MBBan[] array = new MBBanImpl[3];
837    
838                            array[0] = getByUserId_PrevAndNext(session, mbBan, userId,
839                                            orderByComparator, true);
840    
841                            array[1] = mbBan;
842    
843                            array[2] = getByUserId_PrevAndNext(session, mbBan, userId,
844                                            orderByComparator, false);
845    
846                            return array;
847                    }
848                    catch (Exception e) {
849                            throw processException(e);
850                    }
851                    finally {
852                            closeSession(session);
853                    }
854            }
855    
856            protected MBBan getByUserId_PrevAndNext(Session session, MBBan mbBan,
857                    long userId, OrderByComparator orderByComparator, boolean previous) {
858                    StringBundler query = null;
859    
860                    if (orderByComparator != null) {
861                            query = new StringBundler(6 +
862                                            (orderByComparator.getOrderByFields().length * 6));
863                    }
864                    else {
865                            query = new StringBundler(3);
866                    }
867    
868                    query.append(_SQL_SELECT_MBBAN_WHERE);
869    
870                    query.append(_FINDER_COLUMN_USERID_USERID_2);
871    
872                    if (orderByComparator != null) {
873                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
874    
875                            if (orderByConditionFields.length > 0) {
876                                    query.append(WHERE_AND);
877                            }
878    
879                            for (int i = 0; i < orderByConditionFields.length; i++) {
880                                    query.append(_ORDER_BY_ENTITY_ALIAS);
881                                    query.append(orderByConditionFields[i]);
882    
883                                    if ((i + 1) < orderByConditionFields.length) {
884                                            if (orderByComparator.isAscending() ^ previous) {
885                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
886                                            }
887                                            else {
888                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
889                                            }
890                                    }
891                                    else {
892                                            if (orderByComparator.isAscending() ^ previous) {
893                                                    query.append(WHERE_GREATER_THAN);
894                                            }
895                                            else {
896                                                    query.append(WHERE_LESSER_THAN);
897                                            }
898                                    }
899                            }
900    
901                            query.append(ORDER_BY_CLAUSE);
902    
903                            String[] orderByFields = orderByComparator.getOrderByFields();
904    
905                            for (int i = 0; i < orderByFields.length; i++) {
906                                    query.append(_ORDER_BY_ENTITY_ALIAS);
907                                    query.append(orderByFields[i]);
908    
909                                    if ((i + 1) < orderByFields.length) {
910                                            if (orderByComparator.isAscending() ^ previous) {
911                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
912                                            }
913                                            else {
914                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
915                                            }
916                                    }
917                                    else {
918                                            if (orderByComparator.isAscending() ^ previous) {
919                                                    query.append(ORDER_BY_ASC);
920                                            }
921                                            else {
922                                                    query.append(ORDER_BY_DESC);
923                                            }
924                                    }
925                            }
926                    }
927                    else {
928                            query.append(MBBanModelImpl.ORDER_BY_JPQL);
929                    }
930    
931                    String sql = query.toString();
932    
933                    Query q = session.createQuery(sql);
934    
935                    q.setFirstResult(0);
936                    q.setMaxResults(2);
937    
938                    QueryPos qPos = QueryPos.getInstance(q);
939    
940                    qPos.add(userId);
941    
942                    if (orderByComparator != null) {
943                            Object[] values = orderByComparator.getOrderByConditionValues(mbBan);
944    
945                            for (Object value : values) {
946                                    qPos.add(value);
947                            }
948                    }
949    
950                    List<MBBan> list = q.list();
951    
952                    if (list.size() == 2) {
953                            return list.get(1);
954                    }
955                    else {
956                            return null;
957                    }
958            }
959    
960            /**
961             * Removes all the message boards bans where userId = &#63; from the database.
962             *
963             * @param userId the user ID
964             * @throws SystemException if a system exception occurred
965             */
966            public void removeByUserId(long userId) throws SystemException {
967                    for (MBBan mbBan : findByUserId(userId, QueryUtil.ALL_POS,
968                                    QueryUtil.ALL_POS, null)) {
969                            remove(mbBan);
970                    }
971            }
972    
973            /**
974             * Returns the number of message boards bans where userId = &#63;.
975             *
976             * @param userId the user ID
977             * @return the number of matching message boards bans
978             * @throws SystemException if a system exception occurred
979             */
980            public int countByUserId(long userId) throws SystemException {
981                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
982    
983                    Object[] finderArgs = new Object[] { userId };
984    
985                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
986                                    this);
987    
988                    if (count == null) {
989                            StringBundler query = new StringBundler(2);
990    
991                            query.append(_SQL_COUNT_MBBAN_WHERE);
992    
993                            query.append(_FINDER_COLUMN_USERID_USERID_2);
994    
995                            String sql = query.toString();
996    
997                            Session session = null;
998    
999                            try {
1000                                    session = openSession();
1001    
1002                                    Query q = session.createQuery(sql);
1003    
1004                                    QueryPos qPos = QueryPos.getInstance(q);
1005    
1006                                    qPos.add(userId);
1007    
1008                                    count = (Long)q.uniqueResult();
1009    
1010                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1011                            }
1012                            catch (Exception e) {
1013                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1014    
1015                                    throw processException(e);
1016                            }
1017                            finally {
1018                                    closeSession(session);
1019                            }
1020                    }
1021    
1022                    return count.intValue();
1023            }
1024    
1025            private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbBan.userId = ?";
1026            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_BANUSERID =
1027                    new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1028                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
1029                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByBanUserId",
1030                            new String[] {
1031                                    Long.class.getName(),
1032                                    
1033                            Integer.class.getName(), Integer.class.getName(),
1034                                    OrderByComparator.class.getName()
1035                            });
1036            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BANUSERID =
1037                    new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1038                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
1039                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByBanUserId",
1040                            new String[] { Long.class.getName() },
1041                            MBBanModelImpl.BANUSERID_COLUMN_BITMASK);
1042            public static final FinderPath FINDER_PATH_COUNT_BY_BANUSERID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1043                            MBBanModelImpl.FINDER_CACHE_ENABLED, Long.class,
1044                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByBanUserId",
1045                            new String[] { Long.class.getName() });
1046    
1047            /**
1048             * Returns all the message boards bans where banUserId = &#63;.
1049             *
1050             * @param banUserId the ban user ID
1051             * @return the matching message boards bans
1052             * @throws SystemException if a system exception occurred
1053             */
1054            public List<MBBan> findByBanUserId(long banUserId)
1055                    throws SystemException {
1056                    return findByBanUserId(banUserId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1057                            null);
1058            }
1059    
1060            /**
1061             * Returns a range of all the message boards bans where banUserId = &#63;.
1062             *
1063             * <p>
1064             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.messageboards.model.impl.MBBanModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1065             * </p>
1066             *
1067             * @param banUserId the ban user ID
1068             * @param start the lower bound of the range of message boards bans
1069             * @param end the upper bound of the range of message boards bans (not inclusive)
1070             * @return the range of matching message boards bans
1071             * @throws SystemException if a system exception occurred
1072             */
1073            public List<MBBan> findByBanUserId(long banUserId, int start, int end)
1074                    throws SystemException {
1075                    return findByBanUserId(banUserId, start, end, null);
1076            }
1077    
1078            /**
1079             * Returns an ordered range of all the message boards bans where banUserId = &#63;.
1080             *
1081             * <p>
1082             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.messageboards.model.impl.MBBanModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1083             * </p>
1084             *
1085             * @param banUserId the ban user ID
1086             * @param start the lower bound of the range of message boards bans
1087             * @param end the upper bound of the range of message boards bans (not inclusive)
1088             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1089             * @return the ordered range of matching message boards bans
1090             * @throws SystemException if a system exception occurred
1091             */
1092            public List<MBBan> findByBanUserId(long banUserId, int start, int end,
1093                    OrderByComparator orderByComparator) throws SystemException {
1094                    boolean pagination = true;
1095                    FinderPath finderPath = null;
1096                    Object[] finderArgs = null;
1097    
1098                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1099                                    (orderByComparator == null)) {
1100                            pagination = false;
1101                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BANUSERID;
1102                            finderArgs = new Object[] { banUserId };
1103                    }
1104                    else {
1105                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_BANUSERID;
1106                            finderArgs = new Object[] { banUserId, start, end, orderByComparator };
1107                    }
1108    
1109                    List<MBBan> list = (List<MBBan>)FinderCacheUtil.getResult(finderPath,
1110                                    finderArgs, this);
1111    
1112                    if ((list != null) && !list.isEmpty()) {
1113                            for (MBBan mbBan : list) {
1114                                    if ((banUserId != mbBan.getBanUserId())) {
1115                                            list = null;
1116    
1117                                            break;
1118                                    }
1119                            }
1120                    }
1121    
1122                    if (list == null) {
1123                            StringBundler query = null;
1124    
1125                            if (orderByComparator != null) {
1126                                    query = new StringBundler(3 +
1127                                                    (orderByComparator.getOrderByFields().length * 3));
1128                            }
1129                            else {
1130                                    query = new StringBundler(3);
1131                            }
1132    
1133                            query.append(_SQL_SELECT_MBBAN_WHERE);
1134    
1135                            query.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
1136    
1137                            if (orderByComparator != null) {
1138                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1139                                            orderByComparator);
1140                            }
1141                            else
1142                             if (pagination) {
1143                                    query.append(MBBanModelImpl.ORDER_BY_JPQL);
1144                            }
1145    
1146                            String sql = query.toString();
1147    
1148                            Session session = null;
1149    
1150                            try {
1151                                    session = openSession();
1152    
1153                                    Query q = session.createQuery(sql);
1154    
1155                                    QueryPos qPos = QueryPos.getInstance(q);
1156    
1157                                    qPos.add(banUserId);
1158    
1159                                    if (!pagination) {
1160                                            list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
1161                                                            end, false);
1162    
1163                                            Collections.sort(list);
1164    
1165                                            list = new UnmodifiableList<MBBan>(list);
1166                                    }
1167                                    else {
1168                                            list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
1169                                                            end);
1170                                    }
1171    
1172                                    cacheResult(list);
1173    
1174                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1175                            }
1176                            catch (Exception e) {
1177                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1178    
1179                                    throw processException(e);
1180                            }
1181                            finally {
1182                                    closeSession(session);
1183                            }
1184                    }
1185    
1186                    return list;
1187            }
1188    
1189            /**
1190             * Returns the first message boards ban in the ordered set where banUserId = &#63;.
1191             *
1192             * @param banUserId the ban user ID
1193             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1194             * @return the first matching message boards ban
1195             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a matching message boards ban could not be found
1196             * @throws SystemException if a system exception occurred
1197             */
1198            public MBBan findByBanUserId_First(long banUserId,
1199                    OrderByComparator orderByComparator)
1200                    throws NoSuchBanException, SystemException {
1201                    MBBan mbBan = fetchByBanUserId_First(banUserId, orderByComparator);
1202    
1203                    if (mbBan != null) {
1204                            return mbBan;
1205                    }
1206    
1207                    StringBundler msg = new StringBundler(4);
1208    
1209                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1210    
1211                    msg.append("banUserId=");
1212                    msg.append(banUserId);
1213    
1214                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1215    
1216                    throw new NoSuchBanException(msg.toString());
1217            }
1218    
1219            /**
1220             * Returns the first message boards ban in the ordered set where banUserId = &#63;.
1221             *
1222             * @param banUserId the ban user ID
1223             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1224             * @return the first matching message boards ban, or <code>null</code> if a matching message boards ban could not be found
1225             * @throws SystemException if a system exception occurred
1226             */
1227            public MBBan fetchByBanUserId_First(long banUserId,
1228                    OrderByComparator orderByComparator) throws SystemException {
1229                    List<MBBan> list = findByBanUserId(banUserId, 0, 1, orderByComparator);
1230    
1231                    if (!list.isEmpty()) {
1232                            return list.get(0);
1233                    }
1234    
1235                    return null;
1236            }
1237    
1238            /**
1239             * Returns the last message boards ban in the ordered set where banUserId = &#63;.
1240             *
1241             * @param banUserId the ban user ID
1242             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1243             * @return the last matching message boards ban
1244             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a matching message boards ban could not be found
1245             * @throws SystemException if a system exception occurred
1246             */
1247            public MBBan findByBanUserId_Last(long banUserId,
1248                    OrderByComparator orderByComparator)
1249                    throws NoSuchBanException, SystemException {
1250                    MBBan mbBan = fetchByBanUserId_Last(banUserId, orderByComparator);
1251    
1252                    if (mbBan != null) {
1253                            return mbBan;
1254                    }
1255    
1256                    StringBundler msg = new StringBundler(4);
1257    
1258                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1259    
1260                    msg.append("banUserId=");
1261                    msg.append(banUserId);
1262    
1263                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1264    
1265                    throw new NoSuchBanException(msg.toString());
1266            }
1267    
1268            /**
1269             * Returns the last message boards ban in the ordered set where banUserId = &#63;.
1270             *
1271             * @param banUserId the ban user ID
1272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1273             * @return the last matching message boards ban, or <code>null</code> if a matching message boards ban could not be found
1274             * @throws SystemException if a system exception occurred
1275             */
1276            public MBBan fetchByBanUserId_Last(long banUserId,
1277                    OrderByComparator orderByComparator) throws SystemException {
1278                    int count = countByBanUserId(banUserId);
1279    
1280                    List<MBBan> list = findByBanUserId(banUserId, count - 1, count,
1281                                    orderByComparator);
1282    
1283                    if (!list.isEmpty()) {
1284                            return list.get(0);
1285                    }
1286    
1287                    return null;
1288            }
1289    
1290            /**
1291             * Returns the message boards bans before and after the current message boards ban in the ordered set where banUserId = &#63;.
1292             *
1293             * @param banId the primary key of the current message boards ban
1294             * @param banUserId the ban user ID
1295             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1296             * @return the previous, current, and next message boards ban
1297             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a message boards ban with the primary key could not be found
1298             * @throws SystemException if a system exception occurred
1299             */
1300            public MBBan[] findByBanUserId_PrevAndNext(long banId, long banUserId,
1301                    OrderByComparator orderByComparator)
1302                    throws NoSuchBanException, SystemException {
1303                    MBBan mbBan = findByPrimaryKey(banId);
1304    
1305                    Session session = null;
1306    
1307                    try {
1308                            session = openSession();
1309    
1310                            MBBan[] array = new MBBanImpl[3];
1311    
1312                            array[0] = getByBanUserId_PrevAndNext(session, mbBan, banUserId,
1313                                            orderByComparator, true);
1314    
1315                            array[1] = mbBan;
1316    
1317                            array[2] = getByBanUserId_PrevAndNext(session, mbBan, banUserId,
1318                                            orderByComparator, false);
1319    
1320                            return array;
1321                    }
1322                    catch (Exception e) {
1323                            throw processException(e);
1324                    }
1325                    finally {
1326                            closeSession(session);
1327                    }
1328            }
1329    
1330            protected MBBan getByBanUserId_PrevAndNext(Session session, MBBan mbBan,
1331                    long banUserId, OrderByComparator orderByComparator, boolean previous) {
1332                    StringBundler query = null;
1333    
1334                    if (orderByComparator != null) {
1335                            query = new StringBundler(6 +
1336                                            (orderByComparator.getOrderByFields().length * 6));
1337                    }
1338                    else {
1339                            query = new StringBundler(3);
1340                    }
1341    
1342                    query.append(_SQL_SELECT_MBBAN_WHERE);
1343    
1344                    query.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
1345    
1346                    if (orderByComparator != null) {
1347                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1348    
1349                            if (orderByConditionFields.length > 0) {
1350                                    query.append(WHERE_AND);
1351                            }
1352    
1353                            for (int i = 0; i < orderByConditionFields.length; i++) {
1354                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1355                                    query.append(orderByConditionFields[i]);
1356    
1357                                    if ((i + 1) < orderByConditionFields.length) {
1358                                            if (orderByComparator.isAscending() ^ previous) {
1359                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1360                                            }
1361                                            else {
1362                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1363                                            }
1364                                    }
1365                                    else {
1366                                            if (orderByComparator.isAscending() ^ previous) {
1367                                                    query.append(WHERE_GREATER_THAN);
1368                                            }
1369                                            else {
1370                                                    query.append(WHERE_LESSER_THAN);
1371                                            }
1372                                    }
1373                            }
1374    
1375                            query.append(ORDER_BY_CLAUSE);
1376    
1377                            String[] orderByFields = orderByComparator.getOrderByFields();
1378    
1379                            for (int i = 0; i < orderByFields.length; i++) {
1380                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1381                                    query.append(orderByFields[i]);
1382    
1383                                    if ((i + 1) < orderByFields.length) {
1384                                            if (orderByComparator.isAscending() ^ previous) {
1385                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1386                                            }
1387                                            else {
1388                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1389                                            }
1390                                    }
1391                                    else {
1392                                            if (orderByComparator.isAscending() ^ previous) {
1393                                                    query.append(ORDER_BY_ASC);
1394                                            }
1395                                            else {
1396                                                    query.append(ORDER_BY_DESC);
1397                                            }
1398                                    }
1399                            }
1400                    }
1401                    else {
1402                            query.append(MBBanModelImpl.ORDER_BY_JPQL);
1403                    }
1404    
1405                    String sql = query.toString();
1406    
1407                    Query q = session.createQuery(sql);
1408    
1409                    q.setFirstResult(0);
1410                    q.setMaxResults(2);
1411    
1412                    QueryPos qPos = QueryPos.getInstance(q);
1413    
1414                    qPos.add(banUserId);
1415    
1416                    if (orderByComparator != null) {
1417                            Object[] values = orderByComparator.getOrderByConditionValues(mbBan);
1418    
1419                            for (Object value : values) {
1420                                    qPos.add(value);
1421                            }
1422                    }
1423    
1424                    List<MBBan> list = q.list();
1425    
1426                    if (list.size() == 2) {
1427                            return list.get(1);
1428                    }
1429                    else {
1430                            return null;
1431                    }
1432            }
1433    
1434            /**
1435             * Removes all the message boards bans where banUserId = &#63; from the database.
1436             *
1437             * @param banUserId the ban user ID
1438             * @throws SystemException if a system exception occurred
1439             */
1440            public void removeByBanUserId(long banUserId) throws SystemException {
1441                    for (MBBan mbBan : findByBanUserId(banUserId, QueryUtil.ALL_POS,
1442                                    QueryUtil.ALL_POS, null)) {
1443                            remove(mbBan);
1444                    }
1445            }
1446    
1447            /**
1448             * Returns the number of message boards bans where banUserId = &#63;.
1449             *
1450             * @param banUserId the ban user ID
1451             * @return the number of matching message boards bans
1452             * @throws SystemException if a system exception occurred
1453             */
1454            public int countByBanUserId(long banUserId) throws SystemException {
1455                    FinderPath finderPath = FINDER_PATH_COUNT_BY_BANUSERID;
1456    
1457                    Object[] finderArgs = new Object[] { banUserId };
1458    
1459                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1460                                    this);
1461    
1462                    if (count == null) {
1463                            StringBundler query = new StringBundler(2);
1464    
1465                            query.append(_SQL_COUNT_MBBAN_WHERE);
1466    
1467                            query.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
1468    
1469                            String sql = query.toString();
1470    
1471                            Session session = null;
1472    
1473                            try {
1474                                    session = openSession();
1475    
1476                                    Query q = session.createQuery(sql);
1477    
1478                                    QueryPos qPos = QueryPos.getInstance(q);
1479    
1480                                    qPos.add(banUserId);
1481    
1482                                    count = (Long)q.uniqueResult();
1483    
1484                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1485                            }
1486                            catch (Exception e) {
1487                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1488    
1489                                    throw processException(e);
1490                            }
1491                            finally {
1492                                    closeSession(session);
1493                            }
1494                    }
1495    
1496                    return count.intValue();
1497            }
1498    
1499            private static final String _FINDER_COLUMN_BANUSERID_BANUSERID_2 = "mbBan.banUserId = ?";
1500            public static final FinderPath FINDER_PATH_FETCH_BY_G_B = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1501                            MBBanModelImpl.FINDER_CACHE_ENABLED, MBBanImpl.class,
1502                            FINDER_CLASS_NAME_ENTITY, "fetchByG_B",
1503                            new String[] { Long.class.getName(), Long.class.getName() },
1504                            MBBanModelImpl.GROUPID_COLUMN_BITMASK |
1505                            MBBanModelImpl.BANUSERID_COLUMN_BITMASK);
1506            public static final FinderPath FINDER_PATH_COUNT_BY_G_B = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1507                            MBBanModelImpl.FINDER_CACHE_ENABLED, Long.class,
1508                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_B",
1509                            new String[] { Long.class.getName(), Long.class.getName() });
1510    
1511            /**
1512             * Returns the message boards ban where groupId = &#63; and banUserId = &#63; or throws a {@link com.liferay.portlet.messageboards.NoSuchBanException} if it could not be found.
1513             *
1514             * @param groupId the group ID
1515             * @param banUserId the ban user ID
1516             * @return the matching message boards ban
1517             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a matching message boards ban could not be found
1518             * @throws SystemException if a system exception occurred
1519             */
1520            public MBBan findByG_B(long groupId, long banUserId)
1521                    throws NoSuchBanException, SystemException {
1522                    MBBan mbBan = fetchByG_B(groupId, banUserId);
1523    
1524                    if (mbBan == null) {
1525                            StringBundler msg = new StringBundler(6);
1526    
1527                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1528    
1529                            msg.append("groupId=");
1530                            msg.append(groupId);
1531    
1532                            msg.append(", banUserId=");
1533                            msg.append(banUserId);
1534    
1535                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1536    
1537                            if (_log.isWarnEnabled()) {
1538                                    _log.warn(msg.toString());
1539                            }
1540    
1541                            throw new NoSuchBanException(msg.toString());
1542                    }
1543    
1544                    return mbBan;
1545            }
1546    
1547            /**
1548             * Returns the message boards ban where groupId = &#63; and banUserId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1549             *
1550             * @param groupId the group ID
1551             * @param banUserId the ban user ID
1552             * @return the matching message boards ban, or <code>null</code> if a matching message boards ban could not be found
1553             * @throws SystemException if a system exception occurred
1554             */
1555            public MBBan fetchByG_B(long groupId, long banUserId)
1556                    throws SystemException {
1557                    return fetchByG_B(groupId, banUserId, true);
1558            }
1559    
1560            /**
1561             * Returns the message boards ban where groupId = &#63; and banUserId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1562             *
1563             * @param groupId the group ID
1564             * @param banUserId the ban user ID
1565             * @param retrieveFromCache whether to use the finder cache
1566             * @return the matching message boards ban, or <code>null</code> if a matching message boards ban could not be found
1567             * @throws SystemException if a system exception occurred
1568             */
1569            public MBBan fetchByG_B(long groupId, long banUserId,
1570                    boolean retrieveFromCache) throws SystemException {
1571                    Object[] finderArgs = new Object[] { groupId, banUserId };
1572    
1573                    Object result = null;
1574    
1575                    if (retrieveFromCache) {
1576                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_B,
1577                                            finderArgs, this);
1578                    }
1579    
1580                    if (result instanceof MBBan) {
1581                            MBBan mbBan = (MBBan)result;
1582    
1583                            if ((groupId != mbBan.getGroupId()) ||
1584                                            (banUserId != mbBan.getBanUserId())) {
1585                                    result = null;
1586                            }
1587                    }
1588    
1589                    if (result == null) {
1590                            StringBundler query = new StringBundler(4);
1591    
1592                            query.append(_SQL_SELECT_MBBAN_WHERE);
1593    
1594                            query.append(_FINDER_COLUMN_G_B_GROUPID_2);
1595    
1596                            query.append(_FINDER_COLUMN_G_B_BANUSERID_2);
1597    
1598                            String sql = query.toString();
1599    
1600                            Session session = null;
1601    
1602                            try {
1603                                    session = openSession();
1604    
1605                                    Query q = session.createQuery(sql);
1606    
1607                                    QueryPos qPos = QueryPos.getInstance(q);
1608    
1609                                    qPos.add(groupId);
1610    
1611                                    qPos.add(banUserId);
1612    
1613                                    List<MBBan> list = q.list();
1614    
1615                                    if (list.isEmpty()) {
1616                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B,
1617                                                    finderArgs, list);
1618                                    }
1619                                    else {
1620                                            MBBan mbBan = list.get(0);
1621    
1622                                            result = mbBan;
1623    
1624                                            cacheResult(mbBan);
1625    
1626                                            if ((mbBan.getGroupId() != groupId) ||
1627                                                            (mbBan.getBanUserId() != banUserId)) {
1628                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B,
1629                                                            finderArgs, mbBan);
1630                                            }
1631                                    }
1632                            }
1633                            catch (Exception e) {
1634                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_B,
1635                                            finderArgs);
1636    
1637                                    throw processException(e);
1638                            }
1639                            finally {
1640                                    closeSession(session);
1641                            }
1642                    }
1643    
1644                    if (result instanceof List<?>) {
1645                            return null;
1646                    }
1647                    else {
1648                            return (MBBan)result;
1649                    }
1650            }
1651    
1652            /**
1653             * Removes the message boards ban where groupId = &#63; and banUserId = &#63; from the database.
1654             *
1655             * @param groupId the group ID
1656             * @param banUserId the ban user ID
1657             * @return the message boards ban that was removed
1658             * @throws SystemException if a system exception occurred
1659             */
1660            public MBBan removeByG_B(long groupId, long banUserId)
1661                    throws NoSuchBanException, SystemException {
1662                    MBBan mbBan = findByG_B(groupId, banUserId);
1663    
1664                    return remove(mbBan);
1665            }
1666    
1667            /**
1668             * Returns the number of message boards bans where groupId = &#63; and banUserId = &#63;.
1669             *
1670             * @param groupId the group ID
1671             * @param banUserId the ban user ID
1672             * @return the number of matching message boards bans
1673             * @throws SystemException if a system exception occurred
1674             */
1675            public int countByG_B(long groupId, long banUserId)
1676                    throws SystemException {
1677                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_B;
1678    
1679                    Object[] finderArgs = new Object[] { groupId, banUserId };
1680    
1681                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1682                                    this);
1683    
1684                    if (count == null) {
1685                            StringBundler query = new StringBundler(3);
1686    
1687                            query.append(_SQL_COUNT_MBBAN_WHERE);
1688    
1689                            query.append(_FINDER_COLUMN_G_B_GROUPID_2);
1690    
1691                            query.append(_FINDER_COLUMN_G_B_BANUSERID_2);
1692    
1693                            String sql = query.toString();
1694    
1695                            Session session = null;
1696    
1697                            try {
1698                                    session = openSession();
1699    
1700                                    Query q = session.createQuery(sql);
1701    
1702                                    QueryPos qPos = QueryPos.getInstance(q);
1703    
1704                                    qPos.add(groupId);
1705    
1706                                    qPos.add(banUserId);
1707    
1708                                    count = (Long)q.uniqueResult();
1709    
1710                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1711                            }
1712                            catch (Exception e) {
1713                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1714    
1715                                    throw processException(e);
1716                            }
1717                            finally {
1718                                    closeSession(session);
1719                            }
1720                    }
1721    
1722                    return count.intValue();
1723            }
1724    
1725            private static final String _FINDER_COLUMN_G_B_GROUPID_2 = "mbBan.groupId = ? AND ";
1726            private static final String _FINDER_COLUMN_G_B_BANUSERID_2 = "mbBan.banUserId = ?";
1727    
1728            /**
1729             * Caches the message boards ban in the entity cache if it is enabled.
1730             *
1731             * @param mbBan the message boards ban
1732             */
1733            public void cacheResult(MBBan mbBan) {
1734                    EntityCacheUtil.putResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1735                            MBBanImpl.class, mbBan.getPrimaryKey(), mbBan);
1736    
1737                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B,
1738                            new Object[] {
1739                                    Long.valueOf(mbBan.getGroupId()),
1740                                    Long.valueOf(mbBan.getBanUserId())
1741                            }, mbBan);
1742    
1743                    mbBan.resetOriginalValues();
1744            }
1745    
1746            /**
1747             * Caches the message boards bans in the entity cache if it is enabled.
1748             *
1749             * @param mbBans the message boards bans
1750             */
1751            public void cacheResult(List<MBBan> mbBans) {
1752                    for (MBBan mbBan : mbBans) {
1753                            if (EntityCacheUtil.getResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1754                                                    MBBanImpl.class, mbBan.getPrimaryKey()) == null) {
1755                                    cacheResult(mbBan);
1756                            }
1757                            else {
1758                                    mbBan.resetOriginalValues();
1759                            }
1760                    }
1761            }
1762    
1763            /**
1764             * Clears the cache for all message boards bans.
1765             *
1766             * <p>
1767             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1768             * </p>
1769             */
1770            @Override
1771            public void clearCache() {
1772                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1773                            CacheRegistryUtil.clear(MBBanImpl.class.getName());
1774                    }
1775    
1776                    EntityCacheUtil.clearCache(MBBanImpl.class.getName());
1777    
1778                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1779                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1780                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1781            }
1782    
1783            /**
1784             * Clears the cache for the message boards ban.
1785             *
1786             * <p>
1787             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1788             * </p>
1789             */
1790            @Override
1791            public void clearCache(MBBan mbBan) {
1792                    EntityCacheUtil.removeResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1793                            MBBanImpl.class, mbBan.getPrimaryKey());
1794    
1795                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1796                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1797    
1798                    clearUniqueFindersCache(mbBan);
1799            }
1800    
1801            @Override
1802            public void clearCache(List<MBBan> mbBans) {
1803                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1804                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1805    
1806                    for (MBBan mbBan : mbBans) {
1807                            EntityCacheUtil.removeResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
1808                                    MBBanImpl.class, mbBan.getPrimaryKey());
1809    
1810                            clearUniqueFindersCache(mbBan);
1811                    }
1812            }
1813    
1814            protected void cacheUniqueFindersCache(MBBan mbBan) {
1815                    if (mbBan.isNew()) {
1816                            Object[] args = new Object[] {
1817                                            Long.valueOf(mbBan.getGroupId()),
1818                                            Long.valueOf(mbBan.getBanUserId())
1819                                    };
1820    
1821                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_B, args,
1822                                    Long.valueOf(1));
1823                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B, args, mbBan);
1824                    }
1825                    else {
1826                            MBBanModelImpl mbBanModelImpl = (MBBanModelImpl)mbBan;
1827    
1828                            if ((mbBanModelImpl.getColumnBitmask() &
1829                                            FINDER_PATH_FETCH_BY_G_B.getColumnBitmask()) != 0) {
1830                                    Object[] args = new Object[] {
1831                                                    Long.valueOf(mbBan.getGroupId()),
1832                                                    Long.valueOf(mbBan.getBanUserId())
1833                                            };
1834    
1835                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_B, args,
1836                                            Long.valueOf(1));
1837                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B, args, mbBan);
1838                            }
1839                    }
1840            }
1841    
1842            protected void clearUniqueFindersCache(MBBan mbBan) {
1843                    MBBanModelImpl mbBanModelImpl = (MBBanModelImpl)mbBan;
1844    
1845                    Object[] args = new Object[] {
1846                                    Long.valueOf(mbBan.getGroupId()),
1847                                    Long.valueOf(mbBan.getBanUserId())
1848                            };
1849    
1850                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_B, args);
1851                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_B, args);
1852    
1853                    if ((mbBanModelImpl.getColumnBitmask() &
1854                                    FINDER_PATH_FETCH_BY_G_B.getColumnBitmask()) != 0) {
1855                            args = new Object[] {
1856                                            Long.valueOf(mbBanModelImpl.getOriginalGroupId()),
1857                                            Long.valueOf(mbBanModelImpl.getOriginalBanUserId())
1858                                    };
1859    
1860                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_B, args);
1861                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_B, args);
1862                    }
1863            }
1864    
1865            /**
1866             * Creates a new message boards ban with the primary key. Does not add the message boards ban to the database.
1867             *
1868             * @param banId the primary key for the new message boards ban
1869             * @return the new message boards ban
1870             */
1871            public MBBan create(long banId) {
1872                    MBBan mbBan = new MBBanImpl();
1873    
1874                    mbBan.setNew(true);
1875                    mbBan.setPrimaryKey(banId);
1876    
1877                    return mbBan;
1878            }
1879    
1880            /**
1881             * Removes the message boards ban with the primary key from the database. Also notifies the appropriate model listeners.
1882             *
1883             * @param banId the primary key of the message boards ban
1884             * @return the message boards ban that was removed
1885             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a message boards ban with the primary key could not be found
1886             * @throws SystemException if a system exception occurred
1887             */
1888            public MBBan remove(long banId) throws NoSuchBanException, SystemException {
1889                    return remove(Long.valueOf(banId));
1890            }
1891    
1892            /**
1893             * Removes the message boards ban with the primary key from the database. Also notifies the appropriate model listeners.
1894             *
1895             * @param primaryKey the primary key of the message boards ban
1896             * @return the message boards ban that was removed
1897             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a message boards ban with the primary key could not be found
1898             * @throws SystemException if a system exception occurred
1899             */
1900            @Override
1901            public MBBan remove(Serializable primaryKey)
1902                    throws NoSuchBanException, SystemException {
1903                    Session session = null;
1904    
1905                    try {
1906                            session = openSession();
1907    
1908                            MBBan mbBan = (MBBan)session.get(MBBanImpl.class, primaryKey);
1909    
1910                            if (mbBan == null) {
1911                                    if (_log.isWarnEnabled()) {
1912                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1913                                    }
1914    
1915                                    throw new NoSuchBanException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1916                                            primaryKey);
1917                            }
1918    
1919                            return remove(mbBan);
1920                    }
1921                    catch (NoSuchBanException nsee) {
1922                            throw nsee;
1923                    }
1924                    catch (Exception e) {
1925                            throw processException(e);
1926                    }
1927                    finally {
1928                            closeSession(session);
1929                    }
1930            }
1931    
1932            @Override
1933            protected MBBan removeImpl(MBBan mbBan) throws SystemException {
1934                    mbBan = toUnwrappedModel(mbBan);
1935    
1936                    Session session = null;
1937    
1938                    try {
1939                            session = openSession();
1940    
1941                            if (!session.contains(mbBan)) {
1942                                    mbBan = (MBBan)session.get(MBBanImpl.class,
1943                                                    mbBan.getPrimaryKeyObj());
1944                            }
1945    
1946                            if (mbBan != null) {
1947                                    session.delete(mbBan);
1948                            }
1949                    }
1950                    catch (Exception e) {
1951                            throw processException(e);
1952                    }
1953                    finally {
1954                            closeSession(session);
1955                    }
1956    
1957                    if (mbBan != null) {
1958                            clearCache(mbBan);
1959                    }
1960    
1961                    return mbBan;
1962            }
1963    
1964            @Override
1965            public MBBan updateImpl(com.liferay.portlet.messageboards.model.MBBan mbBan)
1966                    throws SystemException {
1967                    mbBan = toUnwrappedModel(mbBan);
1968    
1969                    boolean isNew = mbBan.isNew();
1970    
1971                    MBBanModelImpl mbBanModelImpl = (MBBanModelImpl)mbBan;
1972    
1973                    Session session = null;
1974    
1975                    try {
1976                            session = openSession();
1977    
1978                            if (mbBan.isNew()) {
1979                                    session.save(mbBan);
1980    
1981                                    mbBan.setNew(false);
1982                            }
1983                            else {
1984                                    session.merge(mbBan);
1985                            }
1986                    }
1987                    catch (Exception e) {
1988                            throw processException(e);
1989                    }
1990                    finally {
1991                            closeSession(session);
1992                    }
1993    
1994                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1995    
1996                    if (isNew || !MBBanModelImpl.COLUMN_BITMASK_ENABLED) {
1997                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1998                    }
1999    
2000                    else {
2001                            if ((mbBanModelImpl.getColumnBitmask() &
2002                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2003                                    Object[] args = new Object[] {
2004                                                    Long.valueOf(mbBanModelImpl.getOriginalGroupId())
2005                                            };
2006    
2007                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2008                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2009                                            args);
2010    
2011                                    args = new Object[] { Long.valueOf(mbBanModelImpl.getGroupId()) };
2012    
2013                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2014                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2015                                            args);
2016                            }
2017    
2018                            if ((mbBanModelImpl.getColumnBitmask() &
2019                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
2020                                    Object[] args = new Object[] {
2021                                                    Long.valueOf(mbBanModelImpl.getOriginalUserId())
2022                                            };
2023    
2024                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
2025                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
2026                                            args);
2027    
2028                                    args = new Object[] { Long.valueOf(mbBanModelImpl.getUserId()) };
2029    
2030                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
2031                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
2032                                            args);
2033                            }
2034    
2035                            if ((mbBanModelImpl.getColumnBitmask() &
2036                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BANUSERID.getColumnBitmask()) != 0) {
2037                                    Object[] args = new Object[] {
2038                                                    Long.valueOf(mbBanModelImpl.getOriginalBanUserId())
2039                                            };
2040    
2041                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_BANUSERID,
2042                                            args);
2043                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BANUSERID,
2044                                            args);
2045    
2046                                    args = new Object[] { Long.valueOf(mbBanModelImpl.getBanUserId()) };
2047    
2048                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_BANUSERID,
2049                                            args);
2050                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BANUSERID,
2051                                            args);
2052                            }
2053                    }
2054    
2055                    EntityCacheUtil.putResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
2056                            MBBanImpl.class, mbBan.getPrimaryKey(), mbBan);
2057    
2058                    clearUniqueFindersCache(mbBan);
2059                    cacheUniqueFindersCache(mbBan);
2060    
2061                    return mbBan;
2062            }
2063    
2064            protected MBBan toUnwrappedModel(MBBan mbBan) {
2065                    if (mbBan instanceof MBBanImpl) {
2066                            return mbBan;
2067                    }
2068    
2069                    MBBanImpl mbBanImpl = new MBBanImpl();
2070    
2071                    mbBanImpl.setNew(mbBan.isNew());
2072                    mbBanImpl.setPrimaryKey(mbBan.getPrimaryKey());
2073    
2074                    mbBanImpl.setBanId(mbBan.getBanId());
2075                    mbBanImpl.setGroupId(mbBan.getGroupId());
2076                    mbBanImpl.setCompanyId(mbBan.getCompanyId());
2077                    mbBanImpl.setUserId(mbBan.getUserId());
2078                    mbBanImpl.setUserName(mbBan.getUserName());
2079                    mbBanImpl.setCreateDate(mbBan.getCreateDate());
2080                    mbBanImpl.setModifiedDate(mbBan.getModifiedDate());
2081                    mbBanImpl.setBanUserId(mbBan.getBanUserId());
2082    
2083                    return mbBanImpl;
2084            }
2085    
2086            /**
2087             * Returns the message boards ban with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2088             *
2089             * @param primaryKey the primary key of the message boards ban
2090             * @return the message boards ban
2091             * @throws com.liferay.portal.NoSuchModelException if a message boards ban with the primary key could not be found
2092             * @throws SystemException if a system exception occurred
2093             */
2094            @Override
2095            public MBBan findByPrimaryKey(Serializable primaryKey)
2096                    throws NoSuchModelException, SystemException {
2097                    return findByPrimaryKey(((Long)primaryKey).longValue());
2098            }
2099    
2100            /**
2101             * Returns the message boards ban with the primary key or throws a {@link com.liferay.portlet.messageboards.NoSuchBanException} if it could not be found.
2102             *
2103             * @param banId the primary key of the message boards ban
2104             * @return the message boards ban
2105             * @throws com.liferay.portlet.messageboards.NoSuchBanException if a message boards ban with the primary key could not be found
2106             * @throws SystemException if a system exception occurred
2107             */
2108            public MBBan findByPrimaryKey(long banId)
2109                    throws NoSuchBanException, SystemException {
2110                    MBBan mbBan = fetchByPrimaryKey(banId);
2111    
2112                    if (mbBan == null) {
2113                            if (_log.isWarnEnabled()) {
2114                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + banId);
2115                            }
2116    
2117                            throw new NoSuchBanException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2118                                    banId);
2119                    }
2120    
2121                    return mbBan;
2122            }
2123    
2124            /**
2125             * Returns the message boards ban with the primary key or returns <code>null</code> if it could not be found.
2126             *
2127             * @param primaryKey the primary key of the message boards ban
2128             * @return the message boards ban, or <code>null</code> if a message boards ban with the primary key could not be found
2129             * @throws SystemException if a system exception occurred
2130             */
2131            @Override
2132            public MBBan fetchByPrimaryKey(Serializable primaryKey)
2133                    throws SystemException {
2134                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
2135            }
2136    
2137            /**
2138             * Returns the message boards ban with the primary key or returns <code>null</code> if it could not be found.
2139             *
2140             * @param banId the primary key of the message boards ban
2141             * @return the message boards ban, or <code>null</code> if a message boards ban with the primary key could not be found
2142             * @throws SystemException if a system exception occurred
2143             */
2144            public MBBan fetchByPrimaryKey(long banId) throws SystemException {
2145                    MBBan mbBan = (MBBan)EntityCacheUtil.getResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
2146                                    MBBanImpl.class, banId);
2147    
2148                    if (mbBan == _nullMBBan) {
2149                            return null;
2150                    }
2151    
2152                    if (mbBan == null) {
2153                            Session session = null;
2154    
2155                            try {
2156                                    session = openSession();
2157    
2158                                    mbBan = (MBBan)session.get(MBBanImpl.class, Long.valueOf(banId));
2159    
2160                                    if (mbBan != null) {
2161                                            cacheResult(mbBan);
2162                                    }
2163                                    else {
2164                                            EntityCacheUtil.putResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
2165                                                    MBBanImpl.class, banId, _nullMBBan);
2166                                    }
2167                            }
2168                            catch (Exception e) {
2169                                    EntityCacheUtil.removeResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
2170                                            MBBanImpl.class, banId);
2171    
2172                                    throw processException(e);
2173                            }
2174                            finally {
2175                                    closeSession(session);
2176                            }
2177                    }
2178    
2179                    return mbBan;
2180            }
2181    
2182            /**
2183             * Returns all the message boards bans.
2184             *
2185             * @return the message boards bans
2186             * @throws SystemException if a system exception occurred
2187             */
2188            public List<MBBan> findAll() throws SystemException {
2189                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2190            }
2191    
2192            /**
2193             * Returns a range of all the message boards bans.
2194             *
2195             * <p>
2196             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.messageboards.model.impl.MBBanModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2197             * </p>
2198             *
2199             * @param start the lower bound of the range of message boards bans
2200             * @param end the upper bound of the range of message boards bans (not inclusive)
2201             * @return the range of message boards bans
2202             * @throws SystemException if a system exception occurred
2203             */
2204            public List<MBBan> findAll(int start, int end) throws SystemException {
2205                    return findAll(start, end, null);
2206            }
2207    
2208            /**
2209             * Returns an ordered range of all the message boards bans.
2210             *
2211             * <p>
2212             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.messageboards.model.impl.MBBanModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2213             * </p>
2214             *
2215             * @param start the lower bound of the range of message boards bans
2216             * @param end the upper bound of the range of message boards bans (not inclusive)
2217             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2218             * @return the ordered range of message boards bans
2219             * @throws SystemException if a system exception occurred
2220             */
2221            public List<MBBan> findAll(int start, int end,
2222                    OrderByComparator orderByComparator) throws SystemException {
2223                    boolean pagination = true;
2224                    FinderPath finderPath = null;
2225                    Object[] finderArgs = null;
2226    
2227                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2228                                    (orderByComparator == null)) {
2229                            pagination = false;
2230                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2231                            finderArgs = FINDER_ARGS_EMPTY;
2232                    }
2233                    else {
2234                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2235                            finderArgs = new Object[] { start, end, orderByComparator };
2236                    }
2237    
2238                    List<MBBan> list = (List<MBBan>)FinderCacheUtil.getResult(finderPath,
2239                                    finderArgs, this);
2240    
2241                    if (list == null) {
2242                            StringBundler query = null;
2243                            String sql = null;
2244    
2245                            if (orderByComparator != null) {
2246                                    query = new StringBundler(2 +
2247                                                    (orderByComparator.getOrderByFields().length * 3));
2248    
2249                                    query.append(_SQL_SELECT_MBBAN);
2250    
2251                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2252                                            orderByComparator);
2253    
2254                                    sql = query.toString();
2255                            }
2256                            else {
2257                                    sql = _SQL_SELECT_MBBAN;
2258    
2259                                    if (pagination) {
2260                                            sql = sql.concat(MBBanModelImpl.ORDER_BY_JPQL);
2261                                    }
2262                            }
2263    
2264                            Session session = null;
2265    
2266                            try {
2267                                    session = openSession();
2268    
2269                                    Query q = session.createQuery(sql);
2270    
2271                                    if (!pagination) {
2272                                            list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
2273                                                            end, false);
2274    
2275                                            Collections.sort(list);
2276    
2277                                            list = new UnmodifiableList<MBBan>(list);
2278                                    }
2279                                    else {
2280                                            list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
2281                                                            end);
2282                                    }
2283    
2284                                    cacheResult(list);
2285    
2286                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2287                            }
2288                            catch (Exception e) {
2289                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2290    
2291                                    throw processException(e);
2292                            }
2293                            finally {
2294                                    closeSession(session);
2295                            }
2296                    }
2297    
2298                    return list;
2299            }
2300    
2301            /**
2302             * Removes all the message boards bans from the database.
2303             *
2304             * @throws SystemException if a system exception occurred
2305             */
2306            public void removeAll() throws SystemException {
2307                    for (MBBan mbBan : findAll()) {
2308                            remove(mbBan);
2309                    }
2310            }
2311    
2312            /**
2313             * Returns the number of message boards bans.
2314             *
2315             * @return the number of message boards bans
2316             * @throws SystemException if a system exception occurred
2317             */
2318            public int countAll() throws SystemException {
2319                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2320                                    FINDER_ARGS_EMPTY, this);
2321    
2322                    if (count == null) {
2323                            Session session = null;
2324    
2325                            try {
2326                                    session = openSession();
2327    
2328                                    Query q = session.createQuery(_SQL_COUNT_MBBAN);
2329    
2330                                    count = (Long)q.uniqueResult();
2331    
2332                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2333                                            FINDER_ARGS_EMPTY, count);
2334                            }
2335                            catch (Exception e) {
2336                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2337                                            FINDER_ARGS_EMPTY);
2338    
2339                                    throw processException(e);
2340                            }
2341                            finally {
2342                                    closeSession(session);
2343                            }
2344                    }
2345    
2346                    return count.intValue();
2347            }
2348    
2349            /**
2350             * Initializes the message boards ban persistence.
2351             */
2352            public void afterPropertiesSet() {
2353                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2354                                            com.liferay.portal.util.PropsUtil.get(
2355                                                    "value.object.listener.com.liferay.portlet.messageboards.model.MBBan")));
2356    
2357                    if (listenerClassNames.length > 0) {
2358                            try {
2359                                    List<ModelListener<MBBan>> listenersList = new ArrayList<ModelListener<MBBan>>();
2360    
2361                                    for (String listenerClassName : listenerClassNames) {
2362                                            listenersList.add((ModelListener<MBBan>)InstanceFactory.newInstance(
2363                                                            listenerClassName));
2364                                    }
2365    
2366                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2367                            }
2368                            catch (Exception e) {
2369                                    _log.error(e);
2370                            }
2371                    }
2372            }
2373    
2374            public void destroy() {
2375                    EntityCacheUtil.removeCache(MBBanImpl.class.getName());
2376                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2377                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2378                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2379            }
2380    
2381            private static final String _SQL_SELECT_MBBAN = "SELECT mbBan FROM MBBan mbBan";
2382            private static final String _SQL_SELECT_MBBAN_WHERE = "SELECT mbBan FROM MBBan mbBan WHERE ";
2383            private static final String _SQL_COUNT_MBBAN = "SELECT COUNT(mbBan) FROM MBBan mbBan";
2384            private static final String _SQL_COUNT_MBBAN_WHERE = "SELECT COUNT(mbBan) FROM MBBan mbBan WHERE ";
2385            private static final String _ORDER_BY_ENTITY_ALIAS = "mbBan.";
2386            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBBan exists with the primary key ";
2387            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBBan exists with the key {";
2388            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2389            private static Log _log = LogFactoryUtil.getLog(MBBanPersistenceImpl.class);
2390            private static MBBan _nullMBBan = new MBBanImpl() {
2391                            @Override
2392                            public Object clone() {
2393                                    return this;
2394                            }
2395    
2396                            @Override
2397                            public CacheModel<MBBan> toCacheModel() {
2398                                    return _nullMBBanCacheModel;
2399                            }
2400                    };
2401    
2402            private static CacheModel<MBBan> _nullMBBanCacheModel = new CacheModel<MBBan>() {
2403                            public MBBan toEntityModel() {
2404                                    return _nullMBBan;
2405                            }
2406                    };
2407    }