001    /**
002     * Copyright (c) 2000-2013 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.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.Session;
025    import com.liferay.portal.kernel.exception.SystemException;
026    import com.liferay.portal.kernel.log.Log;
027    import com.liferay.portal.kernel.log.LogFactoryUtil;
028    import com.liferay.portal.kernel.util.GetterUtil;
029    import com.liferay.portal.kernel.util.InstanceFactory;
030    import com.liferay.portal.kernel.util.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
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.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.messageboards.NoSuchMailingListException;
043    import com.liferay.portlet.messageboards.model.MBMailingList;
044    import com.liferay.portlet.messageboards.model.impl.MBMailingListImpl;
045    import com.liferay.portlet.messageboards.model.impl.MBMailingListModelImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.List;
052    import java.util.Set;
053    
054    /**
055     * The persistence implementation for the message boards mailing list service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see MBMailingListPersistence
063     * @see MBMailingListUtil
064     * @generated
065     */
066    public class MBMailingListPersistenceImpl extends BasePersistenceImpl<MBMailingList>
067            implements MBMailingListPersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link MBMailingListUtil} to access the message boards mailing list persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072             */
073            public static final String FINDER_CLASS_NAME_ENTITY = MBMailingListImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List1";
076            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List2";
078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
079                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
080                            MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
081                            "findAll", new String[0]);
082            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
083                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
084                            MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
085                            "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
087                            MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
090                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
091                            MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092                            "findByUuid",
093                            new String[] {
094                                    String.class.getName(),
095                                    
096                            Integer.class.getName(), Integer.class.getName(),
097                                    OrderByComparator.class.getName()
098                            });
099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
100                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
101                            MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
102                            "findByUuid", new String[] { String.class.getName() },
103                            MBMailingListModelImpl.UUID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
105                            MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107                            new String[] { String.class.getName() });
108    
109            /**
110             * Returns all the message boards mailing lists where uuid = &#63;.
111             *
112             * @param uuid the uuid
113             * @return the matching message boards mailing lists
114             * @throws SystemException if a system exception occurred
115             */
116            @Override
117            public List<MBMailingList> findByUuid(String uuid)
118                    throws SystemException {
119                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
120            }
121    
122            /**
123             * Returns a range of all the message boards mailing lists where uuid = &#63;.
124             *
125             * <p>
126             * 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.MBMailingListModelImpl}. 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.
127             * </p>
128             *
129             * @param uuid the uuid
130             * @param start the lower bound of the range of message boards mailing lists
131             * @param end the upper bound of the range of message boards mailing lists (not inclusive)
132             * @return the range of matching message boards mailing lists
133             * @throws SystemException if a system exception occurred
134             */
135            @Override
136            public List<MBMailingList> findByUuid(String uuid, int start, int end)
137                    throws SystemException {
138                    return findByUuid(uuid, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the message boards mailing lists where uuid = &#63;.
143             *
144             * <p>
145             * 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.MBMailingListModelImpl}. 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.
146             * </p>
147             *
148             * @param uuid the uuid
149             * @param start the lower bound of the range of message boards mailing lists
150             * @param end the upper bound of the range of message boards mailing lists (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching message boards mailing lists
153             * @throws SystemException if a system exception occurred
154             */
155            @Override
156            public List<MBMailingList> findByUuid(String uuid, int start, int end,
157                    OrderByComparator orderByComparator) throws SystemException {
158                    boolean pagination = true;
159                    FinderPath finderPath = null;
160                    Object[] finderArgs = null;
161    
162                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163                                    (orderByComparator == null)) {
164                            pagination = false;
165                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
166                            finderArgs = new Object[] { uuid };
167                    }
168                    else {
169                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
170                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
171                    }
172    
173                    List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
174                                    finderArgs, this);
175    
176                    if ((list != null) && !list.isEmpty()) {
177                            for (MBMailingList mbMailingList : list) {
178                                    if (!Validator.equals(uuid, mbMailingList.getUuid())) {
179                                            list = null;
180    
181                                            break;
182                                    }
183                            }
184                    }
185    
186                    if (list == null) {
187                            StringBundler query = null;
188    
189                            if (orderByComparator != null) {
190                                    query = new StringBundler(3 +
191                                                    (orderByComparator.getOrderByFields().length * 3));
192                            }
193                            else {
194                                    query = new StringBundler(3);
195                            }
196    
197                            query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
198    
199                            boolean bindUuid = false;
200    
201                            if (uuid == null) {
202                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
203                            }
204                            else if (uuid.equals(StringPool.BLANK)) {
205                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
206                            }
207                            else {
208                                    bindUuid = true;
209    
210                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
211                            }
212    
213                            if (orderByComparator != null) {
214                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
215                                            orderByComparator);
216                            }
217                            else
218                             if (pagination) {
219                                    query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
220                            }
221    
222                            String sql = query.toString();
223    
224                            Session session = null;
225    
226                            try {
227                                    session = openSession();
228    
229                                    Query q = session.createQuery(sql);
230    
231                                    QueryPos qPos = QueryPos.getInstance(q);
232    
233                                    if (bindUuid) {
234                                            qPos.add(uuid);
235                                    }
236    
237                                    if (!pagination) {
238                                            list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
239                                                            start, end, false);
240    
241                                            Collections.sort(list);
242    
243                                            list = new UnmodifiableList<MBMailingList>(list);
244                                    }
245                                    else {
246                                            list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
247                                                            start, end);
248                                    }
249    
250                                    cacheResult(list);
251    
252                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
253                            }
254                            catch (Exception e) {
255                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
256    
257                                    throw processException(e);
258                            }
259                            finally {
260                                    closeSession(session);
261                            }
262                    }
263    
264                    return list;
265            }
266    
267            /**
268             * Returns the first message boards mailing list in the ordered set where uuid = &#63;.
269             *
270             * @param uuid the uuid
271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
272             * @return the first matching message boards mailing list
273             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a matching message boards mailing list could not be found
274             * @throws SystemException if a system exception occurred
275             */
276            @Override
277            public MBMailingList findByUuid_First(String uuid,
278                    OrderByComparator orderByComparator)
279                    throws NoSuchMailingListException, SystemException {
280                    MBMailingList mbMailingList = fetchByUuid_First(uuid, orderByComparator);
281    
282                    if (mbMailingList != null) {
283                            return mbMailingList;
284                    }
285    
286                    StringBundler msg = new StringBundler(4);
287    
288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289    
290                    msg.append("uuid=");
291                    msg.append(uuid);
292    
293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
294    
295                    throw new NoSuchMailingListException(msg.toString());
296            }
297    
298            /**
299             * Returns the first message boards mailing list in the ordered set where uuid = &#63;.
300             *
301             * @param uuid the uuid
302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
303             * @return the first matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
304             * @throws SystemException if a system exception occurred
305             */
306            @Override
307            public MBMailingList fetchByUuid_First(String uuid,
308                    OrderByComparator orderByComparator) throws SystemException {
309                    List<MBMailingList> list = findByUuid(uuid, 0, 1, orderByComparator);
310    
311                    if (!list.isEmpty()) {
312                            return list.get(0);
313                    }
314    
315                    return null;
316            }
317    
318            /**
319             * Returns the last message boards mailing list in the ordered set where uuid = &#63;.
320             *
321             * @param uuid the uuid
322             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
323             * @return the last matching message boards mailing list
324             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a matching message boards mailing list could not be found
325             * @throws SystemException if a system exception occurred
326             */
327            @Override
328            public MBMailingList findByUuid_Last(String uuid,
329                    OrderByComparator orderByComparator)
330                    throws NoSuchMailingListException, SystemException {
331                    MBMailingList mbMailingList = fetchByUuid_Last(uuid, orderByComparator);
332    
333                    if (mbMailingList != null) {
334                            return mbMailingList;
335                    }
336    
337                    StringBundler msg = new StringBundler(4);
338    
339                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
340    
341                    msg.append("uuid=");
342                    msg.append(uuid);
343    
344                    msg.append(StringPool.CLOSE_CURLY_BRACE);
345    
346                    throw new NoSuchMailingListException(msg.toString());
347            }
348    
349            /**
350             * Returns the last message boards mailing list in the ordered set where uuid = &#63;.
351             *
352             * @param uuid the uuid
353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
354             * @return the last matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
355             * @throws SystemException if a system exception occurred
356             */
357            @Override
358            public MBMailingList fetchByUuid_Last(String uuid,
359                    OrderByComparator orderByComparator) throws SystemException {
360                    int count = countByUuid(uuid);
361    
362                    if (count == 0) {
363                            return null;
364                    }
365    
366                    List<MBMailingList> list = findByUuid(uuid, count - 1, count,
367                                    orderByComparator);
368    
369                    if (!list.isEmpty()) {
370                            return list.get(0);
371                    }
372    
373                    return null;
374            }
375    
376            /**
377             * Returns the message boards mailing lists before and after the current message boards mailing list in the ordered set where uuid = &#63;.
378             *
379             * @param mailingListId the primary key of the current message boards mailing list
380             * @param uuid the uuid
381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
382             * @return the previous, current, and next message boards mailing list
383             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a message boards mailing list with the primary key could not be found
384             * @throws SystemException if a system exception occurred
385             */
386            @Override
387            public MBMailingList[] findByUuid_PrevAndNext(long mailingListId,
388                    String uuid, OrderByComparator orderByComparator)
389                    throws NoSuchMailingListException, SystemException {
390                    MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
391    
392                    Session session = null;
393    
394                    try {
395                            session = openSession();
396    
397                            MBMailingList[] array = new MBMailingListImpl[3];
398    
399                            array[0] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
400                                            orderByComparator, true);
401    
402                            array[1] = mbMailingList;
403    
404                            array[2] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
405                                            orderByComparator, false);
406    
407                            return array;
408                    }
409                    catch (Exception e) {
410                            throw processException(e);
411                    }
412                    finally {
413                            closeSession(session);
414                    }
415            }
416    
417            protected MBMailingList getByUuid_PrevAndNext(Session session,
418                    MBMailingList mbMailingList, String uuid,
419                    OrderByComparator orderByComparator, boolean previous) {
420                    StringBundler query = null;
421    
422                    if (orderByComparator != null) {
423                            query = new StringBundler(6 +
424                                            (orderByComparator.getOrderByFields().length * 6));
425                    }
426                    else {
427                            query = new StringBundler(3);
428                    }
429    
430                    query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
431    
432                    boolean bindUuid = false;
433    
434                    if (uuid == null) {
435                            query.append(_FINDER_COLUMN_UUID_UUID_1);
436                    }
437                    else if (uuid.equals(StringPool.BLANK)) {
438                            query.append(_FINDER_COLUMN_UUID_UUID_3);
439                    }
440                    else {
441                            bindUuid = true;
442    
443                            query.append(_FINDER_COLUMN_UUID_UUID_2);
444                    }
445    
446                    if (orderByComparator != null) {
447                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
448    
449                            if (orderByConditionFields.length > 0) {
450                                    query.append(WHERE_AND);
451                            }
452    
453                            for (int i = 0; i < orderByConditionFields.length; i++) {
454                                    query.append(_ORDER_BY_ENTITY_ALIAS);
455                                    query.append(orderByConditionFields[i]);
456    
457                                    if ((i + 1) < orderByConditionFields.length) {
458                                            if (orderByComparator.isAscending() ^ previous) {
459                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
460                                            }
461                                            else {
462                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
463                                            }
464                                    }
465                                    else {
466                                            if (orderByComparator.isAscending() ^ previous) {
467                                                    query.append(WHERE_GREATER_THAN);
468                                            }
469                                            else {
470                                                    query.append(WHERE_LESSER_THAN);
471                                            }
472                                    }
473                            }
474    
475                            query.append(ORDER_BY_CLAUSE);
476    
477                            String[] orderByFields = orderByComparator.getOrderByFields();
478    
479                            for (int i = 0; i < orderByFields.length; i++) {
480                                    query.append(_ORDER_BY_ENTITY_ALIAS);
481                                    query.append(orderByFields[i]);
482    
483                                    if ((i + 1) < orderByFields.length) {
484                                            if (orderByComparator.isAscending() ^ previous) {
485                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
486                                            }
487                                            else {
488                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
489                                            }
490                                    }
491                                    else {
492                                            if (orderByComparator.isAscending() ^ previous) {
493                                                    query.append(ORDER_BY_ASC);
494                                            }
495                                            else {
496                                                    query.append(ORDER_BY_DESC);
497                                            }
498                                    }
499                            }
500                    }
501                    else {
502                            query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
503                    }
504    
505                    String sql = query.toString();
506    
507                    Query q = session.createQuery(sql);
508    
509                    q.setFirstResult(0);
510                    q.setMaxResults(2);
511    
512                    QueryPos qPos = QueryPos.getInstance(q);
513    
514                    if (bindUuid) {
515                            qPos.add(uuid);
516                    }
517    
518                    if (orderByComparator != null) {
519                            Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
520    
521                            for (Object value : values) {
522                                    qPos.add(value);
523                            }
524                    }
525    
526                    List<MBMailingList> list = q.list();
527    
528                    if (list.size() == 2) {
529                            return list.get(1);
530                    }
531                    else {
532                            return null;
533                    }
534            }
535    
536            /**
537             * Removes all the message boards mailing lists where uuid = &#63; from the database.
538             *
539             * @param uuid the uuid
540             * @throws SystemException if a system exception occurred
541             */
542            @Override
543            public void removeByUuid(String uuid) throws SystemException {
544                    for (MBMailingList mbMailingList : findByUuid(uuid, QueryUtil.ALL_POS,
545                                    QueryUtil.ALL_POS, null)) {
546                            remove(mbMailingList);
547                    }
548            }
549    
550            /**
551             * Returns the number of message boards mailing lists where uuid = &#63;.
552             *
553             * @param uuid the uuid
554             * @return the number of matching message boards mailing lists
555             * @throws SystemException if a system exception occurred
556             */
557            @Override
558            public int countByUuid(String uuid) throws SystemException {
559                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
560    
561                    Object[] finderArgs = new Object[] { uuid };
562    
563                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
564                                    this);
565    
566                    if (count == null) {
567                            StringBundler query = new StringBundler(2);
568    
569                            query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
570    
571                            boolean bindUuid = false;
572    
573                            if (uuid == null) {
574                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
575                            }
576                            else if (uuid.equals(StringPool.BLANK)) {
577                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
578                            }
579                            else {
580                                    bindUuid = true;
581    
582                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
583                            }
584    
585                            String sql = query.toString();
586    
587                            Session session = null;
588    
589                            try {
590                                    session = openSession();
591    
592                                    Query q = session.createQuery(sql);
593    
594                                    QueryPos qPos = QueryPos.getInstance(q);
595    
596                                    if (bindUuid) {
597                                            qPos.add(uuid);
598                                    }
599    
600                                    count = (Long)q.uniqueResult();
601    
602                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
603                            }
604                            catch (Exception e) {
605                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
606    
607                                    throw processException(e);
608                            }
609                            finally {
610                                    closeSession(session);
611                            }
612                    }
613    
614                    return count.intValue();
615            }
616    
617            private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMailingList.uuid IS NULL";
618            private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMailingList.uuid = ?";
619            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = '')";
620            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
621                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
622                            MBMailingListImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
623                            new String[] { String.class.getName(), Long.class.getName() },
624                            MBMailingListModelImpl.UUID_COLUMN_BITMASK |
625                            MBMailingListModelImpl.GROUPID_COLUMN_BITMASK);
626            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
627                            MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
628                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
629                            new String[] { String.class.getName(), Long.class.getName() });
630    
631            /**
632             * Returns the message boards mailing list where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.messageboards.NoSuchMailingListException} if it could not be found.
633             *
634             * @param uuid the uuid
635             * @param groupId the group ID
636             * @return the matching message boards mailing list
637             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a matching message boards mailing list could not be found
638             * @throws SystemException if a system exception occurred
639             */
640            @Override
641            public MBMailingList findByUUID_G(String uuid, long groupId)
642                    throws NoSuchMailingListException, SystemException {
643                    MBMailingList mbMailingList = fetchByUUID_G(uuid, groupId);
644    
645                    if (mbMailingList == null) {
646                            StringBundler msg = new StringBundler(6);
647    
648                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
649    
650                            msg.append("uuid=");
651                            msg.append(uuid);
652    
653                            msg.append(", groupId=");
654                            msg.append(groupId);
655    
656                            msg.append(StringPool.CLOSE_CURLY_BRACE);
657    
658                            if (_log.isWarnEnabled()) {
659                                    _log.warn(msg.toString());
660                            }
661    
662                            throw new NoSuchMailingListException(msg.toString());
663                    }
664    
665                    return mbMailingList;
666            }
667    
668            /**
669             * Returns the message boards mailing list where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
670             *
671             * @param uuid the uuid
672             * @param groupId the group ID
673             * @return the matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
674             * @throws SystemException if a system exception occurred
675             */
676            @Override
677            public MBMailingList fetchByUUID_G(String uuid, long groupId)
678                    throws SystemException {
679                    return fetchByUUID_G(uuid, groupId, true);
680            }
681    
682            /**
683             * Returns the message boards mailing list where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
684             *
685             * @param uuid the uuid
686             * @param groupId the group ID
687             * @param retrieveFromCache whether to use the finder cache
688             * @return the matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
689             * @throws SystemException if a system exception occurred
690             */
691            @Override
692            public MBMailingList fetchByUUID_G(String uuid, long groupId,
693                    boolean retrieveFromCache) throws SystemException {
694                    Object[] finderArgs = new Object[] { uuid, groupId };
695    
696                    Object result = null;
697    
698                    if (retrieveFromCache) {
699                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
700                                            finderArgs, this);
701                    }
702    
703                    if (result instanceof MBMailingList) {
704                            MBMailingList mbMailingList = (MBMailingList)result;
705    
706                            if (!Validator.equals(uuid, mbMailingList.getUuid()) ||
707                                            (groupId != mbMailingList.getGroupId())) {
708                                    result = null;
709                            }
710                    }
711    
712                    if (result == null) {
713                            StringBundler query = new StringBundler(4);
714    
715                            query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
716    
717                            boolean bindUuid = false;
718    
719                            if (uuid == null) {
720                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
721                            }
722                            else if (uuid.equals(StringPool.BLANK)) {
723                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
724                            }
725                            else {
726                                    bindUuid = true;
727    
728                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
729                            }
730    
731                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
732    
733                            String sql = query.toString();
734    
735                            Session session = null;
736    
737                            try {
738                                    session = openSession();
739    
740                                    Query q = session.createQuery(sql);
741    
742                                    QueryPos qPos = QueryPos.getInstance(q);
743    
744                                    if (bindUuid) {
745                                            qPos.add(uuid);
746                                    }
747    
748                                    qPos.add(groupId);
749    
750                                    List<MBMailingList> list = q.list();
751    
752                                    if (list.isEmpty()) {
753                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
754                                                    finderArgs, list);
755                                    }
756                                    else {
757                                            MBMailingList mbMailingList = list.get(0);
758    
759                                            result = mbMailingList;
760    
761                                            cacheResult(mbMailingList);
762    
763                                            if ((mbMailingList.getUuid() == null) ||
764                                                            !mbMailingList.getUuid().equals(uuid) ||
765                                                            (mbMailingList.getGroupId() != groupId)) {
766                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
767                                                            finderArgs, mbMailingList);
768                                            }
769                                    }
770                            }
771                            catch (Exception e) {
772                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
773                                            finderArgs);
774    
775                                    throw processException(e);
776                            }
777                            finally {
778                                    closeSession(session);
779                            }
780                    }
781    
782                    if (result instanceof List<?>) {
783                            return null;
784                    }
785                    else {
786                            return (MBMailingList)result;
787                    }
788            }
789    
790            /**
791             * Removes the message boards mailing list where uuid = &#63; and groupId = &#63; from the database.
792             *
793             * @param uuid the uuid
794             * @param groupId the group ID
795             * @return the message boards mailing list that was removed
796             * @throws SystemException if a system exception occurred
797             */
798            @Override
799            public MBMailingList removeByUUID_G(String uuid, long groupId)
800                    throws NoSuchMailingListException, SystemException {
801                    MBMailingList mbMailingList = findByUUID_G(uuid, groupId);
802    
803                    return remove(mbMailingList);
804            }
805    
806            /**
807             * Returns the number of message boards mailing lists where uuid = &#63; and groupId = &#63;.
808             *
809             * @param uuid the uuid
810             * @param groupId the group ID
811             * @return the number of matching message boards mailing lists
812             * @throws SystemException if a system exception occurred
813             */
814            @Override
815            public int countByUUID_G(String uuid, long groupId)
816                    throws SystemException {
817                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
818    
819                    Object[] finderArgs = new Object[] { uuid, groupId };
820    
821                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
822                                    this);
823    
824                    if (count == null) {
825                            StringBundler query = new StringBundler(3);
826    
827                            query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
828    
829                            boolean bindUuid = false;
830    
831                            if (uuid == null) {
832                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
833                            }
834                            else if (uuid.equals(StringPool.BLANK)) {
835                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
836                            }
837                            else {
838                                    bindUuid = true;
839    
840                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
841                            }
842    
843                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
844    
845                            String sql = query.toString();
846    
847                            Session session = null;
848    
849                            try {
850                                    session = openSession();
851    
852                                    Query q = session.createQuery(sql);
853    
854                                    QueryPos qPos = QueryPos.getInstance(q);
855    
856                                    if (bindUuid) {
857                                            qPos.add(uuid);
858                                    }
859    
860                                    qPos.add(groupId);
861    
862                                    count = (Long)q.uniqueResult();
863    
864                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
865                            }
866                            catch (Exception e) {
867                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
868    
869                                    throw processException(e);
870                            }
871                            finally {
872                                    closeSession(session);
873                            }
874                    }
875    
876                    return count.intValue();
877            }
878    
879            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMailingList.uuid IS NULL AND ";
880            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMailingList.uuid = ? AND ";
881            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = '') AND ";
882            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMailingList.groupId = ?";
883            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
884                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
885                            MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
886                            "findByUuid_C",
887                            new String[] {
888                                    String.class.getName(), Long.class.getName(),
889                                    
890                            Integer.class.getName(), Integer.class.getName(),
891                                    OrderByComparator.class.getName()
892                            });
893            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
894                    new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
895                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
896                            MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
897                            "findByUuid_C",
898                            new String[] { String.class.getName(), Long.class.getName() },
899                            MBMailingListModelImpl.UUID_COLUMN_BITMASK |
900                            MBMailingListModelImpl.COMPANYID_COLUMN_BITMASK);
901            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
902                            MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
903                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
904                            new String[] { String.class.getName(), Long.class.getName() });
905    
906            /**
907             * Returns all the message boards mailing lists where uuid = &#63; and companyId = &#63;.
908             *
909             * @param uuid the uuid
910             * @param companyId the company ID
911             * @return the matching message boards mailing lists
912             * @throws SystemException if a system exception occurred
913             */
914            @Override
915            public List<MBMailingList> findByUuid_C(String uuid, long companyId)
916                    throws SystemException {
917                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
918                            QueryUtil.ALL_POS, null);
919            }
920    
921            /**
922             * Returns a range of all the message boards mailing lists where uuid = &#63; and companyId = &#63;.
923             *
924             * <p>
925             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.MBMailingListModelImpl}. 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.
926             * </p>
927             *
928             * @param uuid the uuid
929             * @param companyId the company ID
930             * @param start the lower bound of the range of message boards mailing lists
931             * @param end the upper bound of the range of message boards mailing lists (not inclusive)
932             * @return the range of matching message boards mailing lists
933             * @throws SystemException if a system exception occurred
934             */
935            @Override
936            public List<MBMailingList> findByUuid_C(String uuid, long companyId,
937                    int start, int end) throws SystemException {
938                    return findByUuid_C(uuid, companyId, start, end, null);
939            }
940    
941            /**
942             * Returns an ordered range of all the message boards mailing lists where uuid = &#63; and companyId = &#63;.
943             *
944             * <p>
945             * 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.MBMailingListModelImpl}. 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.
946             * </p>
947             *
948             * @param uuid the uuid
949             * @param companyId the company ID
950             * @param start the lower bound of the range of message boards mailing lists
951             * @param end the upper bound of the range of message boards mailing lists (not inclusive)
952             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
953             * @return the ordered range of matching message boards mailing lists
954             * @throws SystemException if a system exception occurred
955             */
956            @Override
957            public List<MBMailingList> findByUuid_C(String uuid, long companyId,
958                    int start, int end, OrderByComparator orderByComparator)
959                    throws SystemException {
960                    boolean pagination = true;
961                    FinderPath finderPath = null;
962                    Object[] finderArgs = null;
963    
964                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
965                                    (orderByComparator == null)) {
966                            pagination = false;
967                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
968                            finderArgs = new Object[] { uuid, companyId };
969                    }
970                    else {
971                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
972                            finderArgs = new Object[] {
973                                            uuid, companyId,
974                                            
975                                            start, end, orderByComparator
976                                    };
977                    }
978    
979                    List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
980                                    finderArgs, this);
981    
982                    if ((list != null) && !list.isEmpty()) {
983                            for (MBMailingList mbMailingList : list) {
984                                    if (!Validator.equals(uuid, mbMailingList.getUuid()) ||
985                                                    (companyId != mbMailingList.getCompanyId())) {
986                                            list = null;
987    
988                                            break;
989                                    }
990                            }
991                    }
992    
993                    if (list == null) {
994                            StringBundler query = null;
995    
996                            if (orderByComparator != null) {
997                                    query = new StringBundler(4 +
998                                                    (orderByComparator.getOrderByFields().length * 3));
999                            }
1000                            else {
1001                                    query = new StringBundler(4);
1002                            }
1003    
1004                            query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1005    
1006                            boolean bindUuid = false;
1007    
1008                            if (uuid == null) {
1009                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1010                            }
1011                            else if (uuid.equals(StringPool.BLANK)) {
1012                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1013                            }
1014                            else {
1015                                    bindUuid = true;
1016    
1017                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1018                            }
1019    
1020                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1021    
1022                            if (orderByComparator != null) {
1023                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1024                                            orderByComparator);
1025                            }
1026                            else
1027                             if (pagination) {
1028                                    query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
1029                            }
1030    
1031                            String sql = query.toString();
1032    
1033                            Session session = null;
1034    
1035                            try {
1036                                    session = openSession();
1037    
1038                                    Query q = session.createQuery(sql);
1039    
1040                                    QueryPos qPos = QueryPos.getInstance(q);
1041    
1042                                    if (bindUuid) {
1043                                            qPos.add(uuid);
1044                                    }
1045    
1046                                    qPos.add(companyId);
1047    
1048                                    if (!pagination) {
1049                                            list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1050                                                            start, end, false);
1051    
1052                                            Collections.sort(list);
1053    
1054                                            list = new UnmodifiableList<MBMailingList>(list);
1055                                    }
1056                                    else {
1057                                            list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1058                                                            start, end);
1059                                    }
1060    
1061                                    cacheResult(list);
1062    
1063                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1064                            }
1065                            catch (Exception e) {
1066                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1067    
1068                                    throw processException(e);
1069                            }
1070                            finally {
1071                                    closeSession(session);
1072                            }
1073                    }
1074    
1075                    return list;
1076            }
1077    
1078            /**
1079             * Returns the first message boards mailing list in the ordered set where uuid = &#63; and companyId = &#63;.
1080             *
1081             * @param uuid the uuid
1082             * @param companyId the company ID
1083             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1084             * @return the first matching message boards mailing list
1085             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a matching message boards mailing list could not be found
1086             * @throws SystemException if a system exception occurred
1087             */
1088            @Override
1089            public MBMailingList findByUuid_C_First(String uuid, long companyId,
1090                    OrderByComparator orderByComparator)
1091                    throws NoSuchMailingListException, SystemException {
1092                    MBMailingList mbMailingList = fetchByUuid_C_First(uuid, companyId,
1093                                    orderByComparator);
1094    
1095                    if (mbMailingList != null) {
1096                            return mbMailingList;
1097                    }
1098    
1099                    StringBundler msg = new StringBundler(6);
1100    
1101                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1102    
1103                    msg.append("uuid=");
1104                    msg.append(uuid);
1105    
1106                    msg.append(", companyId=");
1107                    msg.append(companyId);
1108    
1109                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1110    
1111                    throw new NoSuchMailingListException(msg.toString());
1112            }
1113    
1114            /**
1115             * Returns the first message boards mailing list in the ordered set where uuid = &#63; and companyId = &#63;.
1116             *
1117             * @param uuid the uuid
1118             * @param companyId the company ID
1119             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1120             * @return the first matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
1121             * @throws SystemException if a system exception occurred
1122             */
1123            @Override
1124            public MBMailingList fetchByUuid_C_First(String uuid, long companyId,
1125                    OrderByComparator orderByComparator) throws SystemException {
1126                    List<MBMailingList> list = findByUuid_C(uuid, companyId, 0, 1,
1127                                    orderByComparator);
1128    
1129                    if (!list.isEmpty()) {
1130                            return list.get(0);
1131                    }
1132    
1133                    return null;
1134            }
1135    
1136            /**
1137             * Returns the last message boards mailing list in the ordered set where uuid = &#63; and companyId = &#63;.
1138             *
1139             * @param uuid the uuid
1140             * @param companyId the company ID
1141             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1142             * @return the last matching message boards mailing list
1143             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a matching message boards mailing list could not be found
1144             * @throws SystemException if a system exception occurred
1145             */
1146            @Override
1147            public MBMailingList findByUuid_C_Last(String uuid, long companyId,
1148                    OrderByComparator orderByComparator)
1149                    throws NoSuchMailingListException, SystemException {
1150                    MBMailingList mbMailingList = fetchByUuid_C_Last(uuid, companyId,
1151                                    orderByComparator);
1152    
1153                    if (mbMailingList != null) {
1154                            return mbMailingList;
1155                    }
1156    
1157                    StringBundler msg = new StringBundler(6);
1158    
1159                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1160    
1161                    msg.append("uuid=");
1162                    msg.append(uuid);
1163    
1164                    msg.append(", companyId=");
1165                    msg.append(companyId);
1166    
1167                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1168    
1169                    throw new NoSuchMailingListException(msg.toString());
1170            }
1171    
1172            /**
1173             * Returns the last message boards mailing list in the ordered set where uuid = &#63; and companyId = &#63;.
1174             *
1175             * @param uuid the uuid
1176             * @param companyId the company ID
1177             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1178             * @return the last matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
1179             * @throws SystemException if a system exception occurred
1180             */
1181            @Override
1182            public MBMailingList fetchByUuid_C_Last(String uuid, long companyId,
1183                    OrderByComparator orderByComparator) throws SystemException {
1184                    int count = countByUuid_C(uuid, companyId);
1185    
1186                    if (count == 0) {
1187                            return null;
1188                    }
1189    
1190                    List<MBMailingList> list = findByUuid_C(uuid, companyId, count - 1,
1191                                    count, orderByComparator);
1192    
1193                    if (!list.isEmpty()) {
1194                            return list.get(0);
1195                    }
1196    
1197                    return null;
1198            }
1199    
1200            /**
1201             * Returns the message boards mailing lists before and after the current message boards mailing list in the ordered set where uuid = &#63; and companyId = &#63;.
1202             *
1203             * @param mailingListId the primary key of the current message boards mailing list
1204             * @param uuid the uuid
1205             * @param companyId the company ID
1206             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1207             * @return the previous, current, and next message boards mailing list
1208             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a message boards mailing list with the primary key could not be found
1209             * @throws SystemException if a system exception occurred
1210             */
1211            @Override
1212            public MBMailingList[] findByUuid_C_PrevAndNext(long mailingListId,
1213                    String uuid, long companyId, OrderByComparator orderByComparator)
1214                    throws NoSuchMailingListException, SystemException {
1215                    MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1216    
1217                    Session session = null;
1218    
1219                    try {
1220                            session = openSession();
1221    
1222                            MBMailingList[] array = new MBMailingListImpl[3];
1223    
1224                            array[0] = getByUuid_C_PrevAndNext(session, mbMailingList, uuid,
1225                                            companyId, orderByComparator, true);
1226    
1227                            array[1] = mbMailingList;
1228    
1229                            array[2] = getByUuid_C_PrevAndNext(session, mbMailingList, uuid,
1230                                            companyId, orderByComparator, false);
1231    
1232                            return array;
1233                    }
1234                    catch (Exception e) {
1235                            throw processException(e);
1236                    }
1237                    finally {
1238                            closeSession(session);
1239                    }
1240            }
1241    
1242            protected MBMailingList getByUuid_C_PrevAndNext(Session session,
1243                    MBMailingList mbMailingList, String uuid, long companyId,
1244                    OrderByComparator orderByComparator, boolean previous) {
1245                    StringBundler query = null;
1246    
1247                    if (orderByComparator != null) {
1248                            query = new StringBundler(6 +
1249                                            (orderByComparator.getOrderByFields().length * 6));
1250                    }
1251                    else {
1252                            query = new StringBundler(3);
1253                    }
1254    
1255                    query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1256    
1257                    boolean bindUuid = false;
1258    
1259                    if (uuid == null) {
1260                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1261                    }
1262                    else if (uuid.equals(StringPool.BLANK)) {
1263                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1264                    }
1265                    else {
1266                            bindUuid = true;
1267    
1268                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1269                    }
1270    
1271                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1272    
1273                    if (orderByComparator != null) {
1274                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1275    
1276                            if (orderByConditionFields.length > 0) {
1277                                    query.append(WHERE_AND);
1278                            }
1279    
1280                            for (int i = 0; i < orderByConditionFields.length; i++) {
1281                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1282                                    query.append(orderByConditionFields[i]);
1283    
1284                                    if ((i + 1) < orderByConditionFields.length) {
1285                                            if (orderByComparator.isAscending() ^ previous) {
1286                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1287                                            }
1288                                            else {
1289                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1290                                            }
1291                                    }
1292                                    else {
1293                                            if (orderByComparator.isAscending() ^ previous) {
1294                                                    query.append(WHERE_GREATER_THAN);
1295                                            }
1296                                            else {
1297                                                    query.append(WHERE_LESSER_THAN);
1298                                            }
1299                                    }
1300                            }
1301    
1302                            query.append(ORDER_BY_CLAUSE);
1303    
1304                            String[] orderByFields = orderByComparator.getOrderByFields();
1305    
1306                            for (int i = 0; i < orderByFields.length; i++) {
1307                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1308                                    query.append(orderByFields[i]);
1309    
1310                                    if ((i + 1) < orderByFields.length) {
1311                                            if (orderByComparator.isAscending() ^ previous) {
1312                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1313                                            }
1314                                            else {
1315                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1316                                            }
1317                                    }
1318                                    else {
1319                                            if (orderByComparator.isAscending() ^ previous) {
1320                                                    query.append(ORDER_BY_ASC);
1321                                            }
1322                                            else {
1323                                                    query.append(ORDER_BY_DESC);
1324                                            }
1325                                    }
1326                            }
1327                    }
1328                    else {
1329                            query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
1330                    }
1331    
1332                    String sql = query.toString();
1333    
1334                    Query q = session.createQuery(sql);
1335    
1336                    q.setFirstResult(0);
1337                    q.setMaxResults(2);
1338    
1339                    QueryPos qPos = QueryPos.getInstance(q);
1340    
1341                    if (bindUuid) {
1342                            qPos.add(uuid);
1343                    }
1344    
1345                    qPos.add(companyId);
1346    
1347                    if (orderByComparator != null) {
1348                            Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1349    
1350                            for (Object value : values) {
1351                                    qPos.add(value);
1352                            }
1353                    }
1354    
1355                    List<MBMailingList> list = q.list();
1356    
1357                    if (list.size() == 2) {
1358                            return list.get(1);
1359                    }
1360                    else {
1361                            return null;
1362                    }
1363            }
1364    
1365            /**
1366             * Removes all the message boards mailing lists where uuid = &#63; and companyId = &#63; from the database.
1367             *
1368             * @param uuid the uuid
1369             * @param companyId the company ID
1370             * @throws SystemException if a system exception occurred
1371             */
1372            @Override
1373            public void removeByUuid_C(String uuid, long companyId)
1374                    throws SystemException {
1375                    for (MBMailingList mbMailingList : findByUuid_C(uuid, companyId,
1376                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1377                            remove(mbMailingList);
1378                    }
1379            }
1380    
1381            /**
1382             * Returns the number of message boards mailing lists where uuid = &#63; and companyId = &#63;.
1383             *
1384             * @param uuid the uuid
1385             * @param companyId the company ID
1386             * @return the number of matching message boards mailing lists
1387             * @throws SystemException if a system exception occurred
1388             */
1389            @Override
1390            public int countByUuid_C(String uuid, long companyId)
1391                    throws SystemException {
1392                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1393    
1394                    Object[] finderArgs = new Object[] { uuid, companyId };
1395    
1396                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1397                                    this);
1398    
1399                    if (count == null) {
1400                            StringBundler query = new StringBundler(3);
1401    
1402                            query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1403    
1404                            boolean bindUuid = false;
1405    
1406                            if (uuid == null) {
1407                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1408                            }
1409                            else if (uuid.equals(StringPool.BLANK)) {
1410                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1411                            }
1412                            else {
1413                                    bindUuid = true;
1414    
1415                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1416                            }
1417    
1418                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1419    
1420                            String sql = query.toString();
1421    
1422                            Session session = null;
1423    
1424                            try {
1425                                    session = openSession();
1426    
1427                                    Query q = session.createQuery(sql);
1428    
1429                                    QueryPos qPos = QueryPos.getInstance(q);
1430    
1431                                    if (bindUuid) {
1432                                            qPos.add(uuid);
1433                                    }
1434    
1435                                    qPos.add(companyId);
1436    
1437                                    count = (Long)q.uniqueResult();
1438    
1439                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1440                            }
1441                            catch (Exception e) {
1442                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1443    
1444                                    throw processException(e);
1445                            }
1446                            finally {
1447                                    closeSession(session);
1448                            }
1449                    }
1450    
1451                    return count.intValue();
1452            }
1453    
1454            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mbMailingList.uuid IS NULL AND ";
1455            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbMailingList.uuid = ? AND ";
1456            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = '') AND ";
1457            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbMailingList.companyId = ?";
1458            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1459                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
1460                            MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1461                            "findByActive",
1462                            new String[] {
1463                                    Boolean.class.getName(),
1464                                    
1465                            Integer.class.getName(), Integer.class.getName(),
1466                                    OrderByComparator.class.getName()
1467                            });
1468            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
1469                    new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1470                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
1471                            MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1472                            "findByActive", new String[] { Boolean.class.getName() },
1473                            MBMailingListModelImpl.ACTIVE_COLUMN_BITMASK);
1474            public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1475                            MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
1476                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
1477                            new String[] { Boolean.class.getName() });
1478    
1479            /**
1480             * Returns all the message boards mailing lists where active = &#63;.
1481             *
1482             * @param active the active
1483             * @return the matching message boards mailing lists
1484             * @throws SystemException if a system exception occurred
1485             */
1486            @Override
1487            public List<MBMailingList> findByActive(boolean active)
1488                    throws SystemException {
1489                    return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1490            }
1491    
1492            /**
1493             * Returns a range of all the message boards mailing lists where active = &#63;.
1494             *
1495             * <p>
1496             * 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.MBMailingListModelImpl}. 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.
1497             * </p>
1498             *
1499             * @param active the active
1500             * @param start the lower bound of the range of message boards mailing lists
1501             * @param end the upper bound of the range of message boards mailing lists (not inclusive)
1502             * @return the range of matching message boards mailing lists
1503             * @throws SystemException if a system exception occurred
1504             */
1505            @Override
1506            public List<MBMailingList> findByActive(boolean active, int start, int end)
1507                    throws SystemException {
1508                    return findByActive(active, start, end, null);
1509            }
1510    
1511            /**
1512             * Returns an ordered range of all the message boards mailing lists where active = &#63;.
1513             *
1514             * <p>
1515             * 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.MBMailingListModelImpl}. 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.
1516             * </p>
1517             *
1518             * @param active the active
1519             * @param start the lower bound of the range of message boards mailing lists
1520             * @param end the upper bound of the range of message boards mailing lists (not inclusive)
1521             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1522             * @return the ordered range of matching message boards mailing lists
1523             * @throws SystemException if a system exception occurred
1524             */
1525            @Override
1526            public List<MBMailingList> findByActive(boolean active, int start, int end,
1527                    OrderByComparator orderByComparator) throws SystemException {
1528                    boolean pagination = true;
1529                    FinderPath finderPath = null;
1530                    Object[] finderArgs = null;
1531    
1532                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1533                                    (orderByComparator == null)) {
1534                            pagination = false;
1535                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
1536                            finderArgs = new Object[] { active };
1537                    }
1538                    else {
1539                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
1540                            finderArgs = new Object[] { active, start, end, orderByComparator };
1541                    }
1542    
1543                    List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
1544                                    finderArgs, this);
1545    
1546                    if ((list != null) && !list.isEmpty()) {
1547                            for (MBMailingList mbMailingList : list) {
1548                                    if ((active != mbMailingList.getActive())) {
1549                                            list = null;
1550    
1551                                            break;
1552                                    }
1553                            }
1554                    }
1555    
1556                    if (list == null) {
1557                            StringBundler query = null;
1558    
1559                            if (orderByComparator != null) {
1560                                    query = new StringBundler(3 +
1561                                                    (orderByComparator.getOrderByFields().length * 3));
1562                            }
1563                            else {
1564                                    query = new StringBundler(3);
1565                            }
1566    
1567                            query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1568    
1569                            query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1570    
1571                            if (orderByComparator != null) {
1572                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1573                                            orderByComparator);
1574                            }
1575                            else
1576                             if (pagination) {
1577                                    query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
1578                            }
1579    
1580                            String sql = query.toString();
1581    
1582                            Session session = null;
1583    
1584                            try {
1585                                    session = openSession();
1586    
1587                                    Query q = session.createQuery(sql);
1588    
1589                                    QueryPos qPos = QueryPos.getInstance(q);
1590    
1591                                    qPos.add(active);
1592    
1593                                    if (!pagination) {
1594                                            list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1595                                                            start, end, false);
1596    
1597                                            Collections.sort(list);
1598    
1599                                            list = new UnmodifiableList<MBMailingList>(list);
1600                                    }
1601                                    else {
1602                                            list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1603                                                            start, end);
1604                                    }
1605    
1606                                    cacheResult(list);
1607    
1608                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1609                            }
1610                            catch (Exception e) {
1611                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1612    
1613                                    throw processException(e);
1614                            }
1615                            finally {
1616                                    closeSession(session);
1617                            }
1618                    }
1619    
1620                    return list;
1621            }
1622    
1623            /**
1624             * Returns the first message boards mailing list in the ordered set where active = &#63;.
1625             *
1626             * @param active the active
1627             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1628             * @return the first matching message boards mailing list
1629             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a matching message boards mailing list could not be found
1630             * @throws SystemException if a system exception occurred
1631             */
1632            @Override
1633            public MBMailingList findByActive_First(boolean active,
1634                    OrderByComparator orderByComparator)
1635                    throws NoSuchMailingListException, SystemException {
1636                    MBMailingList mbMailingList = fetchByActive_First(active,
1637                                    orderByComparator);
1638    
1639                    if (mbMailingList != null) {
1640                            return mbMailingList;
1641                    }
1642    
1643                    StringBundler msg = new StringBundler(4);
1644    
1645                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1646    
1647                    msg.append("active=");
1648                    msg.append(active);
1649    
1650                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1651    
1652                    throw new NoSuchMailingListException(msg.toString());
1653            }
1654    
1655            /**
1656             * Returns the first message boards mailing list in the ordered set where active = &#63;.
1657             *
1658             * @param active the active
1659             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1660             * @return the first matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
1661             * @throws SystemException if a system exception occurred
1662             */
1663            @Override
1664            public MBMailingList fetchByActive_First(boolean active,
1665                    OrderByComparator orderByComparator) throws SystemException {
1666                    List<MBMailingList> list = findByActive(active, 0, 1, orderByComparator);
1667    
1668                    if (!list.isEmpty()) {
1669                            return list.get(0);
1670                    }
1671    
1672                    return null;
1673            }
1674    
1675            /**
1676             * Returns the last message boards mailing list in the ordered set where active = &#63;.
1677             *
1678             * @param active the active
1679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1680             * @return the last matching message boards mailing list
1681             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a matching message boards mailing list could not be found
1682             * @throws SystemException if a system exception occurred
1683             */
1684            @Override
1685            public MBMailingList findByActive_Last(boolean active,
1686                    OrderByComparator orderByComparator)
1687                    throws NoSuchMailingListException, SystemException {
1688                    MBMailingList mbMailingList = fetchByActive_Last(active,
1689                                    orderByComparator);
1690    
1691                    if (mbMailingList != null) {
1692                            return mbMailingList;
1693                    }
1694    
1695                    StringBundler msg = new StringBundler(4);
1696    
1697                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1698    
1699                    msg.append("active=");
1700                    msg.append(active);
1701    
1702                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1703    
1704                    throw new NoSuchMailingListException(msg.toString());
1705            }
1706    
1707            /**
1708             * Returns the last message boards mailing list in the ordered set where active = &#63;.
1709             *
1710             * @param active the active
1711             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1712             * @return the last matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
1713             * @throws SystemException if a system exception occurred
1714             */
1715            @Override
1716            public MBMailingList fetchByActive_Last(boolean active,
1717                    OrderByComparator orderByComparator) throws SystemException {
1718                    int count = countByActive(active);
1719    
1720                    if (count == 0) {
1721                            return null;
1722                    }
1723    
1724                    List<MBMailingList> list = findByActive(active, count - 1, count,
1725                                    orderByComparator);
1726    
1727                    if (!list.isEmpty()) {
1728                            return list.get(0);
1729                    }
1730    
1731                    return null;
1732            }
1733    
1734            /**
1735             * Returns the message boards mailing lists before and after the current message boards mailing list in the ordered set where active = &#63;.
1736             *
1737             * @param mailingListId the primary key of the current message boards mailing list
1738             * @param active the active
1739             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1740             * @return the previous, current, and next message boards mailing list
1741             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a message boards mailing list with the primary key could not be found
1742             * @throws SystemException if a system exception occurred
1743             */
1744            @Override
1745            public MBMailingList[] findByActive_PrevAndNext(long mailingListId,
1746                    boolean active, OrderByComparator orderByComparator)
1747                    throws NoSuchMailingListException, SystemException {
1748                    MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1749    
1750                    Session session = null;
1751    
1752                    try {
1753                            session = openSession();
1754    
1755                            MBMailingList[] array = new MBMailingListImpl[3];
1756    
1757                            array[0] = getByActive_PrevAndNext(session, mbMailingList, active,
1758                                            orderByComparator, true);
1759    
1760                            array[1] = mbMailingList;
1761    
1762                            array[2] = getByActive_PrevAndNext(session, mbMailingList, active,
1763                                            orderByComparator, false);
1764    
1765                            return array;
1766                    }
1767                    catch (Exception e) {
1768                            throw processException(e);
1769                    }
1770                    finally {
1771                            closeSession(session);
1772                    }
1773            }
1774    
1775            protected MBMailingList getByActive_PrevAndNext(Session session,
1776                    MBMailingList mbMailingList, boolean active,
1777                    OrderByComparator orderByComparator, boolean previous) {
1778                    StringBundler query = null;
1779    
1780                    if (orderByComparator != null) {
1781                            query = new StringBundler(6 +
1782                                            (orderByComparator.getOrderByFields().length * 6));
1783                    }
1784                    else {
1785                            query = new StringBundler(3);
1786                    }
1787    
1788                    query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1789    
1790                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1791    
1792                    if (orderByComparator != null) {
1793                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1794    
1795                            if (orderByConditionFields.length > 0) {
1796                                    query.append(WHERE_AND);
1797                            }
1798    
1799                            for (int i = 0; i < orderByConditionFields.length; i++) {
1800                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1801                                    query.append(orderByConditionFields[i]);
1802    
1803                                    if ((i + 1) < orderByConditionFields.length) {
1804                                            if (orderByComparator.isAscending() ^ previous) {
1805                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1806                                            }
1807                                            else {
1808                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1809                                            }
1810                                    }
1811                                    else {
1812                                            if (orderByComparator.isAscending() ^ previous) {
1813                                                    query.append(WHERE_GREATER_THAN);
1814                                            }
1815                                            else {
1816                                                    query.append(WHERE_LESSER_THAN);
1817                                            }
1818                                    }
1819                            }
1820    
1821                            query.append(ORDER_BY_CLAUSE);
1822    
1823                            String[] orderByFields = orderByComparator.getOrderByFields();
1824    
1825                            for (int i = 0; i < orderByFields.length; i++) {
1826                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1827                                    query.append(orderByFields[i]);
1828    
1829                                    if ((i + 1) < orderByFields.length) {
1830                                            if (orderByComparator.isAscending() ^ previous) {
1831                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1832                                            }
1833                                            else {
1834                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1835                                            }
1836                                    }
1837                                    else {
1838                                            if (orderByComparator.isAscending() ^ previous) {
1839                                                    query.append(ORDER_BY_ASC);
1840                                            }
1841                                            else {
1842                                                    query.append(ORDER_BY_DESC);
1843                                            }
1844                                    }
1845                            }
1846                    }
1847                    else {
1848                            query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
1849                    }
1850    
1851                    String sql = query.toString();
1852    
1853                    Query q = session.createQuery(sql);
1854    
1855                    q.setFirstResult(0);
1856                    q.setMaxResults(2);
1857    
1858                    QueryPos qPos = QueryPos.getInstance(q);
1859    
1860                    qPos.add(active);
1861    
1862                    if (orderByComparator != null) {
1863                            Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1864    
1865                            for (Object value : values) {
1866                                    qPos.add(value);
1867                            }
1868                    }
1869    
1870                    List<MBMailingList> list = q.list();
1871    
1872                    if (list.size() == 2) {
1873                            return list.get(1);
1874                    }
1875                    else {
1876                            return null;
1877                    }
1878            }
1879    
1880            /**
1881             * Removes all the message boards mailing lists where active = &#63; from the database.
1882             *
1883             * @param active the active
1884             * @throws SystemException if a system exception occurred
1885             */
1886            @Override
1887            public void removeByActive(boolean active) throws SystemException {
1888                    for (MBMailingList mbMailingList : findByActive(active,
1889                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1890                            remove(mbMailingList);
1891                    }
1892            }
1893    
1894            /**
1895             * Returns the number of message boards mailing lists where active = &#63;.
1896             *
1897             * @param active the active
1898             * @return the number of matching message boards mailing lists
1899             * @throws SystemException if a system exception occurred
1900             */
1901            @Override
1902            public int countByActive(boolean active) throws SystemException {
1903                    FinderPath finderPath = FINDER_PATH_COUNT_BY_ACTIVE;
1904    
1905                    Object[] finderArgs = new Object[] { active };
1906    
1907                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1908                                    this);
1909    
1910                    if (count == null) {
1911                            StringBundler query = new StringBundler(2);
1912    
1913                            query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1914    
1915                            query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1916    
1917                            String sql = query.toString();
1918    
1919                            Session session = null;
1920    
1921                            try {
1922                                    session = openSession();
1923    
1924                                    Query q = session.createQuery(sql);
1925    
1926                                    QueryPos qPos = QueryPos.getInstance(q);
1927    
1928                                    qPos.add(active);
1929    
1930                                    count = (Long)q.uniqueResult();
1931    
1932                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1933                            }
1934                            catch (Exception e) {
1935                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1936    
1937                                    throw processException(e);
1938                            }
1939                            finally {
1940                                    closeSession(session);
1941                            }
1942                    }
1943    
1944                    return count.intValue();
1945            }
1946    
1947            private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "mbMailingList.active = ?";
1948            public static final FinderPath FINDER_PATH_FETCH_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1949                            MBMailingListModelImpl.FINDER_CACHE_ENABLED,
1950                            MBMailingListImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C",
1951                            new String[] { Long.class.getName(), Long.class.getName() },
1952                            MBMailingListModelImpl.GROUPID_COLUMN_BITMASK |
1953                            MBMailingListModelImpl.CATEGORYID_COLUMN_BITMASK);
1954            public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1955                            MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
1956                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
1957                            new String[] { Long.class.getName(), Long.class.getName() });
1958    
1959            /**
1960             * Returns the message boards mailing list where groupId = &#63; and categoryId = &#63; or throws a {@link com.liferay.portlet.messageboards.NoSuchMailingListException} if it could not be found.
1961             *
1962             * @param groupId the group ID
1963             * @param categoryId the category ID
1964             * @return the matching message boards mailing list
1965             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a matching message boards mailing list could not be found
1966             * @throws SystemException if a system exception occurred
1967             */
1968            @Override
1969            public MBMailingList findByG_C(long groupId, long categoryId)
1970                    throws NoSuchMailingListException, SystemException {
1971                    MBMailingList mbMailingList = fetchByG_C(groupId, categoryId);
1972    
1973                    if (mbMailingList == null) {
1974                            StringBundler msg = new StringBundler(6);
1975    
1976                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1977    
1978                            msg.append("groupId=");
1979                            msg.append(groupId);
1980    
1981                            msg.append(", categoryId=");
1982                            msg.append(categoryId);
1983    
1984                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1985    
1986                            if (_log.isWarnEnabled()) {
1987                                    _log.warn(msg.toString());
1988                            }
1989    
1990                            throw new NoSuchMailingListException(msg.toString());
1991                    }
1992    
1993                    return mbMailingList;
1994            }
1995    
1996            /**
1997             * Returns the message boards mailing list where groupId = &#63; and categoryId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1998             *
1999             * @param groupId the group ID
2000             * @param categoryId the category ID
2001             * @return the matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
2002             * @throws SystemException if a system exception occurred
2003             */
2004            @Override
2005            public MBMailingList fetchByG_C(long groupId, long categoryId)
2006                    throws SystemException {
2007                    return fetchByG_C(groupId, categoryId, true);
2008            }
2009    
2010            /**
2011             * Returns the message boards mailing list where groupId = &#63; and categoryId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2012             *
2013             * @param groupId the group ID
2014             * @param categoryId the category ID
2015             * @param retrieveFromCache whether to use the finder cache
2016             * @return the matching message boards mailing list, or <code>null</code> if a matching message boards mailing list could not be found
2017             * @throws SystemException if a system exception occurred
2018             */
2019            @Override
2020            public MBMailingList fetchByG_C(long groupId, long categoryId,
2021                    boolean retrieveFromCache) throws SystemException {
2022                    Object[] finderArgs = new Object[] { groupId, categoryId };
2023    
2024                    Object result = null;
2025    
2026                    if (retrieveFromCache) {
2027                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C,
2028                                            finderArgs, this);
2029                    }
2030    
2031                    if (result instanceof MBMailingList) {
2032                            MBMailingList mbMailingList = (MBMailingList)result;
2033    
2034                            if ((groupId != mbMailingList.getGroupId()) ||
2035                                            (categoryId != mbMailingList.getCategoryId())) {
2036                                    result = null;
2037                            }
2038                    }
2039    
2040                    if (result == null) {
2041                            StringBundler query = new StringBundler(4);
2042    
2043                            query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
2044    
2045                            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2046    
2047                            query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2048    
2049                            String sql = query.toString();
2050    
2051                            Session session = null;
2052    
2053                            try {
2054                                    session = openSession();
2055    
2056                                    Query q = session.createQuery(sql);
2057    
2058                                    QueryPos qPos = QueryPos.getInstance(q);
2059    
2060                                    qPos.add(groupId);
2061    
2062                                    qPos.add(categoryId);
2063    
2064                                    List<MBMailingList> list = q.list();
2065    
2066                                    if (list.isEmpty()) {
2067                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
2068                                                    finderArgs, list);
2069                                    }
2070                                    else {
2071                                            MBMailingList mbMailingList = list.get(0);
2072    
2073                                            result = mbMailingList;
2074    
2075                                            cacheResult(mbMailingList);
2076    
2077                                            if ((mbMailingList.getGroupId() != groupId) ||
2078                                                            (mbMailingList.getCategoryId() != categoryId)) {
2079                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
2080                                                            finderArgs, mbMailingList);
2081                                            }
2082                                    }
2083                            }
2084                            catch (Exception e) {
2085                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
2086                                            finderArgs);
2087    
2088                                    throw processException(e);
2089                            }
2090                            finally {
2091                                    closeSession(session);
2092                            }
2093                    }
2094    
2095                    if (result instanceof List<?>) {
2096                            return null;
2097                    }
2098                    else {
2099                            return (MBMailingList)result;
2100                    }
2101            }
2102    
2103            /**
2104             * Removes the message boards mailing list where groupId = &#63; and categoryId = &#63; from the database.
2105             *
2106             * @param groupId the group ID
2107             * @param categoryId the category ID
2108             * @return the message boards mailing list that was removed
2109             * @throws SystemException if a system exception occurred
2110             */
2111            @Override
2112            public MBMailingList removeByG_C(long groupId, long categoryId)
2113                    throws NoSuchMailingListException, SystemException {
2114                    MBMailingList mbMailingList = findByG_C(groupId, categoryId);
2115    
2116                    return remove(mbMailingList);
2117            }
2118    
2119            /**
2120             * Returns the number of message boards mailing lists where groupId = &#63; and categoryId = &#63;.
2121             *
2122             * @param groupId the group ID
2123             * @param categoryId the category ID
2124             * @return the number of matching message boards mailing lists
2125             * @throws SystemException if a system exception occurred
2126             */
2127            @Override
2128            public int countByG_C(long groupId, long categoryId)
2129                    throws SystemException {
2130                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C;
2131    
2132                    Object[] finderArgs = new Object[] { groupId, categoryId };
2133    
2134                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2135                                    this);
2136    
2137                    if (count == null) {
2138                            StringBundler query = new StringBundler(3);
2139    
2140                            query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2141    
2142                            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2143    
2144                            query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2145    
2146                            String sql = query.toString();
2147    
2148                            Session session = null;
2149    
2150                            try {
2151                                    session = openSession();
2152    
2153                                    Query q = session.createQuery(sql);
2154    
2155                                    QueryPos qPos = QueryPos.getInstance(q);
2156    
2157                                    qPos.add(groupId);
2158    
2159                                    qPos.add(categoryId);
2160    
2161                                    count = (Long)q.uniqueResult();
2162    
2163                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2164                            }
2165                            catch (Exception e) {
2166                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2167    
2168                                    throw processException(e);
2169                            }
2170                            finally {
2171                                    closeSession(session);
2172                            }
2173                    }
2174    
2175                    return count.intValue();
2176            }
2177    
2178            private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMailingList.groupId = ? AND ";
2179            private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMailingList.categoryId = ?";
2180    
2181            public MBMailingListPersistenceImpl() {
2182                    setModelClass(MBMailingList.class);
2183            }
2184    
2185            /**
2186             * Caches the message boards mailing list in the entity cache if it is enabled.
2187             *
2188             * @param mbMailingList the message boards mailing list
2189             */
2190            @Override
2191            public void cacheResult(MBMailingList mbMailingList) {
2192                    EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2193                            MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
2194                            mbMailingList);
2195    
2196                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2197                            new Object[] { mbMailingList.getUuid(), mbMailingList.getGroupId() },
2198                            mbMailingList);
2199    
2200                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
2201                            new Object[] {
2202                                    mbMailingList.getGroupId(), mbMailingList.getCategoryId()
2203                            }, mbMailingList);
2204    
2205                    mbMailingList.resetOriginalValues();
2206            }
2207    
2208            /**
2209             * Caches the message boards mailing lists in the entity cache if it is enabled.
2210             *
2211             * @param mbMailingLists the message boards mailing lists
2212             */
2213            @Override
2214            public void cacheResult(List<MBMailingList> mbMailingLists) {
2215                    for (MBMailingList mbMailingList : mbMailingLists) {
2216                            if (EntityCacheUtil.getResult(
2217                                                    MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2218                                                    MBMailingListImpl.class, mbMailingList.getPrimaryKey()) == null) {
2219                                    cacheResult(mbMailingList);
2220                            }
2221                            else {
2222                                    mbMailingList.resetOriginalValues();
2223                            }
2224                    }
2225            }
2226    
2227            /**
2228             * Clears the cache for all message boards mailing lists.
2229             *
2230             * <p>
2231             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2232             * </p>
2233             */
2234            @Override
2235            public void clearCache() {
2236                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2237                            CacheRegistryUtil.clear(MBMailingListImpl.class.getName());
2238                    }
2239    
2240                    EntityCacheUtil.clearCache(MBMailingListImpl.class.getName());
2241    
2242                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2243                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2244                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2245            }
2246    
2247            /**
2248             * Clears the cache for the message boards mailing list.
2249             *
2250             * <p>
2251             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2252             * </p>
2253             */
2254            @Override
2255            public void clearCache(MBMailingList mbMailingList) {
2256                    EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2257                            MBMailingListImpl.class, mbMailingList.getPrimaryKey());
2258    
2259                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2260                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2261    
2262                    clearUniqueFindersCache(mbMailingList);
2263            }
2264    
2265            @Override
2266            public void clearCache(List<MBMailingList> mbMailingLists) {
2267                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2268                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2269    
2270                    for (MBMailingList mbMailingList : mbMailingLists) {
2271                            EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2272                                    MBMailingListImpl.class, mbMailingList.getPrimaryKey());
2273    
2274                            clearUniqueFindersCache(mbMailingList);
2275                    }
2276            }
2277    
2278            protected void cacheUniqueFindersCache(MBMailingList mbMailingList) {
2279                    if (mbMailingList.isNew()) {
2280                            Object[] args = new Object[] {
2281                                            mbMailingList.getUuid(), mbMailingList.getGroupId()
2282                                    };
2283    
2284                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2285                                    Long.valueOf(1));
2286                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2287                                    mbMailingList);
2288    
2289                            args = new Object[] {
2290                                            mbMailingList.getGroupId(), mbMailingList.getCategoryId()
2291                                    };
2292    
2293                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, args,
2294                                    Long.valueOf(1));
2295                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C, args,
2296                                    mbMailingList);
2297                    }
2298                    else {
2299                            MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
2300    
2301                            if ((mbMailingListModelImpl.getColumnBitmask() &
2302                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2303                                    Object[] args = new Object[] {
2304                                                    mbMailingList.getUuid(), mbMailingList.getGroupId()
2305                                            };
2306    
2307                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2308                                            Long.valueOf(1));
2309                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2310                                            mbMailingList);
2311                            }
2312    
2313                            if ((mbMailingListModelImpl.getColumnBitmask() &
2314                                            FINDER_PATH_FETCH_BY_G_C.getColumnBitmask()) != 0) {
2315                                    Object[] args = new Object[] {
2316                                                    mbMailingList.getGroupId(),
2317                                                    mbMailingList.getCategoryId()
2318                                            };
2319    
2320                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, args,
2321                                            Long.valueOf(1));
2322                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C, args,
2323                                            mbMailingList);
2324                            }
2325                    }
2326            }
2327    
2328            protected void clearUniqueFindersCache(MBMailingList mbMailingList) {
2329                    MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
2330    
2331                    Object[] args = new Object[] {
2332                                    mbMailingList.getUuid(), mbMailingList.getGroupId()
2333                            };
2334    
2335                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2336                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2337    
2338                    if ((mbMailingListModelImpl.getColumnBitmask() &
2339                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2340                            args = new Object[] {
2341                                            mbMailingListModelImpl.getOriginalUuid(),
2342                                            mbMailingListModelImpl.getOriginalGroupId()
2343                                    };
2344    
2345                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2346                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2347                    }
2348    
2349                    args = new Object[] {
2350                                    mbMailingList.getGroupId(), mbMailingList.getCategoryId()
2351                            };
2352    
2353                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
2354                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C, args);
2355    
2356                    if ((mbMailingListModelImpl.getColumnBitmask() &
2357                                    FINDER_PATH_FETCH_BY_G_C.getColumnBitmask()) != 0) {
2358                            args = new Object[] {
2359                                            mbMailingListModelImpl.getOriginalGroupId(),
2360                                            mbMailingListModelImpl.getOriginalCategoryId()
2361                                    };
2362    
2363                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
2364                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C, args);
2365                    }
2366            }
2367    
2368            /**
2369             * Creates a new message boards mailing list with the primary key. Does not add the message boards mailing list to the database.
2370             *
2371             * @param mailingListId the primary key for the new message boards mailing list
2372             * @return the new message boards mailing list
2373             */
2374            @Override
2375            public MBMailingList create(long mailingListId) {
2376                    MBMailingList mbMailingList = new MBMailingListImpl();
2377    
2378                    mbMailingList.setNew(true);
2379                    mbMailingList.setPrimaryKey(mailingListId);
2380    
2381                    String uuid = PortalUUIDUtil.generate();
2382    
2383                    mbMailingList.setUuid(uuid);
2384    
2385                    return mbMailingList;
2386            }
2387    
2388            /**
2389             * Removes the message boards mailing list with the primary key from the database. Also notifies the appropriate model listeners.
2390             *
2391             * @param mailingListId the primary key of the message boards mailing list
2392             * @return the message boards mailing list that was removed
2393             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a message boards mailing list with the primary key could not be found
2394             * @throws SystemException if a system exception occurred
2395             */
2396            @Override
2397            public MBMailingList remove(long mailingListId)
2398                    throws NoSuchMailingListException, SystemException {
2399                    return remove((Serializable)mailingListId);
2400            }
2401    
2402            /**
2403             * Removes the message boards mailing list with the primary key from the database. Also notifies the appropriate model listeners.
2404             *
2405             * @param primaryKey the primary key of the message boards mailing list
2406             * @return the message boards mailing list that was removed
2407             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a message boards mailing list with the primary key could not be found
2408             * @throws SystemException if a system exception occurred
2409             */
2410            @Override
2411            public MBMailingList remove(Serializable primaryKey)
2412                    throws NoSuchMailingListException, SystemException {
2413                    Session session = null;
2414    
2415                    try {
2416                            session = openSession();
2417    
2418                            MBMailingList mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
2419                                            primaryKey);
2420    
2421                            if (mbMailingList == null) {
2422                                    if (_log.isWarnEnabled()) {
2423                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2424                                    }
2425    
2426                                    throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2427                                            primaryKey);
2428                            }
2429    
2430                            return remove(mbMailingList);
2431                    }
2432                    catch (NoSuchMailingListException nsee) {
2433                            throw nsee;
2434                    }
2435                    catch (Exception e) {
2436                            throw processException(e);
2437                    }
2438                    finally {
2439                            closeSession(session);
2440                    }
2441            }
2442    
2443            @Override
2444            protected MBMailingList removeImpl(MBMailingList mbMailingList)
2445                    throws SystemException {
2446                    mbMailingList = toUnwrappedModel(mbMailingList);
2447    
2448                    Session session = null;
2449    
2450                    try {
2451                            session = openSession();
2452    
2453                            if (!session.contains(mbMailingList)) {
2454                                    mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
2455                                                    mbMailingList.getPrimaryKeyObj());
2456                            }
2457    
2458                            if (mbMailingList != null) {
2459                                    session.delete(mbMailingList);
2460                            }
2461                    }
2462                    catch (Exception e) {
2463                            throw processException(e);
2464                    }
2465                    finally {
2466                            closeSession(session);
2467                    }
2468    
2469                    if (mbMailingList != null) {
2470                            clearCache(mbMailingList);
2471                    }
2472    
2473                    return mbMailingList;
2474            }
2475    
2476            @Override
2477            public MBMailingList updateImpl(
2478                    com.liferay.portlet.messageboards.model.MBMailingList mbMailingList)
2479                    throws SystemException {
2480                    mbMailingList = toUnwrappedModel(mbMailingList);
2481    
2482                    boolean isNew = mbMailingList.isNew();
2483    
2484                    MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
2485    
2486                    if (Validator.isNull(mbMailingList.getUuid())) {
2487                            String uuid = PortalUUIDUtil.generate();
2488    
2489                            mbMailingList.setUuid(uuid);
2490                    }
2491    
2492                    Session session = null;
2493    
2494                    try {
2495                            session = openSession();
2496    
2497                            if (mbMailingList.isNew()) {
2498                                    session.save(mbMailingList);
2499    
2500                                    mbMailingList.setNew(false);
2501                            }
2502                            else {
2503                                    session.merge(mbMailingList);
2504                            }
2505                    }
2506                    catch (Exception e) {
2507                            throw processException(e);
2508                    }
2509                    finally {
2510                            closeSession(session);
2511                    }
2512    
2513                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2514    
2515                    if (isNew || !MBMailingListModelImpl.COLUMN_BITMASK_ENABLED) {
2516                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2517                    }
2518    
2519                    else {
2520                            if ((mbMailingListModelImpl.getColumnBitmask() &
2521                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2522                                    Object[] args = new Object[] {
2523                                                    mbMailingListModelImpl.getOriginalUuid()
2524                                            };
2525    
2526                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2527                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2528                                            args);
2529    
2530                                    args = new Object[] { mbMailingListModelImpl.getUuid() };
2531    
2532                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2533                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2534                                            args);
2535                            }
2536    
2537                            if ((mbMailingListModelImpl.getColumnBitmask() &
2538                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2539                                    Object[] args = new Object[] {
2540                                                    mbMailingListModelImpl.getOriginalUuid(),
2541                                                    mbMailingListModelImpl.getOriginalCompanyId()
2542                                            };
2543    
2544                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2545                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2546                                            args);
2547    
2548                                    args = new Object[] {
2549                                                    mbMailingListModelImpl.getUuid(),
2550                                                    mbMailingListModelImpl.getCompanyId()
2551                                            };
2552    
2553                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2554                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2555                                            args);
2556                            }
2557    
2558                            if ((mbMailingListModelImpl.getColumnBitmask() &
2559                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
2560                                    Object[] args = new Object[] {
2561                                                    mbMailingListModelImpl.getOriginalActive()
2562                                            };
2563    
2564                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2565                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2566                                            args);
2567    
2568                                    args = new Object[] { mbMailingListModelImpl.getActive() };
2569    
2570                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2571                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2572                                            args);
2573                            }
2574                    }
2575    
2576                    EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2577                            MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
2578                            mbMailingList);
2579    
2580                    clearUniqueFindersCache(mbMailingList);
2581                    cacheUniqueFindersCache(mbMailingList);
2582    
2583                    return mbMailingList;
2584            }
2585    
2586            protected MBMailingList toUnwrappedModel(MBMailingList mbMailingList) {
2587                    if (mbMailingList instanceof MBMailingListImpl) {
2588                            return mbMailingList;
2589                    }
2590    
2591                    MBMailingListImpl mbMailingListImpl = new MBMailingListImpl();
2592    
2593                    mbMailingListImpl.setNew(mbMailingList.isNew());
2594                    mbMailingListImpl.setPrimaryKey(mbMailingList.getPrimaryKey());
2595    
2596                    mbMailingListImpl.setUuid(mbMailingList.getUuid());
2597                    mbMailingListImpl.setMailingListId(mbMailingList.getMailingListId());
2598                    mbMailingListImpl.setGroupId(mbMailingList.getGroupId());
2599                    mbMailingListImpl.setCompanyId(mbMailingList.getCompanyId());
2600                    mbMailingListImpl.setUserId(mbMailingList.getUserId());
2601                    mbMailingListImpl.setUserName(mbMailingList.getUserName());
2602                    mbMailingListImpl.setCreateDate(mbMailingList.getCreateDate());
2603                    mbMailingListImpl.setModifiedDate(mbMailingList.getModifiedDate());
2604                    mbMailingListImpl.setCategoryId(mbMailingList.getCategoryId());
2605                    mbMailingListImpl.setEmailAddress(mbMailingList.getEmailAddress());
2606                    mbMailingListImpl.setInProtocol(mbMailingList.getInProtocol());
2607                    mbMailingListImpl.setInServerName(mbMailingList.getInServerName());
2608                    mbMailingListImpl.setInServerPort(mbMailingList.getInServerPort());
2609                    mbMailingListImpl.setInUseSSL(mbMailingList.isInUseSSL());
2610                    mbMailingListImpl.setInUserName(mbMailingList.getInUserName());
2611                    mbMailingListImpl.setInPassword(mbMailingList.getInPassword());
2612                    mbMailingListImpl.setInReadInterval(mbMailingList.getInReadInterval());
2613                    mbMailingListImpl.setOutEmailAddress(mbMailingList.getOutEmailAddress());
2614                    mbMailingListImpl.setOutCustom(mbMailingList.isOutCustom());
2615                    mbMailingListImpl.setOutServerName(mbMailingList.getOutServerName());
2616                    mbMailingListImpl.setOutServerPort(mbMailingList.getOutServerPort());
2617                    mbMailingListImpl.setOutUseSSL(mbMailingList.isOutUseSSL());
2618                    mbMailingListImpl.setOutUserName(mbMailingList.getOutUserName());
2619                    mbMailingListImpl.setOutPassword(mbMailingList.getOutPassword());
2620                    mbMailingListImpl.setAllowAnonymous(mbMailingList.isAllowAnonymous());
2621                    mbMailingListImpl.setActive(mbMailingList.isActive());
2622    
2623                    return mbMailingListImpl;
2624            }
2625    
2626            /**
2627             * Returns the message boards mailing list with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2628             *
2629             * @param primaryKey the primary key of the message boards mailing list
2630             * @return the message boards mailing list
2631             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a message boards mailing list with the primary key could not be found
2632             * @throws SystemException if a system exception occurred
2633             */
2634            @Override
2635            public MBMailingList findByPrimaryKey(Serializable primaryKey)
2636                    throws NoSuchMailingListException, SystemException {
2637                    MBMailingList mbMailingList = fetchByPrimaryKey(primaryKey);
2638    
2639                    if (mbMailingList == null) {
2640                            if (_log.isWarnEnabled()) {
2641                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2642                            }
2643    
2644                            throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2645                                    primaryKey);
2646                    }
2647    
2648                    return mbMailingList;
2649            }
2650    
2651            /**
2652             * Returns the message boards mailing list with the primary key or throws a {@link com.liferay.portlet.messageboards.NoSuchMailingListException} if it could not be found.
2653             *
2654             * @param mailingListId the primary key of the message boards mailing list
2655             * @return the message boards mailing list
2656             * @throws com.liferay.portlet.messageboards.NoSuchMailingListException if a message boards mailing list with the primary key could not be found
2657             * @throws SystemException if a system exception occurred
2658             */
2659            @Override
2660            public MBMailingList findByPrimaryKey(long mailingListId)
2661                    throws NoSuchMailingListException, SystemException {
2662                    return findByPrimaryKey((Serializable)mailingListId);
2663            }
2664    
2665            /**
2666             * Returns the message boards mailing list with the primary key or returns <code>null</code> if it could not be found.
2667             *
2668             * @param primaryKey the primary key of the message boards mailing list
2669             * @return the message boards mailing list, or <code>null</code> if a message boards mailing list with the primary key could not be found
2670             * @throws SystemException if a system exception occurred
2671             */
2672            @Override
2673            public MBMailingList fetchByPrimaryKey(Serializable primaryKey)
2674                    throws SystemException {
2675                    MBMailingList mbMailingList = (MBMailingList)EntityCacheUtil.getResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2676                                    MBMailingListImpl.class, primaryKey);
2677    
2678                    if (mbMailingList == _nullMBMailingList) {
2679                            return null;
2680                    }
2681    
2682                    if (mbMailingList == null) {
2683                            Session session = null;
2684    
2685                            try {
2686                                    session = openSession();
2687    
2688                                    mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
2689                                                    primaryKey);
2690    
2691                                    if (mbMailingList != null) {
2692                                            cacheResult(mbMailingList);
2693                                    }
2694                                    else {
2695                                            EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2696                                                    MBMailingListImpl.class, primaryKey, _nullMBMailingList);
2697                                    }
2698                            }
2699                            catch (Exception e) {
2700                                    EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2701                                            MBMailingListImpl.class, primaryKey);
2702    
2703                                    throw processException(e);
2704                            }
2705                            finally {
2706                                    closeSession(session);
2707                            }
2708                    }
2709    
2710                    return mbMailingList;
2711            }
2712    
2713            /**
2714             * Returns the message boards mailing list with the primary key or returns <code>null</code> if it could not be found.
2715             *
2716             * @param mailingListId the primary key of the message boards mailing list
2717             * @return the message boards mailing list, or <code>null</code> if a message boards mailing list with the primary key could not be found
2718             * @throws SystemException if a system exception occurred
2719             */
2720            @Override
2721            public MBMailingList fetchByPrimaryKey(long mailingListId)
2722                    throws SystemException {
2723                    return fetchByPrimaryKey((Serializable)mailingListId);
2724            }
2725    
2726            /**
2727             * Returns all the message boards mailing lists.
2728             *
2729             * @return the message boards mailing lists
2730             * @throws SystemException if a system exception occurred
2731             */
2732            @Override
2733            public List<MBMailingList> findAll() throws SystemException {
2734                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2735            }
2736    
2737            /**
2738             * Returns a range of all the message boards mailing lists.
2739             *
2740             * <p>
2741             * 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.MBMailingListModelImpl}. 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.
2742             * </p>
2743             *
2744             * @param start the lower bound of the range of message boards mailing lists
2745             * @param end the upper bound of the range of message boards mailing lists (not inclusive)
2746             * @return the range of message boards mailing lists
2747             * @throws SystemException if a system exception occurred
2748             */
2749            @Override
2750            public List<MBMailingList> findAll(int start, int end)
2751                    throws SystemException {
2752                    return findAll(start, end, null);
2753            }
2754    
2755            /**
2756             * Returns an ordered range of all the message boards mailing lists.
2757             *
2758             * <p>
2759             * 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.MBMailingListModelImpl}. 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.
2760             * </p>
2761             *
2762             * @param start the lower bound of the range of message boards mailing lists
2763             * @param end the upper bound of the range of message boards mailing lists (not inclusive)
2764             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2765             * @return the ordered range of message boards mailing lists
2766             * @throws SystemException if a system exception occurred
2767             */
2768            @Override
2769            public List<MBMailingList> findAll(int start, int end,
2770                    OrderByComparator orderByComparator) throws SystemException {
2771                    boolean pagination = true;
2772                    FinderPath finderPath = null;
2773                    Object[] finderArgs = null;
2774    
2775                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2776                                    (orderByComparator == null)) {
2777                            pagination = false;
2778                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2779                            finderArgs = FINDER_ARGS_EMPTY;
2780                    }
2781                    else {
2782                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2783                            finderArgs = new Object[] { start, end, orderByComparator };
2784                    }
2785    
2786                    List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
2787                                    finderArgs, this);
2788    
2789                    if (list == null) {
2790                            StringBundler query = null;
2791                            String sql = null;
2792    
2793                            if (orderByComparator != null) {
2794                                    query = new StringBundler(2 +
2795                                                    (orderByComparator.getOrderByFields().length * 3));
2796    
2797                                    query.append(_SQL_SELECT_MBMAILINGLIST);
2798    
2799                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2800                                            orderByComparator);
2801    
2802                                    sql = query.toString();
2803                            }
2804                            else {
2805                                    sql = _SQL_SELECT_MBMAILINGLIST;
2806    
2807                                    if (pagination) {
2808                                            sql = sql.concat(MBMailingListModelImpl.ORDER_BY_JPQL);
2809                                    }
2810                            }
2811    
2812                            Session session = null;
2813    
2814                            try {
2815                                    session = openSession();
2816    
2817                                    Query q = session.createQuery(sql);
2818    
2819                                    if (!pagination) {
2820                                            list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
2821                                                            start, end, false);
2822    
2823                                            Collections.sort(list);
2824    
2825                                            list = new UnmodifiableList<MBMailingList>(list);
2826                                    }
2827                                    else {
2828                                            list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
2829                                                            start, end);
2830                                    }
2831    
2832                                    cacheResult(list);
2833    
2834                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2835                            }
2836                            catch (Exception e) {
2837                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2838    
2839                                    throw processException(e);
2840                            }
2841                            finally {
2842                                    closeSession(session);
2843                            }
2844                    }
2845    
2846                    return list;
2847            }
2848    
2849            /**
2850             * Removes all the message boards mailing lists from the database.
2851             *
2852             * @throws SystemException if a system exception occurred
2853             */
2854            @Override
2855            public void removeAll() throws SystemException {
2856                    for (MBMailingList mbMailingList : findAll()) {
2857                            remove(mbMailingList);
2858                    }
2859            }
2860    
2861            /**
2862             * Returns the number of message boards mailing lists.
2863             *
2864             * @return the number of message boards mailing lists
2865             * @throws SystemException if a system exception occurred
2866             */
2867            @Override
2868            public int countAll() throws SystemException {
2869                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2870                                    FINDER_ARGS_EMPTY, this);
2871    
2872                    if (count == null) {
2873                            Session session = null;
2874    
2875                            try {
2876                                    session = openSession();
2877    
2878                                    Query q = session.createQuery(_SQL_COUNT_MBMAILINGLIST);
2879    
2880                                    count = (Long)q.uniqueResult();
2881    
2882                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2883                                            FINDER_ARGS_EMPTY, count);
2884                            }
2885                            catch (Exception e) {
2886                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2887                                            FINDER_ARGS_EMPTY);
2888    
2889                                    throw processException(e);
2890                            }
2891                            finally {
2892                                    closeSession(session);
2893                            }
2894                    }
2895    
2896                    return count.intValue();
2897            }
2898    
2899            @Override
2900            protected Set<String> getBadColumnNames() {
2901                    return _badColumnNames;
2902            }
2903    
2904            /**
2905             * Initializes the message boards mailing list persistence.
2906             */
2907            public void afterPropertiesSet() {
2908                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2909                                            com.liferay.portal.util.PropsUtil.get(
2910                                                    "value.object.listener.com.liferay.portlet.messageboards.model.MBMailingList")));
2911    
2912                    if (listenerClassNames.length > 0) {
2913                            try {
2914                                    List<ModelListener<MBMailingList>> listenersList = new ArrayList<ModelListener<MBMailingList>>();
2915    
2916                                    for (String listenerClassName : listenerClassNames) {
2917                                            listenersList.add((ModelListener<MBMailingList>)InstanceFactory.newInstance(
2918                                                            getClassLoader(), listenerClassName));
2919                                    }
2920    
2921                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2922                            }
2923                            catch (Exception e) {
2924                                    _log.error(e);
2925                            }
2926                    }
2927            }
2928    
2929            public void destroy() {
2930                    EntityCacheUtil.removeCache(MBMailingListImpl.class.getName());
2931                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2932                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2933                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2934            }
2935    
2936            private static final String _SQL_SELECT_MBMAILINGLIST = "SELECT mbMailingList FROM MBMailingList mbMailingList";
2937            private static final String _SQL_SELECT_MBMAILINGLIST_WHERE = "SELECT mbMailingList FROM MBMailingList mbMailingList WHERE ";
2938            private static final String _SQL_COUNT_MBMAILINGLIST = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList";
2939            private static final String _SQL_COUNT_MBMAILINGLIST_WHERE = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList WHERE ";
2940            private static final String _ORDER_BY_ENTITY_ALIAS = "mbMailingList.";
2941            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMailingList exists with the primary key ";
2942            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMailingList exists with the key {";
2943            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2944            private static Log _log = LogFactoryUtil.getLog(MBMailingListPersistenceImpl.class);
2945            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2946                                    "uuid", "active"
2947                            });
2948            private static MBMailingList _nullMBMailingList = new MBMailingListImpl() {
2949                            @Override
2950                            public Object clone() {
2951                                    return this;
2952                            }
2953    
2954                            @Override
2955                            public CacheModel<MBMailingList> toCacheModel() {
2956                                    return _nullMBMailingListCacheModel;
2957                            }
2958                    };
2959    
2960            private static CacheModel<MBMailingList> _nullMBMailingListCacheModel = new CacheModel<MBMailingList>() {
2961                            @Override
2962                            public MBMailingList toEntityModel() {
2963                                    return _nullMBMailingList;
2964                            }
2965                    };
2966    }