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