1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.messageboards.service.persistence;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.annotation.BeanReference;
27  import com.liferay.portal.kernel.cache.CacheRegistry;
28  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31  import com.liferay.portal.kernel.dao.orm.FinderPath;
32  import com.liferay.portal.kernel.dao.orm.Query;
33  import com.liferay.portal.kernel.dao.orm.QueryPos;
34  import com.liferay.portal.kernel.dao.orm.QueryUtil;
35  import com.liferay.portal.kernel.dao.orm.Session;
36  import com.liferay.portal.kernel.log.Log;
37  import com.liferay.portal.kernel.log.LogFactoryUtil;
38  import com.liferay.portal.kernel.util.CalendarUtil;
39  import com.liferay.portal.kernel.util.GetterUtil;
40  import com.liferay.portal.kernel.util.OrderByComparator;
41  import com.liferay.portal.kernel.util.StringPool;
42  import com.liferay.portal.kernel.util.StringUtil;
43  import com.liferay.portal.model.ModelListener;
44  import com.liferay.portal.service.persistence.BatchSessionUtil;
45  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
46  
47  import com.liferay.portlet.messageboards.NoSuchThreadException;
48  import com.liferay.portlet.messageboards.model.MBThread;
49  import com.liferay.portlet.messageboards.model.impl.MBThreadImpl;
50  import com.liferay.portlet.messageboards.model.impl.MBThreadModelImpl;
51  
52  import java.util.ArrayList;
53  import java.util.Collections;
54  import java.util.Date;
55  import java.util.List;
56  
57  /**
58   * <a href="MBThreadPersistenceImpl.java.html"><b><i>View Source</i></b></a>
59   *
60   * <p>
61   * ServiceBuilder generated this class. Modifications in this class will be
62   * overwritten the next time is generated.
63   * </p>
64   *
65   * @author    Brian Wing Shun Chan
66   * @see       MBThreadPersistence
67   * @see       MBThreadUtil
68   * @generated
69   */
70  public class MBThreadPersistenceImpl extends BasePersistenceImpl
71      implements MBThreadPersistence {
72      public static final String FINDER_CLASS_NAME_ENTITY = MBThreadImpl.class.getName();
73      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74          ".List";
75      public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
76              MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
77              "findByGroupId", new String[] { Long.class.getName() });
78      public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
79              MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
80              "findByGroupId",
81              new String[] {
82                  Long.class.getName(),
83                  
84              "java.lang.Integer", "java.lang.Integer",
85                  "com.liferay.portal.kernel.util.OrderByComparator"
86              });
87      public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
88              MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89              "countByGroupId", new String[] { Long.class.getName() });
90      public static final FinderPath FINDER_PATH_FIND_BY_CATEGORYID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
91              MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
92              "findByCategoryId", new String[] { Long.class.getName() });
93      public static final FinderPath FINDER_PATH_FIND_BY_OBC_CATEGORYID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
94              MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
95              "findByCategoryId",
96              new String[] {
97                  Long.class.getName(),
98                  
99              "java.lang.Integer", "java.lang.Integer",
100                 "com.liferay.portal.kernel.util.OrderByComparator"
101             });
102     public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
103             MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104             "countByCategoryId", new String[] { Long.class.getName() });
105     public static final FinderPath FINDER_PATH_FIND_BY_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
106             MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
107             "findByC_L",
108             new String[] { Long.class.getName(), Date.class.getName() });
109     public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
110             MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111             "findByC_L",
112             new String[] {
113                 Long.class.getName(), Date.class.getName(),
114                 
115             "java.lang.Integer", "java.lang.Integer",
116                 "com.liferay.portal.kernel.util.OrderByComparator"
117             });
118     public static final FinderPath FINDER_PATH_COUNT_BY_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
119             MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
120             "countByC_L",
121             new String[] { Long.class.getName(), Date.class.getName() });
122     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
123             MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
124             "findAll", new String[0]);
125     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
126             MBThreadModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
127             "countAll", new String[0]);
128 
129     public void cacheResult(MBThread mbThread) {
130         EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
131             MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
132     }
133 
134     public void cacheResult(List<MBThread> mbThreads) {
135         for (MBThread mbThread : mbThreads) {
136             if (EntityCacheUtil.getResult(
137                         MBThreadModelImpl.ENTITY_CACHE_ENABLED,
138                         MBThreadImpl.class, mbThread.getPrimaryKey(), this) == null) {
139                 cacheResult(mbThread);
140             }
141         }
142     }
143 
144     public void clearCache() {
145         CacheRegistry.clear(MBThreadImpl.class.getName());
146         EntityCacheUtil.clearCache(MBThreadImpl.class.getName());
147         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
148         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
149     }
150 
151     public MBThread create(long threadId) {
152         MBThread mbThread = new MBThreadImpl();
153 
154         mbThread.setNew(true);
155         mbThread.setPrimaryKey(threadId);
156 
157         return mbThread;
158     }
159 
160     public MBThread remove(long threadId)
161         throws NoSuchThreadException, SystemException {
162         Session session = null;
163 
164         try {
165             session = openSession();
166 
167             MBThread mbThread = (MBThread)session.get(MBThreadImpl.class,
168                     new Long(threadId));
169 
170             if (mbThread == null) {
171                 if (_log.isWarnEnabled()) {
172                     _log.warn("No MBThread exists with the primary key " +
173                         threadId);
174                 }
175 
176                 throw new NoSuchThreadException(
177                     "No MBThread exists with the primary key " + threadId);
178             }
179 
180             return remove(mbThread);
181         }
182         catch (NoSuchThreadException nsee) {
183             throw nsee;
184         }
185         catch (Exception e) {
186             throw processException(e);
187         }
188         finally {
189             closeSession(session);
190         }
191     }
192 
193     public MBThread remove(MBThread mbThread) throws SystemException {
194         for (ModelListener<MBThread> listener : listeners) {
195             listener.onBeforeRemove(mbThread);
196         }
197 
198         mbThread = removeImpl(mbThread);
199 
200         for (ModelListener<MBThread> listener : listeners) {
201             listener.onAfterRemove(mbThread);
202         }
203 
204         return mbThread;
205     }
206 
207     protected MBThread removeImpl(MBThread mbThread) throws SystemException {
208         mbThread = toUnwrappedModel(mbThread);
209 
210         Session session = null;
211 
212         try {
213             session = openSession();
214 
215             if (mbThread.isCachedModel() || BatchSessionUtil.isEnabled()) {
216                 Object staleObject = session.get(MBThreadImpl.class,
217                         mbThread.getPrimaryKeyObj());
218 
219                 if (staleObject != null) {
220                     session.evict(staleObject);
221                 }
222             }
223 
224             session.delete(mbThread);
225 
226             session.flush();
227         }
228         catch (Exception e) {
229             throw processException(e);
230         }
231         finally {
232             closeSession(session);
233         }
234 
235         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
236 
237         EntityCacheUtil.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
238             MBThreadImpl.class, mbThread.getPrimaryKey());
239 
240         return mbThread;
241     }
242 
243     /**
244      * @deprecated Use {@link #update(MBThread, boolean merge)}.
245      */
246     public MBThread update(MBThread mbThread) throws SystemException {
247         if (_log.isWarnEnabled()) {
248             _log.warn(
249                 "Using the deprecated update(MBThread mbThread) method. Use update(MBThread mbThread, boolean merge) instead.");
250         }
251 
252         return update(mbThread, false);
253     }
254 
255     /**
256      * Add, update, or merge, the entity. This method also calls the model
257      * listeners to trigger the proper events associated with adding, deleting,
258      * or updating an entity.
259      *
260      * @param  mbThread the entity to add, update, or merge
261      * @param  merge boolean value for whether to merge the entity. The default
262      *         value is false. Setting merge to true is more expensive and
263      *         should only be true when mbThread is transient. See
264      *         LEP-5473 for a detailed discussion of this method.
265      * @return the entity that was added, updated, or merged
266      */
267     public MBThread update(MBThread mbThread, boolean merge)
268         throws SystemException {
269         boolean isNew = mbThread.isNew();
270 
271         for (ModelListener<MBThread> listener : listeners) {
272             if (isNew) {
273                 listener.onBeforeCreate(mbThread);
274             }
275             else {
276                 listener.onBeforeUpdate(mbThread);
277             }
278         }
279 
280         mbThread = updateImpl(mbThread, merge);
281 
282         for (ModelListener<MBThread> listener : listeners) {
283             if (isNew) {
284                 listener.onAfterCreate(mbThread);
285             }
286             else {
287                 listener.onAfterUpdate(mbThread);
288             }
289         }
290 
291         return mbThread;
292     }
293 
294     public MBThread updateImpl(
295         com.liferay.portlet.messageboards.model.MBThread mbThread, boolean merge)
296         throws SystemException {
297         mbThread = toUnwrappedModel(mbThread);
298 
299         Session session = null;
300 
301         try {
302             session = openSession();
303 
304             BatchSessionUtil.update(session, mbThread, merge);
305 
306             mbThread.setNew(false);
307         }
308         catch (Exception e) {
309             throw processException(e);
310         }
311         finally {
312             closeSession(session);
313         }
314 
315         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
316 
317         EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
318             MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
319 
320         return mbThread;
321     }
322 
323     protected MBThread toUnwrappedModel(MBThread mbThread) {
324         if (mbThread instanceof MBThreadImpl) {
325             return mbThread;
326         }
327 
328         MBThreadImpl mbThreadImpl = new MBThreadImpl();
329 
330         mbThreadImpl.setNew(mbThread.isNew());
331         mbThreadImpl.setPrimaryKey(mbThread.getPrimaryKey());
332 
333         mbThreadImpl.setThreadId(mbThread.getThreadId());
334         mbThreadImpl.setGroupId(mbThread.getGroupId());
335         mbThreadImpl.setCategoryId(mbThread.getCategoryId());
336         mbThreadImpl.setRootMessageId(mbThread.getRootMessageId());
337         mbThreadImpl.setMessageCount(mbThread.getMessageCount());
338         mbThreadImpl.setViewCount(mbThread.getViewCount());
339         mbThreadImpl.setLastPostByUserId(mbThread.getLastPostByUserId());
340         mbThreadImpl.setLastPostDate(mbThread.getLastPostDate());
341         mbThreadImpl.setPriority(mbThread.getPriority());
342 
343         return mbThreadImpl;
344     }
345 
346     public MBThread findByPrimaryKey(long threadId)
347         throws NoSuchThreadException, SystemException {
348         MBThread mbThread = fetchByPrimaryKey(threadId);
349 
350         if (mbThread == null) {
351             if (_log.isWarnEnabled()) {
352                 _log.warn("No MBThread exists with the primary key " +
353                     threadId);
354             }
355 
356             throw new NoSuchThreadException(
357                 "No MBThread exists with the primary key " + threadId);
358         }
359 
360         return mbThread;
361     }
362 
363     public MBThread fetchByPrimaryKey(long threadId) throws SystemException {
364         MBThread mbThread = (MBThread)EntityCacheUtil.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
365                 MBThreadImpl.class, threadId, this);
366 
367         if (mbThread == null) {
368             Session session = null;
369 
370             try {
371                 session = openSession();
372 
373                 mbThread = (MBThread)session.get(MBThreadImpl.class,
374                         new Long(threadId));
375             }
376             catch (Exception e) {
377                 throw processException(e);
378             }
379             finally {
380                 if (mbThread != null) {
381                     cacheResult(mbThread);
382                 }
383 
384                 closeSession(session);
385             }
386         }
387 
388         return mbThread;
389     }
390 
391     public List<MBThread> findByGroupId(long groupId) throws SystemException {
392         Object[] finderArgs = new Object[] { new Long(groupId) };
393 
394         List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
395                 finderArgs, this);
396 
397         if (list == null) {
398             Session session = null;
399 
400             try {
401                 session = openSession();
402 
403                 StringBuilder query = new StringBuilder();
404 
405                 query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
406 
407                 query.append("mbThread.groupId = ?");
408 
409                 query.append(" ");
410 
411                 query.append("ORDER BY ");
412 
413                 query.append("mbThread.priority DESC, ");
414                 query.append("mbThread.lastPostDate DESC");
415 
416                 Query q = session.createQuery(query.toString());
417 
418                 QueryPos qPos = QueryPos.getInstance(q);
419 
420                 qPos.add(groupId);
421 
422                 list = q.list();
423             }
424             catch (Exception e) {
425                 throw processException(e);
426             }
427             finally {
428                 if (list == null) {
429                     list = new ArrayList<MBThread>();
430                 }
431 
432                 cacheResult(list);
433 
434                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
435                     finderArgs, list);
436 
437                 closeSession(session);
438             }
439         }
440 
441         return list;
442     }
443 
444     public List<MBThread> findByGroupId(long groupId, int start, int end)
445         throws SystemException {
446         return findByGroupId(groupId, start, end, null);
447     }
448 
449     public List<MBThread> findByGroupId(long groupId, int start, int end,
450         OrderByComparator obc) throws SystemException {
451         Object[] finderArgs = new Object[] {
452                 new Long(groupId),
453                 
454                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
455             };
456 
457         List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
458                 finderArgs, this);
459 
460         if (list == null) {
461             Session session = null;
462 
463             try {
464                 session = openSession();
465 
466                 StringBuilder query = new StringBuilder();
467 
468                 query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
469 
470                 query.append("mbThread.groupId = ?");
471 
472                 query.append(" ");
473 
474                 if (obc != null) {
475                     query.append("ORDER BY ");
476 
477                     String[] orderByFields = obc.getOrderByFields();
478 
479                     for (int i = 0; i < orderByFields.length; i++) {
480                         query.append("mbThread.");
481                         query.append(orderByFields[i]);
482 
483                         if (obc.isAscending()) {
484                             query.append(" ASC");
485                         }
486                         else {
487                             query.append(" DESC");
488                         }
489 
490                         if ((i + 1) < orderByFields.length) {
491                             query.append(", ");
492                         }
493                     }
494                 }
495 
496                 else {
497                     query.append("ORDER BY ");
498 
499                     query.append("mbThread.priority DESC, ");
500                     query.append("mbThread.lastPostDate DESC");
501                 }
502 
503                 Query q = session.createQuery(query.toString());
504 
505                 QueryPos qPos = QueryPos.getInstance(q);
506 
507                 qPos.add(groupId);
508 
509                 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
510                         end);
511             }
512             catch (Exception e) {
513                 throw processException(e);
514             }
515             finally {
516                 if (list == null) {
517                     list = new ArrayList<MBThread>();
518                 }
519 
520                 cacheResult(list);
521 
522                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
523                     finderArgs, list);
524 
525                 closeSession(session);
526             }
527         }
528 
529         return list;
530     }
531 
532     public MBThread findByGroupId_First(long groupId, OrderByComparator obc)
533         throws NoSuchThreadException, SystemException {
534         List<MBThread> list = findByGroupId(groupId, 0, 1, obc);
535 
536         if (list.isEmpty()) {
537             StringBuilder msg = new StringBuilder();
538 
539             msg.append("No MBThread exists with the key {");
540 
541             msg.append("groupId=" + groupId);
542 
543             msg.append(StringPool.CLOSE_CURLY_BRACE);
544 
545             throw new NoSuchThreadException(msg.toString());
546         }
547         else {
548             return list.get(0);
549         }
550     }
551 
552     public MBThread findByGroupId_Last(long groupId, OrderByComparator obc)
553         throws NoSuchThreadException, SystemException {
554         int count = countByGroupId(groupId);
555 
556         List<MBThread> list = findByGroupId(groupId, count - 1, count, obc);
557 
558         if (list.isEmpty()) {
559             StringBuilder msg = new StringBuilder();
560 
561             msg.append("No MBThread exists with the key {");
562 
563             msg.append("groupId=" + groupId);
564 
565             msg.append(StringPool.CLOSE_CURLY_BRACE);
566 
567             throw new NoSuchThreadException(msg.toString());
568         }
569         else {
570             return list.get(0);
571         }
572     }
573 
574     public MBThread[] findByGroupId_PrevAndNext(long threadId, long groupId,
575         OrderByComparator obc) throws NoSuchThreadException, SystemException {
576         MBThread mbThread = findByPrimaryKey(threadId);
577 
578         int count = countByGroupId(groupId);
579 
580         Session session = null;
581 
582         try {
583             session = openSession();
584 
585             StringBuilder query = new StringBuilder();
586 
587             query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
588 
589             query.append("mbThread.groupId = ?");
590 
591             query.append(" ");
592 
593             if (obc != null) {
594                 query.append("ORDER BY ");
595 
596                 String[] orderByFields = obc.getOrderByFields();
597 
598                 for (int i = 0; i < orderByFields.length; i++) {
599                     query.append("mbThread.");
600                     query.append(orderByFields[i]);
601 
602                     if (obc.isAscending()) {
603                         query.append(" ASC");
604                     }
605                     else {
606                         query.append(" DESC");
607                     }
608 
609                     if ((i + 1) < orderByFields.length) {
610                         query.append(", ");
611                     }
612                 }
613             }
614 
615             else {
616                 query.append("ORDER BY ");
617 
618                 query.append("mbThread.priority DESC, ");
619                 query.append("mbThread.lastPostDate DESC");
620             }
621 
622             Query q = session.createQuery(query.toString());
623 
624             QueryPos qPos = QueryPos.getInstance(q);
625 
626             qPos.add(groupId);
627 
628             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, mbThread);
629 
630             MBThread[] array = new MBThreadImpl[3];
631 
632             array[0] = (MBThread)objArray[0];
633             array[1] = (MBThread)objArray[1];
634             array[2] = (MBThread)objArray[2];
635 
636             return array;
637         }
638         catch (Exception e) {
639             throw processException(e);
640         }
641         finally {
642             closeSession(session);
643         }
644     }
645 
646     public List<MBThread> findByCategoryId(long categoryId)
647         throws SystemException {
648         Object[] finderArgs = new Object[] { new Long(categoryId) };
649 
650         List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_CATEGORYID,
651                 finderArgs, this);
652 
653         if (list == null) {
654             Session session = null;
655 
656             try {
657                 session = openSession();
658 
659                 StringBuilder query = new StringBuilder();
660 
661                 query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
662 
663                 query.append("mbThread.categoryId = ?");
664 
665                 query.append(" ");
666 
667                 query.append("ORDER BY ");
668 
669                 query.append("mbThread.priority DESC, ");
670                 query.append("mbThread.lastPostDate DESC");
671 
672                 Query q = session.createQuery(query.toString());
673 
674                 QueryPos qPos = QueryPos.getInstance(q);
675 
676                 qPos.add(categoryId);
677 
678                 list = q.list();
679             }
680             catch (Exception e) {
681                 throw processException(e);
682             }
683             finally {
684                 if (list == null) {
685                     list = new ArrayList<MBThread>();
686                 }
687 
688                 cacheResult(list);
689 
690                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_CATEGORYID,
691                     finderArgs, list);
692 
693                 closeSession(session);
694             }
695         }
696 
697         return list;
698     }
699 
700     public List<MBThread> findByCategoryId(long categoryId, int start, int end)
701         throws SystemException {
702         return findByCategoryId(categoryId, start, end, null);
703     }
704 
705     public List<MBThread> findByCategoryId(long categoryId, int start, int end,
706         OrderByComparator obc) throws SystemException {
707         Object[] finderArgs = new Object[] {
708                 new Long(categoryId),
709                 
710                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
711             };
712 
713         List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_CATEGORYID,
714                 finderArgs, this);
715 
716         if (list == null) {
717             Session session = null;
718 
719             try {
720                 session = openSession();
721 
722                 StringBuilder query = new StringBuilder();
723 
724                 query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
725 
726                 query.append("mbThread.categoryId = ?");
727 
728                 query.append(" ");
729 
730                 if (obc != null) {
731                     query.append("ORDER BY ");
732 
733                     String[] orderByFields = obc.getOrderByFields();
734 
735                     for (int i = 0; i < orderByFields.length; i++) {
736                         query.append("mbThread.");
737                         query.append(orderByFields[i]);
738 
739                         if (obc.isAscending()) {
740                             query.append(" ASC");
741                         }
742                         else {
743                             query.append(" DESC");
744                         }
745 
746                         if ((i + 1) < orderByFields.length) {
747                             query.append(", ");
748                         }
749                     }
750                 }
751 
752                 else {
753                     query.append("ORDER BY ");
754 
755                     query.append("mbThread.priority DESC, ");
756                     query.append("mbThread.lastPostDate DESC");
757                 }
758 
759                 Query q = session.createQuery(query.toString());
760 
761                 QueryPos qPos = QueryPos.getInstance(q);
762 
763                 qPos.add(categoryId);
764 
765                 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
766                         end);
767             }
768             catch (Exception e) {
769                 throw processException(e);
770             }
771             finally {
772                 if (list == null) {
773                     list = new ArrayList<MBThread>();
774                 }
775 
776                 cacheResult(list);
777 
778                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_CATEGORYID,
779                     finderArgs, list);
780 
781                 closeSession(session);
782             }
783         }
784 
785         return list;
786     }
787 
788     public MBThread findByCategoryId_First(long categoryId,
789         OrderByComparator obc) throws NoSuchThreadException, SystemException {
790         List<MBThread> list = findByCategoryId(categoryId, 0, 1, obc);
791 
792         if (list.isEmpty()) {
793             StringBuilder msg = new StringBuilder();
794 
795             msg.append("No MBThread exists with the key {");
796 
797             msg.append("categoryId=" + categoryId);
798 
799             msg.append(StringPool.CLOSE_CURLY_BRACE);
800 
801             throw new NoSuchThreadException(msg.toString());
802         }
803         else {
804             return list.get(0);
805         }
806     }
807 
808     public MBThread findByCategoryId_Last(long categoryId, OrderByComparator obc)
809         throws NoSuchThreadException, SystemException {
810         int count = countByCategoryId(categoryId);
811 
812         List<MBThread> list = findByCategoryId(categoryId, count - 1, count, obc);
813 
814         if (list.isEmpty()) {
815             StringBuilder msg = new StringBuilder();
816 
817             msg.append("No MBThread exists with the key {");
818 
819             msg.append("categoryId=" + categoryId);
820 
821             msg.append(StringPool.CLOSE_CURLY_BRACE);
822 
823             throw new NoSuchThreadException(msg.toString());
824         }
825         else {
826             return list.get(0);
827         }
828     }
829 
830     public MBThread[] findByCategoryId_PrevAndNext(long threadId,
831         long categoryId, OrderByComparator obc)
832         throws NoSuchThreadException, SystemException {
833         MBThread mbThread = findByPrimaryKey(threadId);
834 
835         int count = countByCategoryId(categoryId);
836 
837         Session session = null;
838 
839         try {
840             session = openSession();
841 
842             StringBuilder query = new StringBuilder();
843 
844             query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
845 
846             query.append("mbThread.categoryId = ?");
847 
848             query.append(" ");
849 
850             if (obc != null) {
851                 query.append("ORDER BY ");
852 
853                 String[] orderByFields = obc.getOrderByFields();
854 
855                 for (int i = 0; i < orderByFields.length; i++) {
856                     query.append("mbThread.");
857                     query.append(orderByFields[i]);
858 
859                     if (obc.isAscending()) {
860                         query.append(" ASC");
861                     }
862                     else {
863                         query.append(" DESC");
864                     }
865 
866                     if ((i + 1) < orderByFields.length) {
867                         query.append(", ");
868                     }
869                 }
870             }
871 
872             else {
873                 query.append("ORDER BY ");
874 
875                 query.append("mbThread.priority DESC, ");
876                 query.append("mbThread.lastPostDate DESC");
877             }
878 
879             Query q = session.createQuery(query.toString());
880 
881             QueryPos qPos = QueryPos.getInstance(q);
882 
883             qPos.add(categoryId);
884 
885             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, mbThread);
886 
887             MBThread[] array = new MBThreadImpl[3];
888 
889             array[0] = (MBThread)objArray[0];
890             array[1] = (MBThread)objArray[1];
891             array[2] = (MBThread)objArray[2];
892 
893             return array;
894         }
895         catch (Exception e) {
896             throw processException(e);
897         }
898         finally {
899             closeSession(session);
900         }
901     }
902 
903     public List<MBThread> findByC_L(long categoryId, Date lastPostDate)
904         throws SystemException {
905         Object[] finderArgs = new Object[] { new Long(categoryId), lastPostDate };
906 
907         List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_L,
908                 finderArgs, this);
909 
910         if (list == null) {
911             Session session = null;
912 
913             try {
914                 session = openSession();
915 
916                 StringBuilder query = new StringBuilder();
917 
918                 query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
919 
920                 query.append("mbThread.categoryId = ?");
921 
922                 query.append(" AND ");
923 
924                 if (lastPostDate == null) {
925                     query.append("mbThread.lastPostDate IS NULL");
926                 }
927                 else {
928                     query.append("mbThread.lastPostDate = ?");
929                 }
930 
931                 query.append(" ");
932 
933                 query.append("ORDER BY ");
934 
935                 query.append("mbThread.priority DESC, ");
936                 query.append("mbThread.lastPostDate DESC");
937 
938                 Query q = session.createQuery(query.toString());
939 
940                 QueryPos qPos = QueryPos.getInstance(q);
941 
942                 qPos.add(categoryId);
943 
944                 if (lastPostDate != null) {
945                     qPos.add(CalendarUtil.getTimestamp(lastPostDate));
946                 }
947 
948                 list = q.list();
949             }
950             catch (Exception e) {
951                 throw processException(e);
952             }
953             finally {
954                 if (list == null) {
955                     list = new ArrayList<MBThread>();
956                 }
957 
958                 cacheResult(list);
959 
960                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_L, finderArgs,
961                     list);
962 
963                 closeSession(session);
964             }
965         }
966 
967         return list;
968     }
969 
970     public List<MBThread> findByC_L(long categoryId, Date lastPostDate,
971         int start, int end) throws SystemException {
972         return findByC_L(categoryId, lastPostDate, start, end, null);
973     }
974 
975     public List<MBThread> findByC_L(long categoryId, Date lastPostDate,
976         int start, int end, OrderByComparator obc) throws SystemException {
977         Object[] finderArgs = new Object[] {
978                 new Long(categoryId),
979                 
980                 lastPostDate,
981                 
982                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
983             };
984 
985         List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_L,
986                 finderArgs, this);
987 
988         if (list == null) {
989             Session session = null;
990 
991             try {
992                 session = openSession();
993 
994                 StringBuilder query = new StringBuilder();
995 
996                 query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
997 
998                 query.append("mbThread.categoryId = ?");
999 
1000                query.append(" AND ");
1001
1002                if (lastPostDate == null) {
1003                    query.append("mbThread.lastPostDate IS NULL");
1004                }
1005                else {
1006                    query.append("mbThread.lastPostDate = ?");
1007                }
1008
1009                query.append(" ");
1010
1011                if (obc != null) {
1012                    query.append("ORDER BY ");
1013
1014                    String[] orderByFields = obc.getOrderByFields();
1015
1016                    for (int i = 0; i < orderByFields.length; i++) {
1017                        query.append("mbThread.");
1018                        query.append(orderByFields[i]);
1019
1020                        if (obc.isAscending()) {
1021                            query.append(" ASC");
1022                        }
1023                        else {
1024                            query.append(" DESC");
1025                        }
1026
1027                        if ((i + 1) < orderByFields.length) {
1028                            query.append(", ");
1029                        }
1030                    }
1031                }
1032
1033                else {
1034                    query.append("ORDER BY ");
1035
1036                    query.append("mbThread.priority DESC, ");
1037                    query.append("mbThread.lastPostDate DESC");
1038                }
1039
1040                Query q = session.createQuery(query.toString());
1041
1042                QueryPos qPos = QueryPos.getInstance(q);
1043
1044                qPos.add(categoryId);
1045
1046                if (lastPostDate != null) {
1047                    qPos.add(CalendarUtil.getTimestamp(lastPostDate));
1048                }
1049
1050                list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
1051                        end);
1052            }
1053            catch (Exception e) {
1054                throw processException(e);
1055            }
1056            finally {
1057                if (list == null) {
1058                    list = new ArrayList<MBThread>();
1059                }
1060
1061                cacheResult(list);
1062
1063                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_L,
1064                    finderArgs, list);
1065
1066                closeSession(session);
1067            }
1068        }
1069
1070        return list;
1071    }
1072
1073    public MBThread findByC_L_First(long categoryId, Date lastPostDate,
1074        OrderByComparator obc) throws NoSuchThreadException, SystemException {
1075        List<MBThread> list = findByC_L(categoryId, lastPostDate, 0, 1, obc);
1076
1077        if (list.isEmpty()) {
1078            StringBuilder msg = new StringBuilder();
1079
1080            msg.append("No MBThread exists with the key {");
1081
1082            msg.append("categoryId=" + categoryId);
1083
1084            msg.append(", ");
1085            msg.append("lastPostDate=" + lastPostDate);
1086
1087            msg.append(StringPool.CLOSE_CURLY_BRACE);
1088
1089            throw new NoSuchThreadException(msg.toString());
1090        }
1091        else {
1092            return list.get(0);
1093        }
1094    }
1095
1096    public MBThread findByC_L_Last(long categoryId, Date lastPostDate,
1097        OrderByComparator obc) throws NoSuchThreadException, SystemException {
1098        int count = countByC_L(categoryId, lastPostDate);
1099
1100        List<MBThread> list = findByC_L(categoryId, lastPostDate, count - 1,
1101                count, obc);
1102
1103        if (list.isEmpty()) {
1104            StringBuilder msg = new StringBuilder();
1105
1106            msg.append("No MBThread exists with the key {");
1107
1108            msg.append("categoryId=" + categoryId);
1109
1110            msg.append(", ");
1111            msg.append("lastPostDate=" + lastPostDate);
1112
1113            msg.append(StringPool.CLOSE_CURLY_BRACE);
1114
1115            throw new NoSuchThreadException(msg.toString());
1116        }
1117        else {
1118            return list.get(0);
1119        }
1120    }
1121
1122    public MBThread[] findByC_L_PrevAndNext(long threadId, long categoryId,
1123        Date lastPostDate, OrderByComparator obc)
1124        throws NoSuchThreadException, SystemException {
1125        MBThread mbThread = findByPrimaryKey(threadId);
1126
1127        int count = countByC_L(categoryId, lastPostDate);
1128
1129        Session session = null;
1130
1131        try {
1132            session = openSession();
1133
1134            StringBuilder query = new StringBuilder();
1135
1136            query.append("SELECT mbThread FROM MBThread mbThread WHERE ");
1137
1138            query.append("mbThread.categoryId = ?");
1139
1140            query.append(" AND ");
1141
1142            if (lastPostDate == null) {
1143                query.append("mbThread.lastPostDate IS NULL");
1144            }
1145            else {
1146                query.append("mbThread.lastPostDate = ?");
1147            }
1148
1149            query.append(" ");
1150
1151            if (obc != null) {
1152                query.append("ORDER BY ");
1153
1154                String[] orderByFields = obc.getOrderByFields();
1155
1156                for (int i = 0; i < orderByFields.length; i++) {
1157                    query.append("mbThread.");
1158                    query.append(orderByFields[i]);
1159
1160                    if (obc.isAscending()) {
1161                        query.append(" ASC");
1162                    }
1163                    else {
1164                        query.append(" DESC");
1165                    }
1166
1167                    if ((i + 1) < orderByFields.length) {
1168                        query.append(", ");
1169                    }
1170                }
1171            }
1172
1173            else {
1174                query.append("ORDER BY ");
1175
1176                query.append("mbThread.priority DESC, ");
1177                query.append("mbThread.lastPostDate DESC");
1178            }
1179
1180            Query q = session.createQuery(query.toString());
1181
1182            QueryPos qPos = QueryPos.getInstance(q);
1183
1184            qPos.add(categoryId);
1185
1186            if (lastPostDate != null) {
1187                qPos.add(CalendarUtil.getTimestamp(lastPostDate));
1188            }
1189
1190            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, mbThread);
1191
1192            MBThread[] array = new MBThreadImpl[3];
1193
1194            array[0] = (MBThread)objArray[0];
1195            array[1] = (MBThread)objArray[1];
1196            array[2] = (MBThread)objArray[2];
1197
1198            return array;
1199        }
1200        catch (Exception e) {
1201            throw processException(e);
1202        }
1203        finally {
1204            closeSession(session);
1205        }
1206    }
1207
1208    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1209        throws SystemException {
1210        Session session = null;
1211
1212        try {
1213            session = openSession();
1214
1215            dynamicQuery.compile(session);
1216
1217            return dynamicQuery.list();
1218        }
1219        catch (Exception e) {
1220            throw processException(e);
1221        }
1222        finally {
1223            closeSession(session);
1224        }
1225    }
1226
1227    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1228        int start, int end) throws SystemException {
1229        Session session = null;
1230
1231        try {
1232            session = openSession();
1233
1234            dynamicQuery.setLimit(start, end);
1235
1236            dynamicQuery.compile(session);
1237
1238            return dynamicQuery.list();
1239        }
1240        catch (Exception e) {
1241            throw processException(e);
1242        }
1243        finally {
1244            closeSession(session);
1245        }
1246    }
1247
1248    public List<MBThread> findAll() throws SystemException {
1249        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1250    }
1251
1252    public List<MBThread> findAll(int start, int end) throws SystemException {
1253        return findAll(start, end, null);
1254    }
1255
1256    public List<MBThread> findAll(int start, int end, OrderByComparator obc)
1257        throws SystemException {
1258        Object[] finderArgs = new Object[] {
1259                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1260            };
1261
1262        List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1263                finderArgs, this);
1264
1265        if (list == null) {
1266            Session session = null;
1267
1268            try {
1269                session = openSession();
1270
1271                StringBuilder query = new StringBuilder();
1272
1273                query.append("SELECT mbThread FROM MBThread mbThread ");
1274
1275                if (obc != null) {
1276                    query.append("ORDER BY ");
1277
1278                    String[] orderByFields = obc.getOrderByFields();
1279
1280                    for (int i = 0; i < orderByFields.length; i++) {
1281                        query.append("mbThread.");
1282                        query.append(orderByFields[i]);
1283
1284                        if (obc.isAscending()) {
1285                            query.append(" ASC");
1286                        }
1287                        else {
1288                            query.append(" DESC");
1289                        }
1290
1291                        if ((i + 1) < orderByFields.length) {
1292                            query.append(", ");
1293                        }
1294                    }
1295                }
1296
1297                else {
1298                    query.append("ORDER BY ");
1299
1300                    query.append("mbThread.priority DESC, ");
1301                    query.append("mbThread.lastPostDate DESC");
1302                }
1303
1304                Query q = session.createQuery(query.toString());
1305
1306                if (obc == null) {
1307                    list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1308                            start, end, false);
1309
1310                    Collections.sort(list);
1311                }
1312                else {
1313                    list = (List<MBThread>)QueryUtil.list(q, getDialect(),
1314                            start, end);
1315                }
1316            }
1317            catch (Exception e) {
1318                throw processException(e);
1319            }
1320            finally {
1321                if (list == null) {
1322                    list = new ArrayList<MBThread>();
1323                }
1324
1325                cacheResult(list);
1326
1327                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1328
1329                closeSession(session);
1330            }
1331        }
1332
1333        return list;
1334    }
1335
1336    public void removeByGroupId(long groupId) throws SystemException {
1337        for (MBThread mbThread : findByGroupId(groupId)) {
1338            remove(mbThread);
1339        }
1340    }
1341
1342    public void removeByCategoryId(long categoryId) throws SystemException {
1343        for (MBThread mbThread : findByCategoryId(categoryId)) {
1344            remove(mbThread);
1345        }
1346    }
1347
1348    public void removeByC_L(long categoryId, Date lastPostDate)
1349        throws SystemException {
1350        for (MBThread mbThread : findByC_L(categoryId, lastPostDate)) {
1351            remove(mbThread);
1352        }
1353    }
1354
1355    public void removeAll() throws SystemException {
1356        for (MBThread mbThread : findAll()) {
1357            remove(mbThread);
1358        }
1359    }
1360
1361    public int countByGroupId(long groupId) throws SystemException {
1362        Object[] finderArgs = new Object[] { new Long(groupId) };
1363
1364        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1365                finderArgs, this);
1366
1367        if (count == null) {
1368            Session session = null;
1369
1370            try {
1371                session = openSession();
1372
1373                StringBuilder query = new StringBuilder();
1374
1375                query.append("SELECT COUNT(mbThread) ");
1376                query.append("FROM MBThread mbThread WHERE ");
1377
1378                query.append("mbThread.groupId = ?");
1379
1380                query.append(" ");
1381
1382                Query q = session.createQuery(query.toString());
1383
1384                QueryPos qPos = QueryPos.getInstance(q);
1385
1386                qPos.add(groupId);
1387
1388                count = (Long)q.uniqueResult();
1389            }
1390            catch (Exception e) {
1391                throw processException(e);
1392            }
1393            finally {
1394                if (count == null) {
1395                    count = Long.valueOf(0);
1396                }
1397
1398                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1399                    finderArgs, count);
1400
1401                closeSession(session);
1402            }
1403        }
1404
1405        return count.intValue();
1406    }
1407
1408    public int countByCategoryId(long categoryId) throws SystemException {
1409        Object[] finderArgs = new Object[] { new Long(categoryId) };
1410
1411        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1412                finderArgs, this);
1413
1414        if (count == null) {
1415            Session session = null;
1416
1417            try {
1418                session = openSession();
1419
1420                StringBuilder query = new StringBuilder();
1421
1422                query.append("SELECT COUNT(mbThread) ");
1423                query.append("FROM MBThread mbThread WHERE ");
1424
1425                query.append("mbThread.categoryId = ?");
1426
1427                query.append(" ");
1428
1429                Query q = session.createQuery(query.toString());
1430
1431                QueryPos qPos = QueryPos.getInstance(q);
1432
1433                qPos.add(categoryId);
1434
1435                count = (Long)q.uniqueResult();
1436            }
1437            catch (Exception e) {
1438                throw processException(e);
1439            }
1440            finally {
1441                if (count == null) {
1442                    count = Long.valueOf(0);
1443                }
1444
1445                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1446                    finderArgs, count);
1447
1448                closeSession(session);
1449            }
1450        }
1451
1452        return count.intValue();
1453    }
1454
1455    public int countByC_L(long categoryId, Date lastPostDate)
1456        throws SystemException {
1457        Object[] finderArgs = new Object[] { new Long(categoryId), lastPostDate };
1458
1459        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_L,
1460                finderArgs, this);
1461
1462        if (count == null) {
1463            Session session = null;
1464
1465            try {
1466                session = openSession();
1467
1468                StringBuilder query = new StringBuilder();
1469
1470                query.append("SELECT COUNT(mbThread) ");
1471                query.append("FROM MBThread mbThread WHERE ");
1472
1473                query.append("mbThread.categoryId = ?");
1474
1475                query.append(" AND ");
1476
1477                if (lastPostDate == null) {
1478                    query.append("mbThread.lastPostDate IS NULL");
1479                }
1480                else {
1481                    query.append("mbThread.lastPostDate = ?");
1482                }
1483
1484                query.append(" ");
1485
1486                Query q = session.createQuery(query.toString());
1487
1488                QueryPos qPos = QueryPos.getInstance(q);
1489
1490                qPos.add(categoryId);
1491
1492                if (lastPostDate != null) {
1493                    qPos.add(CalendarUtil.getTimestamp(lastPostDate));
1494                }
1495
1496                count = (Long)q.uniqueResult();
1497            }
1498            catch (Exception e) {
1499                throw processException(e);
1500            }
1501            finally {
1502                if (count == null) {
1503                    count = Long.valueOf(0);
1504                }
1505
1506                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L, finderArgs,
1507                    count);
1508
1509                closeSession(session);
1510            }
1511        }
1512
1513        return count.intValue();
1514    }
1515
1516    public int countAll() throws SystemException {
1517        Object[] finderArgs = new Object[0];
1518
1519        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1520                finderArgs, this);
1521
1522        if (count == null) {
1523            Session session = null;
1524
1525            try {
1526                session = openSession();
1527
1528                Query q = session.createQuery(
1529                        "SELECT COUNT(mbThread) FROM MBThread mbThread");
1530
1531                count = (Long)q.uniqueResult();
1532            }
1533            catch (Exception e) {
1534                throw processException(e);
1535            }
1536            finally {
1537                if (count == null) {
1538                    count = Long.valueOf(0);
1539                }
1540
1541                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1542                    count);
1543
1544                closeSession(session);
1545            }
1546        }
1547
1548        return count.intValue();
1549    }
1550
1551    public void afterPropertiesSet() {
1552        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1553                    com.liferay.portal.util.PropsUtil.get(
1554                        "value.object.listener.com.liferay.portlet.messageboards.model.MBThread")));
1555
1556        if (listenerClassNames.length > 0) {
1557            try {
1558                List<ModelListener<MBThread>> listenersList = new ArrayList<ModelListener<MBThread>>();
1559
1560                for (String listenerClassName : listenerClassNames) {
1561                    listenersList.add((ModelListener<MBThread>)Class.forName(
1562                            listenerClassName).newInstance());
1563                }
1564
1565                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1566            }
1567            catch (Exception e) {
1568                _log.error(e);
1569            }
1570        }
1571    }
1572
1573    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBBanPersistence.impl")
1574    protected com.liferay.portlet.messageboards.service.persistence.MBBanPersistence mbBanPersistence;
1575    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence.impl")
1576    protected com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence mbCategoryPersistence;
1577    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence.impl")
1578    protected com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence mbDiscussionPersistence;
1579    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMailingListPersistence.impl")
1580    protected com.liferay.portlet.messageboards.service.persistence.MBMailingListPersistence mbMailingListPersistence;
1581    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence.impl")
1582    protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
1583    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence.impl")
1584    protected com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence mbMessageFlagPersistence;
1585    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence.impl")
1586    protected com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence mbStatsUserPersistence;
1587    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence.impl")
1588    protected com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence mbThreadPersistence;
1589    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1590    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1591    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1592    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1593    @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence.impl")
1594    protected com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence ratingsStatsPersistence;
1595    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence.impl")
1596    protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
1597    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
1598    protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
1599    private static Log _log = LogFactoryUtil.getLog(MBThreadPersistenceImpl.class);
1600}