001
014
015 package com.liferay.portlet.messageboards.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.ArrayUtil;
032 import com.liferay.portal.kernel.util.CalendarUtil;
033 import com.liferay.portal.kernel.util.GetterUtil;
034 import com.liferay.portal.kernel.util.InstanceFactory;
035 import com.liferay.portal.kernel.util.OrderByComparator;
036 import com.liferay.portal.kernel.util.StringBundler;
037 import com.liferay.portal.kernel.util.StringPool;
038 import com.liferay.portal.kernel.util.StringUtil;
039 import com.liferay.portal.kernel.util.Validator;
040 import com.liferay.portal.model.CacheModel;
041 import com.liferay.portal.model.ModelListener;
042 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043 import com.liferay.portal.service.persistence.BatchSessionUtil;
044 import com.liferay.portal.service.persistence.LockPersistence;
045 import com.liferay.portal.service.persistence.ResourcePersistence;
046 import com.liferay.portal.service.persistence.SubscriptionPersistence;
047 import com.liferay.portal.service.persistence.UserPersistence;
048 import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
049 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050
051 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
052 import com.liferay.portlet.messageboards.NoSuchThreadException;
053 import com.liferay.portlet.messageboards.model.MBThread;
054 import com.liferay.portlet.messageboards.model.impl.MBThreadImpl;
055 import com.liferay.portlet.messageboards.model.impl.MBThreadModelImpl;
056 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
057 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
058
059 import java.io.Serializable;
060
061 import java.util.ArrayList;
062 import java.util.Collections;
063 import java.util.Date;
064 import java.util.List;
065
066
078 public class MBThreadPersistenceImpl extends BasePersistenceImpl<MBThread>
079 implements MBThreadPersistence {
080
085 public static final String FINDER_CLASS_NAME_ENTITY = MBThreadImpl.class.getName();
086 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087 ".List1";
088 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089 ".List2";
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
091 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
092 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
093 new String[] {
094 Long.class.getName(),
095
096 "java.lang.Integer", "java.lang.Integer",
097 "com.liferay.portal.kernel.util.OrderByComparator"
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
100 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
101 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
103 new String[] { Long.class.getName() },
104 MBThreadModelImpl.GROUPID_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
106 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
108 new String[] { Long.class.getName() });
109 public static final FinderPath FINDER_PATH_FETCH_BY_ROOTMESSAGEID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
110 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
111 FINDER_CLASS_NAME_ENTITY, "fetchByRootMessageId",
112 new String[] { Long.class.getName() },
113 MBThreadModelImpl.ROOTMESSAGEID_COLUMN_BITMASK);
114 public static final FinderPath FINDER_PATH_COUNT_BY_ROOTMESSAGEID = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
115 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRootMessageId",
117 new String[] { Long.class.getName() });
118 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
119 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
120 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C",
121 new String[] {
122 Long.class.getName(), Long.class.getName(),
123
124 "java.lang.Integer", "java.lang.Integer",
125 "com.liferay.portal.kernel.util.OrderByComparator"
126 });
127 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
128 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
129 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C",
130 new String[] { Long.class.getName(), Long.class.getName() },
131 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
132 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK);
133 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
134 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
136 new String[] { Long.class.getName(), Long.class.getName() });
137 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
138 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
139 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C",
140 new String[] { Long.class.getName(), Long.class.getName() });
141 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
142 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
143 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC",
144 new String[] {
145 Long.class.getName(), Long.class.getName(),
146
147 "java.lang.Integer", "java.lang.Integer",
148 "com.liferay.portal.kernel.util.OrderByComparator"
149 });
150 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
151 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
152 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotC",
153 new String[] { Long.class.getName(), Long.class.getName() });
154 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
155 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
156 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
157 new String[] {
158 Long.class.getName(), Integer.class.getName(),
159
160 "java.lang.Integer", "java.lang.Integer",
161 "com.liferay.portal.kernel.util.OrderByComparator"
162 });
163 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
164 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
165 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
166 new String[] { Long.class.getName(), Integer.class.getName() },
167 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
168 MBThreadModelImpl.STATUS_COLUMN_BITMASK);
169 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
170 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
171 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
172 new String[] { Long.class.getName(), Integer.class.getName() });
173 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
174 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
175 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
176 new String[] {
177 Long.class.getName(), Double.class.getName(),
178
179 "java.lang.Integer", "java.lang.Integer",
180 "com.liferay.portal.kernel.util.OrderByComparator"
181 });
182 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
183 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
184 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
185 new String[] { Long.class.getName(), Double.class.getName() },
186 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
187 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK);
188 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
189 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
190 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
191 new String[] { Long.class.getName(), Double.class.getName() });
192 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
193 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
194 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByL_P",
195 new String[] {
196 Date.class.getName(), Double.class.getName(),
197
198 "java.lang.Integer", "java.lang.Integer",
199 "com.liferay.portal.kernel.util.OrderByComparator"
200 });
201 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
202 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
203 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P",
204 new String[] { Date.class.getName(), Double.class.getName() },
205 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK |
206 MBThreadModelImpl.PRIORITY_COLUMN_BITMASK);
207 public static final FinderPath FINDER_PATH_COUNT_BY_L_P = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
208 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
209 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P",
210 new String[] { Date.class.getName(), Double.class.getName() });
211 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
212 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
213 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_L",
214 new String[] {
215 Long.class.getName(), Long.class.getName(), Date.class.getName(),
216
217 "java.lang.Integer", "java.lang.Integer",
218 "com.liferay.portal.kernel.util.OrderByComparator"
219 });
220 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
221 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
222 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
223 new String[] {
224 Long.class.getName(), Long.class.getName(), Date.class.getName()
225 },
226 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
227 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
228 MBThreadModelImpl.LASTPOSTDATE_COLUMN_BITMASK);
229 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
230 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
231 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
232 new String[] {
233 Long.class.getName(), Long.class.getName(), Date.class.getName()
234 });
235 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
236 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
237 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_S",
238 new String[] {
239 Long.class.getName(), Long.class.getName(),
240 Integer.class.getName(),
241
242 "java.lang.Integer", "java.lang.Integer",
243 "com.liferay.portal.kernel.util.OrderByComparator"
244 });
245 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
246 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
247 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_S",
248 new String[] {
249 Long.class.getName(), Long.class.getName(),
250 Integer.class.getName()
251 },
252 MBThreadModelImpl.GROUPID_COLUMN_BITMASK |
253 MBThreadModelImpl.CATEGORYID_COLUMN_BITMASK |
254 MBThreadModelImpl.STATUS_COLUMN_BITMASK);
255 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
256 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
257 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
258 new String[] {
259 Long.class.getName(), Long.class.getName(),
260 Integer.class.getName()
261 });
262 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
263 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
264 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C_S",
265 new String[] {
266 Long.class.getName(), Long.class.getName(),
267 Integer.class.getName()
268 });
269 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
270 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
271 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotC_S",
272 new String[] {
273 Long.class.getName(), Long.class.getName(),
274 Integer.class.getName(),
275
276 "java.lang.Integer", "java.lang.Integer",
277 "com.liferay.portal.kernel.util.OrderByComparator"
278 });
279 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S =
280 new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
281 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
282 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotC_S",
283 new String[] {
284 Long.class.getName(), Long.class.getName(),
285 Integer.class.getName()
286 });
287 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
288 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
289 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
290 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
291 MBThreadModelImpl.FINDER_CACHE_ENABLED, MBThreadImpl.class,
292 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
293 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
294 MBThreadModelImpl.FINDER_CACHE_ENABLED, Long.class,
295 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
296
297
302 public void cacheResult(MBThread mbThread) {
303 EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
304 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
305
306 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
307 new Object[] { Long.valueOf(mbThread.getRootMessageId()) }, mbThread);
308
309 mbThread.resetOriginalValues();
310 }
311
312
317 public void cacheResult(List<MBThread> mbThreads) {
318 for (MBThread mbThread : mbThreads) {
319 if (EntityCacheUtil.getResult(
320 MBThreadModelImpl.ENTITY_CACHE_ENABLED,
321 MBThreadImpl.class, mbThread.getPrimaryKey()) == null) {
322 cacheResult(mbThread);
323 }
324 else {
325 mbThread.resetOriginalValues();
326 }
327 }
328 }
329
330
337 @Override
338 public void clearCache() {
339 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
340 CacheRegistryUtil.clear(MBThreadImpl.class.getName());
341 }
342
343 EntityCacheUtil.clearCache(MBThreadImpl.class.getName());
344
345 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
346 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
347 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
348 }
349
350
357 @Override
358 public void clearCache(MBThread mbThread) {
359 EntityCacheUtil.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
360 MBThreadImpl.class, mbThread.getPrimaryKey());
361
362 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
363 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
364
365 clearUniqueFindersCache(mbThread);
366 }
367
368 @Override
369 public void clearCache(List<MBThread> mbThreads) {
370 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
372
373 for (MBThread mbThread : mbThreads) {
374 EntityCacheUtil.removeResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
375 MBThreadImpl.class, mbThread.getPrimaryKey());
376
377 clearUniqueFindersCache(mbThread);
378 }
379 }
380
381 protected void clearUniqueFindersCache(MBThread mbThread) {
382 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
383 new Object[] { Long.valueOf(mbThread.getRootMessageId()) });
384 }
385
386
392 public MBThread create(long threadId) {
393 MBThread mbThread = new MBThreadImpl();
394
395 mbThread.setNew(true);
396 mbThread.setPrimaryKey(threadId);
397
398 return mbThread;
399 }
400
401
409 public MBThread remove(long threadId)
410 throws NoSuchThreadException, SystemException {
411 return remove(Long.valueOf(threadId));
412 }
413
414
422 @Override
423 public MBThread remove(Serializable primaryKey)
424 throws NoSuchThreadException, SystemException {
425 Session session = null;
426
427 try {
428 session = openSession();
429
430 MBThread mbThread = (MBThread)session.get(MBThreadImpl.class,
431 primaryKey);
432
433 if (mbThread == null) {
434 if (_log.isWarnEnabled()) {
435 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
436 }
437
438 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
439 primaryKey);
440 }
441
442 return remove(mbThread);
443 }
444 catch (NoSuchThreadException nsee) {
445 throw nsee;
446 }
447 catch (Exception e) {
448 throw processException(e);
449 }
450 finally {
451 closeSession(session);
452 }
453 }
454
455 @Override
456 protected MBThread removeImpl(MBThread mbThread) throws SystemException {
457 mbThread = toUnwrappedModel(mbThread);
458
459 Session session = null;
460
461 try {
462 session = openSession();
463
464 BatchSessionUtil.delete(session, mbThread);
465 }
466 catch (Exception e) {
467 throw processException(e);
468 }
469 finally {
470 closeSession(session);
471 }
472
473 clearCache(mbThread);
474
475 return mbThread;
476 }
477
478 @Override
479 public MBThread updateImpl(
480 com.liferay.portlet.messageboards.model.MBThread mbThread, boolean merge)
481 throws SystemException {
482 mbThread = toUnwrappedModel(mbThread);
483
484 boolean isNew = mbThread.isNew();
485
486 MBThreadModelImpl mbThreadModelImpl = (MBThreadModelImpl)mbThread;
487
488 Session session = null;
489
490 try {
491 session = openSession();
492
493 BatchSessionUtil.update(session, mbThread, merge);
494
495 mbThread.setNew(false);
496 }
497 catch (Exception e) {
498 throw processException(e);
499 }
500 finally {
501 closeSession(session);
502 }
503
504 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
505
506 if (isNew || !MBThreadModelImpl.COLUMN_BITMASK_ENABLED) {
507 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
508 }
509
510 else {
511 if ((mbThreadModelImpl.getColumnBitmask() &
512 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
513 Object[] args = new Object[] {
514 Long.valueOf(mbThreadModelImpl.getOriginalGroupId())
515 };
516
517 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
518 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
519 args);
520
521 args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()) };
522
523 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
524 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
525 args);
526 }
527
528 if ((mbThreadModelImpl.getColumnBitmask() &
529 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) {
530 Object[] args = new Object[] {
531 Long.valueOf(mbThreadModelImpl.getOriginalGroupId()),
532 Long.valueOf(mbThreadModelImpl.getOriginalCategoryId())
533 };
534
535 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
536 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
537 args);
538
539 args = new Object[] {
540 Long.valueOf(mbThreadModelImpl.getGroupId()),
541 Long.valueOf(mbThreadModelImpl.getCategoryId())
542 };
543
544 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
545 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
546 args);
547 }
548
549 if ((mbThreadModelImpl.getColumnBitmask() &
550 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
551 Object[] args = new Object[] {
552 Long.valueOf(mbThreadModelImpl.getOriginalGroupId()),
553 Integer.valueOf(mbThreadModelImpl.getOriginalStatus())
554 };
555
556 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
557 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
558 args);
559
560 args = new Object[] {
561 Long.valueOf(mbThreadModelImpl.getGroupId()),
562 Integer.valueOf(mbThreadModelImpl.getStatus())
563 };
564
565 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
566 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
567 args);
568 }
569
570 if ((mbThreadModelImpl.getColumnBitmask() &
571 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
572 Object[] args = new Object[] {
573 Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()),
574 Double.valueOf(mbThreadModelImpl.getOriginalPriority())
575 };
576
577 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
578 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
579 args);
580
581 args = new Object[] {
582 Long.valueOf(mbThreadModelImpl.getCategoryId()),
583 Double.valueOf(mbThreadModelImpl.getPriority())
584 };
585
586 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
587 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
588 args);
589 }
590
591 if ((mbThreadModelImpl.getColumnBitmask() &
592 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
593 Object[] args = new Object[] {
594 mbThreadModelImpl.getOriginalLastPostDate(),
595 Double.valueOf(mbThreadModelImpl.getOriginalPriority())
596 };
597
598 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
599 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
600 args);
601
602 args = new Object[] {
603 mbThreadModelImpl.getLastPostDate(),
604 Double.valueOf(mbThreadModelImpl.getPriority())
605 };
606
607 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
608 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
609 args);
610 }
611
612 if ((mbThreadModelImpl.getColumnBitmask() &
613 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
614 Object[] args = new Object[] {
615 Long.valueOf(mbThreadModelImpl.getOriginalGroupId()),
616 Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()),
617
618 mbThreadModelImpl.getOriginalLastPostDate()
619 };
620
621 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
622 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
623 args);
624
625 args = new Object[] {
626 Long.valueOf(mbThreadModelImpl.getGroupId()),
627 Long.valueOf(mbThreadModelImpl.getCategoryId()),
628
629 mbThreadModelImpl.getLastPostDate()
630 };
631
632 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
633 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
634 args);
635 }
636
637 if ((mbThreadModelImpl.getColumnBitmask() &
638 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S.getColumnBitmask()) != 0) {
639 Object[] args = new Object[] {
640 Long.valueOf(mbThreadModelImpl.getOriginalGroupId()),
641 Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()),
642 Integer.valueOf(mbThreadModelImpl.getOriginalStatus())
643 };
644
645 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
646 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
647 args);
648
649 args = new Object[] {
650 Long.valueOf(mbThreadModelImpl.getGroupId()),
651 Long.valueOf(mbThreadModelImpl.getCategoryId()),
652 Integer.valueOf(mbThreadModelImpl.getStatus())
653 };
654
655 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
656 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
657 args);
658 }
659 }
660
661 EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
662 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
663
664 if (isNew) {
665 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
666 new Object[] { Long.valueOf(mbThread.getRootMessageId()) },
667 mbThread);
668 }
669 else {
670 if ((mbThreadModelImpl.getColumnBitmask() &
671 FINDER_PATH_FETCH_BY_ROOTMESSAGEID.getColumnBitmask()) != 0) {
672 Object[] args = new Object[] {
673 Long.valueOf(mbThreadModelImpl.getOriginalRootMessageId())
674 };
675
676 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID,
677 args);
678
679 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
680 args);
681
682 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
683 new Object[] { Long.valueOf(mbThread.getRootMessageId()) },
684 mbThread);
685 }
686 }
687
688 return mbThread;
689 }
690
691 protected MBThread toUnwrappedModel(MBThread mbThread) {
692 if (mbThread instanceof MBThreadImpl) {
693 return mbThread;
694 }
695
696 MBThreadImpl mbThreadImpl = new MBThreadImpl();
697
698 mbThreadImpl.setNew(mbThread.isNew());
699 mbThreadImpl.setPrimaryKey(mbThread.getPrimaryKey());
700
701 mbThreadImpl.setThreadId(mbThread.getThreadId());
702 mbThreadImpl.setGroupId(mbThread.getGroupId());
703 mbThreadImpl.setCompanyId(mbThread.getCompanyId());
704 mbThreadImpl.setCategoryId(mbThread.getCategoryId());
705 mbThreadImpl.setRootMessageId(mbThread.getRootMessageId());
706 mbThreadImpl.setRootMessageUserId(mbThread.getRootMessageUserId());
707 mbThreadImpl.setMessageCount(mbThread.getMessageCount());
708 mbThreadImpl.setViewCount(mbThread.getViewCount());
709 mbThreadImpl.setLastPostByUserId(mbThread.getLastPostByUserId());
710 mbThreadImpl.setLastPostDate(mbThread.getLastPostDate());
711 mbThreadImpl.setPriority(mbThread.getPriority());
712 mbThreadImpl.setQuestion(mbThread.isQuestion());
713 mbThreadImpl.setStatus(mbThread.getStatus());
714 mbThreadImpl.setStatusByUserId(mbThread.getStatusByUserId());
715 mbThreadImpl.setStatusByUserName(mbThread.getStatusByUserName());
716 mbThreadImpl.setStatusDate(mbThread.getStatusDate());
717
718 return mbThreadImpl;
719 }
720
721
729 @Override
730 public MBThread findByPrimaryKey(Serializable primaryKey)
731 throws NoSuchModelException, SystemException {
732 return findByPrimaryKey(((Long)primaryKey).longValue());
733 }
734
735
743 public MBThread findByPrimaryKey(long threadId)
744 throws NoSuchThreadException, SystemException {
745 MBThread mbThread = fetchByPrimaryKey(threadId);
746
747 if (mbThread == null) {
748 if (_log.isWarnEnabled()) {
749 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + threadId);
750 }
751
752 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
753 threadId);
754 }
755
756 return mbThread;
757 }
758
759
766 @Override
767 public MBThread fetchByPrimaryKey(Serializable primaryKey)
768 throws SystemException {
769 return fetchByPrimaryKey(((Long)primaryKey).longValue());
770 }
771
772
779 public MBThread fetchByPrimaryKey(long threadId) throws SystemException {
780 MBThread mbThread = (MBThread)EntityCacheUtil.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
781 MBThreadImpl.class, threadId);
782
783 if (mbThread == _nullMBThread) {
784 return null;
785 }
786
787 if (mbThread == null) {
788 Session session = null;
789
790 boolean hasException = false;
791
792 try {
793 session = openSession();
794
795 mbThread = (MBThread)session.get(MBThreadImpl.class,
796 Long.valueOf(threadId));
797 }
798 catch (Exception e) {
799 hasException = true;
800
801 throw processException(e);
802 }
803 finally {
804 if (mbThread != null) {
805 cacheResult(mbThread);
806 }
807 else if (!hasException) {
808 EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
809 MBThreadImpl.class, threadId, _nullMBThread);
810 }
811
812 closeSession(session);
813 }
814 }
815
816 return mbThread;
817 }
818
819
826 public List<MBThread> findByGroupId(long groupId) throws SystemException {
827 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
828 }
829
830
843 public List<MBThread> findByGroupId(long groupId, int start, int end)
844 throws SystemException {
845 return findByGroupId(groupId, start, end, null);
846 }
847
848
862 public List<MBThread> findByGroupId(long groupId, int start, int end,
863 OrderByComparator orderByComparator) throws SystemException {
864 FinderPath finderPath = null;
865 Object[] finderArgs = null;
866
867 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
868 (orderByComparator == null)) {
869 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
870 finderArgs = new Object[] { groupId };
871 }
872 else {
873 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
874 finderArgs = new Object[] { groupId, start, end, orderByComparator };
875 }
876
877 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
878 finderArgs, this);
879
880 if ((list != null) && !list.isEmpty()) {
881 for (MBThread mbThread : list) {
882 if ((groupId != mbThread.getGroupId())) {
883 list = null;
884
885 break;
886 }
887 }
888 }
889
890 if (list == null) {
891 StringBundler query = null;
892
893 if (orderByComparator != null) {
894 query = new StringBundler(3 +
895 (orderByComparator.getOrderByFields().length * 3));
896 }
897 else {
898 query = new StringBundler(3);
899 }
900
901 query.append(_SQL_SELECT_MBTHREAD_WHERE);
902
903 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
904
905 if (orderByComparator != null) {
906 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
907 orderByComparator);
908 }
909
910 else {
911 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
912 }
913
914 String sql = query.toString();
915
916 Session session = null;
917
918 try {
919 session = openSession();
920
921 Query q = session.createQuery(sql);
922
923 QueryPos qPos = QueryPos.getInstance(q);
924
925 qPos.add(groupId);
926
927 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
928 end);
929 }
930 catch (Exception e) {
931 throw processException(e);
932 }
933 finally {
934 if (list == null) {
935 FinderCacheUtil.removeResult(finderPath, finderArgs);
936 }
937 else {
938 cacheResult(list);
939
940 FinderCacheUtil.putResult(finderPath, finderArgs, list);
941 }
942
943 closeSession(session);
944 }
945 }
946
947 return list;
948 }
949
950
959 public MBThread findByGroupId_First(long groupId,
960 OrderByComparator orderByComparator)
961 throws NoSuchThreadException, SystemException {
962 MBThread mbThread = fetchByGroupId_First(groupId, orderByComparator);
963
964 if (mbThread != null) {
965 return mbThread;
966 }
967
968 StringBundler msg = new StringBundler(4);
969
970 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
971
972 msg.append("groupId=");
973 msg.append(groupId);
974
975 msg.append(StringPool.CLOSE_CURLY_BRACE);
976
977 throw new NoSuchThreadException(msg.toString());
978 }
979
980
988 public MBThread fetchByGroupId_First(long groupId,
989 OrderByComparator orderByComparator) throws SystemException {
990 List<MBThread> list = findByGroupId(groupId, 0, 1, orderByComparator);
991
992 if (!list.isEmpty()) {
993 return list.get(0);
994 }
995
996 return null;
997 }
998
999
1008 public MBThread findByGroupId_Last(long groupId,
1009 OrderByComparator orderByComparator)
1010 throws NoSuchThreadException, SystemException {
1011 MBThread mbThread = fetchByGroupId_Last(groupId, orderByComparator);
1012
1013 if (mbThread != null) {
1014 return mbThread;
1015 }
1016
1017 StringBundler msg = new StringBundler(4);
1018
1019 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1020
1021 msg.append("groupId=");
1022 msg.append(groupId);
1023
1024 msg.append(StringPool.CLOSE_CURLY_BRACE);
1025
1026 throw new NoSuchThreadException(msg.toString());
1027 }
1028
1029
1037 public MBThread fetchByGroupId_Last(long groupId,
1038 OrderByComparator orderByComparator) throws SystemException {
1039 int count = countByGroupId(groupId);
1040
1041 List<MBThread> list = findByGroupId(groupId, count - 1, count,
1042 orderByComparator);
1043
1044 if (!list.isEmpty()) {
1045 return list.get(0);
1046 }
1047
1048 return null;
1049 }
1050
1051
1061 public MBThread[] findByGroupId_PrevAndNext(long threadId, long groupId,
1062 OrderByComparator orderByComparator)
1063 throws NoSuchThreadException, SystemException {
1064 MBThread mbThread = findByPrimaryKey(threadId);
1065
1066 Session session = null;
1067
1068 try {
1069 session = openSession();
1070
1071 MBThread[] array = new MBThreadImpl[3];
1072
1073 array[0] = getByGroupId_PrevAndNext(session, mbThread, groupId,
1074 orderByComparator, true);
1075
1076 array[1] = mbThread;
1077
1078 array[2] = getByGroupId_PrevAndNext(session, mbThread, groupId,
1079 orderByComparator, false);
1080
1081 return array;
1082 }
1083 catch (Exception e) {
1084 throw processException(e);
1085 }
1086 finally {
1087 closeSession(session);
1088 }
1089 }
1090
1091 protected MBThread getByGroupId_PrevAndNext(Session session,
1092 MBThread mbThread, long groupId, OrderByComparator orderByComparator,
1093 boolean previous) {
1094 StringBundler query = null;
1095
1096 if (orderByComparator != null) {
1097 query = new StringBundler(6 +
1098 (orderByComparator.getOrderByFields().length * 6));
1099 }
1100 else {
1101 query = new StringBundler(3);
1102 }
1103
1104 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1105
1106 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1107
1108 if (orderByComparator != null) {
1109 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1110
1111 if (orderByConditionFields.length > 0) {
1112 query.append(WHERE_AND);
1113 }
1114
1115 for (int i = 0; i < orderByConditionFields.length; i++) {
1116 query.append(_ORDER_BY_ENTITY_ALIAS);
1117 query.append(orderByConditionFields[i]);
1118
1119 if ((i + 1) < orderByConditionFields.length) {
1120 if (orderByComparator.isAscending() ^ previous) {
1121 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1122 }
1123 else {
1124 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1125 }
1126 }
1127 else {
1128 if (orderByComparator.isAscending() ^ previous) {
1129 query.append(WHERE_GREATER_THAN);
1130 }
1131 else {
1132 query.append(WHERE_LESSER_THAN);
1133 }
1134 }
1135 }
1136
1137 query.append(ORDER_BY_CLAUSE);
1138
1139 String[] orderByFields = orderByComparator.getOrderByFields();
1140
1141 for (int i = 0; i < orderByFields.length; i++) {
1142 query.append(_ORDER_BY_ENTITY_ALIAS);
1143 query.append(orderByFields[i]);
1144
1145 if ((i + 1) < orderByFields.length) {
1146 if (orderByComparator.isAscending() ^ previous) {
1147 query.append(ORDER_BY_ASC_HAS_NEXT);
1148 }
1149 else {
1150 query.append(ORDER_BY_DESC_HAS_NEXT);
1151 }
1152 }
1153 else {
1154 if (orderByComparator.isAscending() ^ previous) {
1155 query.append(ORDER_BY_ASC);
1156 }
1157 else {
1158 query.append(ORDER_BY_DESC);
1159 }
1160 }
1161 }
1162 }
1163
1164 else {
1165 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1166 }
1167
1168 String sql = query.toString();
1169
1170 Query q = session.createQuery(sql);
1171
1172 q.setFirstResult(0);
1173 q.setMaxResults(2);
1174
1175 QueryPos qPos = QueryPos.getInstance(q);
1176
1177 qPos.add(groupId);
1178
1179 if (orderByComparator != null) {
1180 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
1181
1182 for (Object value : values) {
1183 qPos.add(value);
1184 }
1185 }
1186
1187 List<MBThread> list = q.list();
1188
1189 if (list.size() == 2) {
1190 return list.get(1);
1191 }
1192 else {
1193 return null;
1194 }
1195 }
1196
1197
1204 public List<MBThread> filterFindByGroupId(long groupId)
1205 throws SystemException {
1206 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1207 QueryUtil.ALL_POS, null);
1208 }
1209
1210
1223 public List<MBThread> filterFindByGroupId(long groupId, int start, int end)
1224 throws SystemException {
1225 return filterFindByGroupId(groupId, start, end, null);
1226 }
1227
1228
1242 public List<MBThread> filterFindByGroupId(long groupId, int start, int end,
1243 OrderByComparator orderByComparator) throws SystemException {
1244 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1245 return findByGroupId(groupId, start, end, orderByComparator);
1246 }
1247
1248 StringBundler query = null;
1249
1250 if (orderByComparator != null) {
1251 query = new StringBundler(3 +
1252 (orderByComparator.getOrderByFields().length * 3));
1253 }
1254 else {
1255 query = new StringBundler(3);
1256 }
1257
1258 if (getDB().isSupportsInlineDistinct()) {
1259 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
1260 }
1261 else {
1262 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
1263 }
1264
1265 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1266
1267 if (!getDB().isSupportsInlineDistinct()) {
1268 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
1269 }
1270
1271 if (orderByComparator != null) {
1272 if (getDB().isSupportsInlineDistinct()) {
1273 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1274 orderByComparator);
1275 }
1276 else {
1277 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1278 orderByComparator);
1279 }
1280 }
1281
1282 else {
1283 if (getDB().isSupportsInlineDistinct()) {
1284 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1285 }
1286 else {
1287 query.append(MBThreadModelImpl.ORDER_BY_SQL);
1288 }
1289 }
1290
1291 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1292 MBThread.class.getName(),
1293 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1294
1295 Session session = null;
1296
1297 try {
1298 session = openSession();
1299
1300 SQLQuery q = session.createSQLQuery(sql);
1301
1302 if (getDB().isSupportsInlineDistinct()) {
1303 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
1304 }
1305 else {
1306 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
1307 }
1308
1309 QueryPos qPos = QueryPos.getInstance(q);
1310
1311 qPos.add(groupId);
1312
1313 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
1314 }
1315 catch (Exception e) {
1316 throw processException(e);
1317 }
1318 finally {
1319 closeSession(session);
1320 }
1321 }
1322
1323
1333 public MBThread[] filterFindByGroupId_PrevAndNext(long threadId,
1334 long groupId, OrderByComparator orderByComparator)
1335 throws NoSuchThreadException, SystemException {
1336 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1337 return findByGroupId_PrevAndNext(threadId, groupId,
1338 orderByComparator);
1339 }
1340
1341 MBThread mbThread = findByPrimaryKey(threadId);
1342
1343 Session session = null;
1344
1345 try {
1346 session = openSession();
1347
1348 MBThread[] array = new MBThreadImpl[3];
1349
1350 array[0] = filterGetByGroupId_PrevAndNext(session, mbThread,
1351 groupId, orderByComparator, true);
1352
1353 array[1] = mbThread;
1354
1355 array[2] = filterGetByGroupId_PrevAndNext(session, mbThread,
1356 groupId, orderByComparator, false);
1357
1358 return array;
1359 }
1360 catch (Exception e) {
1361 throw processException(e);
1362 }
1363 finally {
1364 closeSession(session);
1365 }
1366 }
1367
1368 protected MBThread filterGetByGroupId_PrevAndNext(Session session,
1369 MBThread mbThread, long groupId, OrderByComparator orderByComparator,
1370 boolean previous) {
1371 StringBundler query = null;
1372
1373 if (orderByComparator != null) {
1374 query = new StringBundler(6 +
1375 (orderByComparator.getOrderByFields().length * 6));
1376 }
1377 else {
1378 query = new StringBundler(3);
1379 }
1380
1381 if (getDB().isSupportsInlineDistinct()) {
1382 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
1383 }
1384 else {
1385 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
1386 }
1387
1388 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1389
1390 if (!getDB().isSupportsInlineDistinct()) {
1391 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
1392 }
1393
1394 if (orderByComparator != null) {
1395 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1396
1397 if (orderByConditionFields.length > 0) {
1398 query.append(WHERE_AND);
1399 }
1400
1401 for (int i = 0; i < orderByConditionFields.length; i++) {
1402 if (getDB().isSupportsInlineDistinct()) {
1403 query.append(_ORDER_BY_ENTITY_ALIAS);
1404 }
1405 else {
1406 query.append(_ORDER_BY_ENTITY_TABLE);
1407 }
1408
1409 query.append(orderByConditionFields[i]);
1410
1411 if ((i + 1) < orderByConditionFields.length) {
1412 if (orderByComparator.isAscending() ^ previous) {
1413 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1414 }
1415 else {
1416 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1417 }
1418 }
1419 else {
1420 if (orderByComparator.isAscending() ^ previous) {
1421 query.append(WHERE_GREATER_THAN);
1422 }
1423 else {
1424 query.append(WHERE_LESSER_THAN);
1425 }
1426 }
1427 }
1428
1429 query.append(ORDER_BY_CLAUSE);
1430
1431 String[] orderByFields = orderByComparator.getOrderByFields();
1432
1433 for (int i = 0; i < orderByFields.length; i++) {
1434 if (getDB().isSupportsInlineDistinct()) {
1435 query.append(_ORDER_BY_ENTITY_ALIAS);
1436 }
1437 else {
1438 query.append(_ORDER_BY_ENTITY_TABLE);
1439 }
1440
1441 query.append(orderByFields[i]);
1442
1443 if ((i + 1) < orderByFields.length) {
1444 if (orderByComparator.isAscending() ^ previous) {
1445 query.append(ORDER_BY_ASC_HAS_NEXT);
1446 }
1447 else {
1448 query.append(ORDER_BY_DESC_HAS_NEXT);
1449 }
1450 }
1451 else {
1452 if (orderByComparator.isAscending() ^ previous) {
1453 query.append(ORDER_BY_ASC);
1454 }
1455 else {
1456 query.append(ORDER_BY_DESC);
1457 }
1458 }
1459 }
1460 }
1461
1462 else {
1463 if (getDB().isSupportsInlineDistinct()) {
1464 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1465 }
1466 else {
1467 query.append(MBThreadModelImpl.ORDER_BY_SQL);
1468 }
1469 }
1470
1471 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1472 MBThread.class.getName(),
1473 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1474
1475 SQLQuery q = session.createSQLQuery(sql);
1476
1477 q.setFirstResult(0);
1478 q.setMaxResults(2);
1479
1480 if (getDB().isSupportsInlineDistinct()) {
1481 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
1482 }
1483 else {
1484 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
1485 }
1486
1487 QueryPos qPos = QueryPos.getInstance(q);
1488
1489 qPos.add(groupId);
1490
1491 if (orderByComparator != null) {
1492 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
1493
1494 for (Object value : values) {
1495 qPos.add(value);
1496 }
1497 }
1498
1499 List<MBThread> list = q.list();
1500
1501 if (list.size() == 2) {
1502 return list.get(1);
1503 }
1504 else {
1505 return null;
1506 }
1507 }
1508
1509
1517 public MBThread findByRootMessageId(long rootMessageId)
1518 throws NoSuchThreadException, SystemException {
1519 MBThread mbThread = fetchByRootMessageId(rootMessageId);
1520
1521 if (mbThread == null) {
1522 StringBundler msg = new StringBundler(4);
1523
1524 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1525
1526 msg.append("rootMessageId=");
1527 msg.append(rootMessageId);
1528
1529 msg.append(StringPool.CLOSE_CURLY_BRACE);
1530
1531 if (_log.isWarnEnabled()) {
1532 _log.warn(msg.toString());
1533 }
1534
1535 throw new NoSuchThreadException(msg.toString());
1536 }
1537
1538 return mbThread;
1539 }
1540
1541
1548 public MBThread fetchByRootMessageId(long rootMessageId)
1549 throws SystemException {
1550 return fetchByRootMessageId(rootMessageId, true);
1551 }
1552
1553
1561 public MBThread fetchByRootMessageId(long rootMessageId,
1562 boolean retrieveFromCache) throws SystemException {
1563 Object[] finderArgs = new Object[] { rootMessageId };
1564
1565 Object result = null;
1566
1567 if (retrieveFromCache) {
1568 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
1569 finderArgs, this);
1570 }
1571
1572 if (result instanceof MBThread) {
1573 MBThread mbThread = (MBThread)result;
1574
1575 if ((rootMessageId != mbThread.getRootMessageId())) {
1576 result = null;
1577 }
1578 }
1579
1580 if (result == null) {
1581 StringBundler query = new StringBundler(3);
1582
1583 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1584
1585 query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2);
1586
1587 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1588
1589 String sql = query.toString();
1590
1591 Session session = null;
1592
1593 try {
1594 session = openSession();
1595
1596 Query q = session.createQuery(sql);
1597
1598 QueryPos qPos = QueryPos.getInstance(q);
1599
1600 qPos.add(rootMessageId);
1601
1602 List<MBThread> list = q.list();
1603
1604 result = list;
1605
1606 MBThread mbThread = null;
1607
1608 if (list.isEmpty()) {
1609 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
1610 finderArgs, list);
1611 }
1612 else {
1613 mbThread = list.get(0);
1614
1615 cacheResult(mbThread);
1616
1617 if ((mbThread.getRootMessageId() != rootMessageId)) {
1618 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
1619 finderArgs, mbThread);
1620 }
1621 }
1622
1623 return mbThread;
1624 }
1625 catch (Exception e) {
1626 throw processException(e);
1627 }
1628 finally {
1629 if (result == null) {
1630 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
1631 finderArgs);
1632 }
1633
1634 closeSession(session);
1635 }
1636 }
1637 else {
1638 if (result instanceof List<?>) {
1639 return null;
1640 }
1641 else {
1642 return (MBThread)result;
1643 }
1644 }
1645 }
1646
1647
1655 public List<MBThread> findByG_C(long groupId, long categoryId)
1656 throws SystemException {
1657 return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
1658 QueryUtil.ALL_POS, null);
1659 }
1660
1661
1675 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
1676 int end) throws SystemException {
1677 return findByG_C(groupId, categoryId, start, end, null);
1678 }
1679
1680
1695 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
1696 int end, OrderByComparator orderByComparator) throws SystemException {
1697 FinderPath finderPath = null;
1698 Object[] finderArgs = null;
1699
1700 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1701 (orderByComparator == null)) {
1702 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C;
1703 finderArgs = new Object[] { groupId, categoryId };
1704 }
1705 else {
1706 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
1707 finderArgs = new Object[] {
1708 groupId, categoryId,
1709
1710 start, end, orderByComparator
1711 };
1712 }
1713
1714 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
1715 finderArgs, this);
1716
1717 if ((list != null) && !list.isEmpty()) {
1718 for (MBThread mbThread : list) {
1719 if ((groupId != mbThread.getGroupId()) ||
1720 (categoryId != mbThread.getCategoryId())) {
1721 list = null;
1722
1723 break;
1724 }
1725 }
1726 }
1727
1728 if (list == null) {
1729 StringBundler query = null;
1730
1731 if (orderByComparator != null) {
1732 query = new StringBundler(4 +
1733 (orderByComparator.getOrderByFields().length * 3));
1734 }
1735 else {
1736 query = new StringBundler(4);
1737 }
1738
1739 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1740
1741 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1742
1743 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1744
1745 if (orderByComparator != null) {
1746 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1747 orderByComparator);
1748 }
1749
1750 else {
1751 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1752 }
1753
1754 String sql = query.toString();
1755
1756 Session session = null;
1757
1758 try {
1759 session = openSession();
1760
1761 Query q = session.createQuery(sql);
1762
1763 QueryPos qPos = QueryPos.getInstance(q);
1764
1765 qPos.add(groupId);
1766
1767 qPos.add(categoryId);
1768
1769 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
1770 end);
1771 }
1772 catch (Exception e) {
1773 throw processException(e);
1774 }
1775 finally {
1776 if (list == null) {
1777 FinderCacheUtil.removeResult(finderPath, finderArgs);
1778 }
1779 else {
1780 cacheResult(list);
1781
1782 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1783 }
1784
1785 closeSession(session);
1786 }
1787 }
1788
1789 return list;
1790 }
1791
1792
1802 public MBThread findByG_C_First(long groupId, long categoryId,
1803 OrderByComparator orderByComparator)
1804 throws NoSuchThreadException, SystemException {
1805 MBThread mbThread = fetchByG_C_First(groupId, categoryId,
1806 orderByComparator);
1807
1808 if (mbThread != null) {
1809 return mbThread;
1810 }
1811
1812 StringBundler msg = new StringBundler(6);
1813
1814 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1815
1816 msg.append("groupId=");
1817 msg.append(groupId);
1818
1819 msg.append(", categoryId=");
1820 msg.append(categoryId);
1821
1822 msg.append(StringPool.CLOSE_CURLY_BRACE);
1823
1824 throw new NoSuchThreadException(msg.toString());
1825 }
1826
1827
1836 public MBThread fetchByG_C_First(long groupId, long categoryId,
1837 OrderByComparator orderByComparator) throws SystemException {
1838 List<MBThread> list = findByG_C(groupId, categoryId, 0, 1,
1839 orderByComparator);
1840
1841 if (!list.isEmpty()) {
1842 return list.get(0);
1843 }
1844
1845 return null;
1846 }
1847
1848
1858 public MBThread findByG_C_Last(long groupId, long categoryId,
1859 OrderByComparator orderByComparator)
1860 throws NoSuchThreadException, SystemException {
1861 MBThread mbThread = fetchByG_C_Last(groupId, categoryId,
1862 orderByComparator);
1863
1864 if (mbThread != null) {
1865 return mbThread;
1866 }
1867
1868 StringBundler msg = new StringBundler(6);
1869
1870 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1871
1872 msg.append("groupId=");
1873 msg.append(groupId);
1874
1875 msg.append(", categoryId=");
1876 msg.append(categoryId);
1877
1878 msg.append(StringPool.CLOSE_CURLY_BRACE);
1879
1880 throw new NoSuchThreadException(msg.toString());
1881 }
1882
1883
1892 public MBThread fetchByG_C_Last(long groupId, long categoryId,
1893 OrderByComparator orderByComparator) throws SystemException {
1894 int count = countByG_C(groupId, categoryId);
1895
1896 List<MBThread> list = findByG_C(groupId, categoryId, count - 1, count,
1897 orderByComparator);
1898
1899 if (!list.isEmpty()) {
1900 return list.get(0);
1901 }
1902
1903 return null;
1904 }
1905
1906
1917 public MBThread[] findByG_C_PrevAndNext(long threadId, long groupId,
1918 long categoryId, OrderByComparator orderByComparator)
1919 throws NoSuchThreadException, SystemException {
1920 MBThread mbThread = findByPrimaryKey(threadId);
1921
1922 Session session = null;
1923
1924 try {
1925 session = openSession();
1926
1927 MBThread[] array = new MBThreadImpl[3];
1928
1929 array[0] = getByG_C_PrevAndNext(session, mbThread, groupId,
1930 categoryId, orderByComparator, true);
1931
1932 array[1] = mbThread;
1933
1934 array[2] = getByG_C_PrevAndNext(session, mbThread, groupId,
1935 categoryId, orderByComparator, false);
1936
1937 return array;
1938 }
1939 catch (Exception e) {
1940 throw processException(e);
1941 }
1942 finally {
1943 closeSession(session);
1944 }
1945 }
1946
1947 protected MBThread getByG_C_PrevAndNext(Session session, MBThread mbThread,
1948 long groupId, long categoryId, OrderByComparator orderByComparator,
1949 boolean previous) {
1950 StringBundler query = null;
1951
1952 if (orderByComparator != null) {
1953 query = new StringBundler(6 +
1954 (orderByComparator.getOrderByFields().length * 6));
1955 }
1956 else {
1957 query = new StringBundler(3);
1958 }
1959
1960 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1961
1962 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1963
1964 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1965
1966 if (orderByComparator != null) {
1967 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1968
1969 if (orderByConditionFields.length > 0) {
1970 query.append(WHERE_AND);
1971 }
1972
1973 for (int i = 0; i < orderByConditionFields.length; i++) {
1974 query.append(_ORDER_BY_ENTITY_ALIAS);
1975 query.append(orderByConditionFields[i]);
1976
1977 if ((i + 1) < orderByConditionFields.length) {
1978 if (orderByComparator.isAscending() ^ previous) {
1979 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1980 }
1981 else {
1982 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1983 }
1984 }
1985 else {
1986 if (orderByComparator.isAscending() ^ previous) {
1987 query.append(WHERE_GREATER_THAN);
1988 }
1989 else {
1990 query.append(WHERE_LESSER_THAN);
1991 }
1992 }
1993 }
1994
1995 query.append(ORDER_BY_CLAUSE);
1996
1997 String[] orderByFields = orderByComparator.getOrderByFields();
1998
1999 for (int i = 0; i < orderByFields.length; i++) {
2000 query.append(_ORDER_BY_ENTITY_ALIAS);
2001 query.append(orderByFields[i]);
2002
2003 if ((i + 1) < orderByFields.length) {
2004 if (orderByComparator.isAscending() ^ previous) {
2005 query.append(ORDER_BY_ASC_HAS_NEXT);
2006 }
2007 else {
2008 query.append(ORDER_BY_DESC_HAS_NEXT);
2009 }
2010 }
2011 else {
2012 if (orderByComparator.isAscending() ^ previous) {
2013 query.append(ORDER_BY_ASC);
2014 }
2015 else {
2016 query.append(ORDER_BY_DESC);
2017 }
2018 }
2019 }
2020 }
2021
2022 else {
2023 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2024 }
2025
2026 String sql = query.toString();
2027
2028 Query q = session.createQuery(sql);
2029
2030 q.setFirstResult(0);
2031 q.setMaxResults(2);
2032
2033 QueryPos qPos = QueryPos.getInstance(q);
2034
2035 qPos.add(groupId);
2036
2037 qPos.add(categoryId);
2038
2039 if (orderByComparator != null) {
2040 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
2041
2042 for (Object value : values) {
2043 qPos.add(value);
2044 }
2045 }
2046
2047 List<MBThread> list = q.list();
2048
2049 if (list.size() == 2) {
2050 return list.get(1);
2051 }
2052 else {
2053 return null;
2054 }
2055 }
2056
2057
2069 public List<MBThread> findByG_C(long groupId, long[] categoryIds)
2070 throws SystemException {
2071 return findByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
2072 QueryUtil.ALL_POS, null);
2073 }
2074
2075
2089 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
2090 int start, int end) throws SystemException {
2091 return findByG_C(groupId, categoryIds, start, end, null);
2092 }
2093
2094
2109 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
2110 int start, int end, OrderByComparator orderByComparator)
2111 throws SystemException {
2112 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
2113 Object[] finderArgs = null;
2114
2115 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2116 (orderByComparator == null)) {
2117 finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds) };
2118 }
2119 else {
2120 finderArgs = new Object[] {
2121 groupId, StringUtil.merge(categoryIds),
2122
2123 start, end, orderByComparator
2124 };
2125 }
2126
2127 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
2128 finderArgs, this);
2129
2130 if ((list != null) && !list.isEmpty()) {
2131 for (MBThread mbThread : list) {
2132 if ((groupId != mbThread.getGroupId()) ||
2133 !ArrayUtil.contains(categoryIds,
2134 mbThread.getCategoryId())) {
2135 list = null;
2136
2137 break;
2138 }
2139 }
2140 }
2141
2142 if (list == null) {
2143 StringBundler query = new StringBundler();
2144
2145 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2146
2147 boolean conjunctionable = false;
2148
2149 if (conjunctionable) {
2150 query.append(WHERE_AND);
2151 }
2152
2153 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
2154
2155 conjunctionable = true;
2156
2157 if ((categoryIds == null) || (categoryIds.length > 0)) {
2158 if (conjunctionable) {
2159 query.append(WHERE_AND);
2160 }
2161
2162 query.append(StringPool.OPEN_PARENTHESIS);
2163
2164 for (int i = 0; i < categoryIds.length; i++) {
2165 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
2166
2167 if ((i + 1) < categoryIds.length) {
2168 query.append(WHERE_OR);
2169 }
2170 }
2171
2172 query.append(StringPool.CLOSE_PARENTHESIS);
2173
2174 conjunctionable = true;
2175 }
2176
2177 if (orderByComparator != null) {
2178 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2179 orderByComparator);
2180 }
2181
2182 else {
2183 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2184 }
2185
2186 String sql = query.toString();
2187
2188 Session session = null;
2189
2190 try {
2191 session = openSession();
2192
2193 Query q = session.createQuery(sql);
2194
2195 QueryPos qPos = QueryPos.getInstance(q);
2196
2197 qPos.add(groupId);
2198
2199 if (categoryIds != null) {
2200 qPos.add(categoryIds);
2201 }
2202
2203 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
2204 end);
2205 }
2206 catch (Exception e) {
2207 throw processException(e);
2208 }
2209 finally {
2210 if (list == null) {
2211 FinderCacheUtil.removeResult(finderPath, finderArgs);
2212 }
2213 else {
2214 cacheResult(list);
2215
2216 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2217 }
2218
2219 closeSession(session);
2220 }
2221 }
2222
2223 return list;
2224 }
2225
2226
2234 public List<MBThread> filterFindByG_C(long groupId, long categoryId)
2235 throws SystemException {
2236 return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS,
2237 QueryUtil.ALL_POS, null);
2238 }
2239
2240
2254 public List<MBThread> filterFindByG_C(long groupId, long categoryId,
2255 int start, int end) throws SystemException {
2256 return filterFindByG_C(groupId, categoryId, start, end, null);
2257 }
2258
2259
2274 public List<MBThread> filterFindByG_C(long groupId, long categoryId,
2275 int start, int end, OrderByComparator orderByComparator)
2276 throws SystemException {
2277 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2278 return findByG_C(groupId, categoryId, start, end, orderByComparator);
2279 }
2280
2281 StringBundler query = null;
2282
2283 if (orderByComparator != null) {
2284 query = new StringBundler(4 +
2285 (orderByComparator.getOrderByFields().length * 3));
2286 }
2287 else {
2288 query = new StringBundler(4);
2289 }
2290
2291 if (getDB().isSupportsInlineDistinct()) {
2292 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
2293 }
2294 else {
2295 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
2296 }
2297
2298 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2299
2300 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2301
2302 if (!getDB().isSupportsInlineDistinct()) {
2303 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
2304 }
2305
2306 if (orderByComparator != null) {
2307 if (getDB().isSupportsInlineDistinct()) {
2308 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2309 orderByComparator);
2310 }
2311 else {
2312 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2313 orderByComparator);
2314 }
2315 }
2316
2317 else {
2318 if (getDB().isSupportsInlineDistinct()) {
2319 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2320 }
2321 else {
2322 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2323 }
2324 }
2325
2326 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2327 MBThread.class.getName(),
2328 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2329
2330 Session session = null;
2331
2332 try {
2333 session = openSession();
2334
2335 SQLQuery q = session.createSQLQuery(sql);
2336
2337 if (getDB().isSupportsInlineDistinct()) {
2338 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2339 }
2340 else {
2341 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2342 }
2343
2344 QueryPos qPos = QueryPos.getInstance(q);
2345
2346 qPos.add(groupId);
2347
2348 qPos.add(categoryId);
2349
2350 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
2351 }
2352 catch (Exception e) {
2353 throw processException(e);
2354 }
2355 finally {
2356 closeSession(session);
2357 }
2358 }
2359
2360
2371 public MBThread[] filterFindByG_C_PrevAndNext(long threadId, long groupId,
2372 long categoryId, OrderByComparator orderByComparator)
2373 throws NoSuchThreadException, SystemException {
2374 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2375 return findByG_C_PrevAndNext(threadId, groupId, categoryId,
2376 orderByComparator);
2377 }
2378
2379 MBThread mbThread = findByPrimaryKey(threadId);
2380
2381 Session session = null;
2382
2383 try {
2384 session = openSession();
2385
2386 MBThread[] array = new MBThreadImpl[3];
2387
2388 array[0] = filterGetByG_C_PrevAndNext(session, mbThread, groupId,
2389 categoryId, orderByComparator, true);
2390
2391 array[1] = mbThread;
2392
2393 array[2] = filterGetByG_C_PrevAndNext(session, mbThread, groupId,
2394 categoryId, orderByComparator, false);
2395
2396 return array;
2397 }
2398 catch (Exception e) {
2399 throw processException(e);
2400 }
2401 finally {
2402 closeSession(session);
2403 }
2404 }
2405
2406 protected MBThread filterGetByG_C_PrevAndNext(Session session,
2407 MBThread mbThread, long groupId, long categoryId,
2408 OrderByComparator orderByComparator, boolean previous) {
2409 StringBundler query = null;
2410
2411 if (orderByComparator != null) {
2412 query = new StringBundler(6 +
2413 (orderByComparator.getOrderByFields().length * 6));
2414 }
2415 else {
2416 query = new StringBundler(3);
2417 }
2418
2419 if (getDB().isSupportsInlineDistinct()) {
2420 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
2421 }
2422 else {
2423 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
2424 }
2425
2426 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2427
2428 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2429
2430 if (!getDB().isSupportsInlineDistinct()) {
2431 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
2432 }
2433
2434 if (orderByComparator != null) {
2435 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2436
2437 if (orderByConditionFields.length > 0) {
2438 query.append(WHERE_AND);
2439 }
2440
2441 for (int i = 0; i < orderByConditionFields.length; i++) {
2442 if (getDB().isSupportsInlineDistinct()) {
2443 query.append(_ORDER_BY_ENTITY_ALIAS);
2444 }
2445 else {
2446 query.append(_ORDER_BY_ENTITY_TABLE);
2447 }
2448
2449 query.append(orderByConditionFields[i]);
2450
2451 if ((i + 1) < orderByConditionFields.length) {
2452 if (orderByComparator.isAscending() ^ previous) {
2453 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2454 }
2455 else {
2456 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2457 }
2458 }
2459 else {
2460 if (orderByComparator.isAscending() ^ previous) {
2461 query.append(WHERE_GREATER_THAN);
2462 }
2463 else {
2464 query.append(WHERE_LESSER_THAN);
2465 }
2466 }
2467 }
2468
2469 query.append(ORDER_BY_CLAUSE);
2470
2471 String[] orderByFields = orderByComparator.getOrderByFields();
2472
2473 for (int i = 0; i < orderByFields.length; i++) {
2474 if (getDB().isSupportsInlineDistinct()) {
2475 query.append(_ORDER_BY_ENTITY_ALIAS);
2476 }
2477 else {
2478 query.append(_ORDER_BY_ENTITY_TABLE);
2479 }
2480
2481 query.append(orderByFields[i]);
2482
2483 if ((i + 1) < orderByFields.length) {
2484 if (orderByComparator.isAscending() ^ previous) {
2485 query.append(ORDER_BY_ASC_HAS_NEXT);
2486 }
2487 else {
2488 query.append(ORDER_BY_DESC_HAS_NEXT);
2489 }
2490 }
2491 else {
2492 if (orderByComparator.isAscending() ^ previous) {
2493 query.append(ORDER_BY_ASC);
2494 }
2495 else {
2496 query.append(ORDER_BY_DESC);
2497 }
2498 }
2499 }
2500 }
2501
2502 else {
2503 if (getDB().isSupportsInlineDistinct()) {
2504 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2505 }
2506 else {
2507 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2508 }
2509 }
2510
2511 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2512 MBThread.class.getName(),
2513 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2514
2515 SQLQuery q = session.createSQLQuery(sql);
2516
2517 q.setFirstResult(0);
2518 q.setMaxResults(2);
2519
2520 if (getDB().isSupportsInlineDistinct()) {
2521 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2522 }
2523 else {
2524 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2525 }
2526
2527 QueryPos qPos = QueryPos.getInstance(q);
2528
2529 qPos.add(groupId);
2530
2531 qPos.add(categoryId);
2532
2533 if (orderByComparator != null) {
2534 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
2535
2536 for (Object value : values) {
2537 qPos.add(value);
2538 }
2539 }
2540
2541 List<MBThread> list = q.list();
2542
2543 if (list.size() == 2) {
2544 return list.get(1);
2545 }
2546 else {
2547 return null;
2548 }
2549 }
2550
2551
2559 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds)
2560 throws SystemException {
2561 return filterFindByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
2562 QueryUtil.ALL_POS, null);
2563 }
2564
2565
2579 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds,
2580 int start, int end) throws SystemException {
2581 return filterFindByG_C(groupId, categoryIds, start, end, null);
2582 }
2583
2584
2599 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds,
2600 int start, int end, OrderByComparator orderByComparator)
2601 throws SystemException {
2602 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2603 return findByG_C(groupId, categoryIds, start, end, orderByComparator);
2604 }
2605
2606 StringBundler query = new StringBundler();
2607
2608 if (getDB().isSupportsInlineDistinct()) {
2609 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
2610 }
2611 else {
2612 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
2613 }
2614
2615 boolean conjunctionable = false;
2616
2617 if (conjunctionable) {
2618 query.append(WHERE_AND);
2619 }
2620
2621 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
2622
2623 conjunctionable = true;
2624
2625 if ((categoryIds == null) || (categoryIds.length > 0)) {
2626 if (conjunctionable) {
2627 query.append(WHERE_AND);
2628 }
2629
2630 query.append(StringPool.OPEN_PARENTHESIS);
2631
2632 for (int i = 0; i < categoryIds.length; i++) {
2633 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
2634
2635 if ((i + 1) < categoryIds.length) {
2636 query.append(WHERE_OR);
2637 }
2638 }
2639
2640 query.append(StringPool.CLOSE_PARENTHESIS);
2641
2642 conjunctionable = true;
2643 }
2644
2645 if (!getDB().isSupportsInlineDistinct()) {
2646 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
2647 }
2648
2649 if (orderByComparator != null) {
2650 if (getDB().isSupportsInlineDistinct()) {
2651 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2652 orderByComparator);
2653 }
2654 else {
2655 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2656 orderByComparator);
2657 }
2658 }
2659
2660 else {
2661 if (getDB().isSupportsInlineDistinct()) {
2662 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2663 }
2664 else {
2665 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2666 }
2667 }
2668
2669 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2670 MBThread.class.getName(),
2671 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2672
2673 Session session = null;
2674
2675 try {
2676 session = openSession();
2677
2678 SQLQuery q = session.createSQLQuery(sql);
2679
2680 if (getDB().isSupportsInlineDistinct()) {
2681 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2682 }
2683 else {
2684 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2685 }
2686
2687 QueryPos qPos = QueryPos.getInstance(q);
2688
2689 qPos.add(groupId);
2690
2691 if (categoryIds != null) {
2692 qPos.add(categoryIds);
2693 }
2694
2695 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
2696 }
2697 catch (Exception e) {
2698 throw processException(e);
2699 }
2700 finally {
2701 closeSession(session);
2702 }
2703 }
2704
2705
2713 public List<MBThread> findByG_NotC(long groupId, long categoryId)
2714 throws SystemException {
2715 return findByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
2716 QueryUtil.ALL_POS, null);
2717 }
2718
2719
2733 public List<MBThread> findByG_NotC(long groupId, long categoryId,
2734 int start, int end) throws SystemException {
2735 return findByG_NotC(groupId, categoryId, start, end, null);
2736 }
2737
2738
2753 public List<MBThread> findByG_NotC(long groupId, long categoryId,
2754 int start, int end, OrderByComparator orderByComparator)
2755 throws SystemException {
2756 FinderPath finderPath = null;
2757 Object[] finderArgs = null;
2758
2759 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC;
2760 finderArgs = new Object[] {
2761 groupId, categoryId,
2762
2763 start, end, orderByComparator
2764 };
2765
2766 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
2767 finderArgs, this);
2768
2769 if ((list != null) && !list.isEmpty()) {
2770 for (MBThread mbThread : list) {
2771 if ((groupId != mbThread.getGroupId()) ||
2772 (categoryId != mbThread.getCategoryId())) {
2773 list = null;
2774
2775 break;
2776 }
2777 }
2778 }
2779
2780 if (list == null) {
2781 StringBundler query = null;
2782
2783 if (orderByComparator != null) {
2784 query = new StringBundler(4 +
2785 (orderByComparator.getOrderByFields().length * 3));
2786 }
2787 else {
2788 query = new StringBundler(4);
2789 }
2790
2791 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2792
2793 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
2794
2795 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
2796
2797 if (orderByComparator != null) {
2798 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2799 orderByComparator);
2800 }
2801
2802 else {
2803 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2804 }
2805
2806 String sql = query.toString();
2807
2808 Session session = null;
2809
2810 try {
2811 session = openSession();
2812
2813 Query q = session.createQuery(sql);
2814
2815 QueryPos qPos = QueryPos.getInstance(q);
2816
2817 qPos.add(groupId);
2818
2819 qPos.add(categoryId);
2820
2821 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
2822 end);
2823 }
2824 catch (Exception e) {
2825 throw processException(e);
2826 }
2827 finally {
2828 if (list == null) {
2829 FinderCacheUtil.removeResult(finderPath, finderArgs);
2830 }
2831 else {
2832 cacheResult(list);
2833
2834 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2835 }
2836
2837 closeSession(session);
2838 }
2839 }
2840
2841 return list;
2842 }
2843
2844
2854 public MBThread findByG_NotC_First(long groupId, long categoryId,
2855 OrderByComparator orderByComparator)
2856 throws NoSuchThreadException, SystemException {
2857 MBThread mbThread = fetchByG_NotC_First(groupId, categoryId,
2858 orderByComparator);
2859
2860 if (mbThread != null) {
2861 return mbThread;
2862 }
2863
2864 StringBundler msg = new StringBundler(6);
2865
2866 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2867
2868 msg.append("groupId=");
2869 msg.append(groupId);
2870
2871 msg.append(", categoryId=");
2872 msg.append(categoryId);
2873
2874 msg.append(StringPool.CLOSE_CURLY_BRACE);
2875
2876 throw new NoSuchThreadException(msg.toString());
2877 }
2878
2879
2888 public MBThread fetchByG_NotC_First(long groupId, long categoryId,
2889 OrderByComparator orderByComparator) throws SystemException {
2890 List<MBThread> list = findByG_NotC(groupId, categoryId, 0, 1,
2891 orderByComparator);
2892
2893 if (!list.isEmpty()) {
2894 return list.get(0);
2895 }
2896
2897 return null;
2898 }
2899
2900
2910 public MBThread findByG_NotC_Last(long groupId, long categoryId,
2911 OrderByComparator orderByComparator)
2912 throws NoSuchThreadException, SystemException {
2913 MBThread mbThread = fetchByG_NotC_Last(groupId, categoryId,
2914 orderByComparator);
2915
2916 if (mbThread != null) {
2917 return mbThread;
2918 }
2919
2920 StringBundler msg = new StringBundler(6);
2921
2922 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2923
2924 msg.append("groupId=");
2925 msg.append(groupId);
2926
2927 msg.append(", categoryId=");
2928 msg.append(categoryId);
2929
2930 msg.append(StringPool.CLOSE_CURLY_BRACE);
2931
2932 throw new NoSuchThreadException(msg.toString());
2933 }
2934
2935
2944 public MBThread fetchByG_NotC_Last(long groupId, long categoryId,
2945 OrderByComparator orderByComparator) throws SystemException {
2946 int count = countByG_NotC(groupId, categoryId);
2947
2948 List<MBThread> list = findByG_NotC(groupId, categoryId, count - 1,
2949 count, orderByComparator);
2950
2951 if (!list.isEmpty()) {
2952 return list.get(0);
2953 }
2954
2955 return null;
2956 }
2957
2958
2969 public MBThread[] findByG_NotC_PrevAndNext(long threadId, long groupId,
2970 long categoryId, OrderByComparator orderByComparator)
2971 throws NoSuchThreadException, SystemException {
2972 MBThread mbThread = findByPrimaryKey(threadId);
2973
2974 Session session = null;
2975
2976 try {
2977 session = openSession();
2978
2979 MBThread[] array = new MBThreadImpl[3];
2980
2981 array[0] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
2982 categoryId, orderByComparator, true);
2983
2984 array[1] = mbThread;
2985
2986 array[2] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
2987 categoryId, orderByComparator, false);
2988
2989 return array;
2990 }
2991 catch (Exception e) {
2992 throw processException(e);
2993 }
2994 finally {
2995 closeSession(session);
2996 }
2997 }
2998
2999 protected MBThread getByG_NotC_PrevAndNext(Session session,
3000 MBThread mbThread, long groupId, long categoryId,
3001 OrderByComparator orderByComparator, boolean previous) {
3002 StringBundler query = null;
3003
3004 if (orderByComparator != null) {
3005 query = new StringBundler(6 +
3006 (orderByComparator.getOrderByFields().length * 6));
3007 }
3008 else {
3009 query = new StringBundler(3);
3010 }
3011
3012 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3013
3014 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
3015
3016 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
3017
3018 if (orderByComparator != null) {
3019 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3020
3021 if (orderByConditionFields.length > 0) {
3022 query.append(WHERE_AND);
3023 }
3024
3025 for (int i = 0; i < orderByConditionFields.length; i++) {
3026 query.append(_ORDER_BY_ENTITY_ALIAS);
3027 query.append(orderByConditionFields[i]);
3028
3029 if ((i + 1) < orderByConditionFields.length) {
3030 if (orderByComparator.isAscending() ^ previous) {
3031 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3032 }
3033 else {
3034 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3035 }
3036 }
3037 else {
3038 if (orderByComparator.isAscending() ^ previous) {
3039 query.append(WHERE_GREATER_THAN);
3040 }
3041 else {
3042 query.append(WHERE_LESSER_THAN);
3043 }
3044 }
3045 }
3046
3047 query.append(ORDER_BY_CLAUSE);
3048
3049 String[] orderByFields = orderByComparator.getOrderByFields();
3050
3051 for (int i = 0; i < orderByFields.length; i++) {
3052 query.append(_ORDER_BY_ENTITY_ALIAS);
3053 query.append(orderByFields[i]);
3054
3055 if ((i + 1) < orderByFields.length) {
3056 if (orderByComparator.isAscending() ^ previous) {
3057 query.append(ORDER_BY_ASC_HAS_NEXT);
3058 }
3059 else {
3060 query.append(ORDER_BY_DESC_HAS_NEXT);
3061 }
3062 }
3063 else {
3064 if (orderByComparator.isAscending() ^ previous) {
3065 query.append(ORDER_BY_ASC);
3066 }
3067 else {
3068 query.append(ORDER_BY_DESC);
3069 }
3070 }
3071 }
3072 }
3073
3074 else {
3075 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3076 }
3077
3078 String sql = query.toString();
3079
3080 Query q = session.createQuery(sql);
3081
3082 q.setFirstResult(0);
3083 q.setMaxResults(2);
3084
3085 QueryPos qPos = QueryPos.getInstance(q);
3086
3087 qPos.add(groupId);
3088
3089 qPos.add(categoryId);
3090
3091 if (orderByComparator != null) {
3092 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3093
3094 for (Object value : values) {
3095 qPos.add(value);
3096 }
3097 }
3098
3099 List<MBThread> list = q.list();
3100
3101 if (list.size() == 2) {
3102 return list.get(1);
3103 }
3104 else {
3105 return null;
3106 }
3107 }
3108
3109
3117 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId)
3118 throws SystemException {
3119 return filterFindByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
3120 QueryUtil.ALL_POS, null);
3121 }
3122
3123
3137 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId,
3138 int start, int end) throws SystemException {
3139 return filterFindByG_NotC(groupId, categoryId, start, end, null);
3140 }
3141
3142
3157 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId,
3158 int start, int end, OrderByComparator orderByComparator)
3159 throws SystemException {
3160 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3161 return findByG_NotC(groupId, categoryId, start, end,
3162 orderByComparator);
3163 }
3164
3165 StringBundler query = null;
3166
3167 if (orderByComparator != null) {
3168 query = new StringBundler(4 +
3169 (orderByComparator.getOrderByFields().length * 3));
3170 }
3171 else {
3172 query = new StringBundler(4);
3173 }
3174
3175 if (getDB().isSupportsInlineDistinct()) {
3176 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3177 }
3178 else {
3179 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3180 }
3181
3182 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
3183
3184 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
3185
3186 if (!getDB().isSupportsInlineDistinct()) {
3187 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3188 }
3189
3190 if (orderByComparator != null) {
3191 if (getDB().isSupportsInlineDistinct()) {
3192 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3193 orderByComparator);
3194 }
3195 else {
3196 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3197 orderByComparator);
3198 }
3199 }
3200
3201 else {
3202 if (getDB().isSupportsInlineDistinct()) {
3203 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3204 }
3205 else {
3206 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3207 }
3208 }
3209
3210 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3211 MBThread.class.getName(),
3212 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3213
3214 Session session = null;
3215
3216 try {
3217 session = openSession();
3218
3219 SQLQuery q = session.createSQLQuery(sql);
3220
3221 if (getDB().isSupportsInlineDistinct()) {
3222 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3223 }
3224 else {
3225 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3226 }
3227
3228 QueryPos qPos = QueryPos.getInstance(q);
3229
3230 qPos.add(groupId);
3231
3232 qPos.add(categoryId);
3233
3234 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
3235 }
3236 catch (Exception e) {
3237 throw processException(e);
3238 }
3239 finally {
3240 closeSession(session);
3241 }
3242 }
3243
3244
3255 public MBThread[] filterFindByG_NotC_PrevAndNext(long threadId,
3256 long groupId, long categoryId, OrderByComparator orderByComparator)
3257 throws NoSuchThreadException, SystemException {
3258 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3259 return findByG_NotC_PrevAndNext(threadId, groupId, categoryId,
3260 orderByComparator);
3261 }
3262
3263 MBThread mbThread = findByPrimaryKey(threadId);
3264
3265 Session session = null;
3266
3267 try {
3268 session = openSession();
3269
3270 MBThread[] array = new MBThreadImpl[3];
3271
3272 array[0] = filterGetByG_NotC_PrevAndNext(session, mbThread,
3273 groupId, categoryId, orderByComparator, true);
3274
3275 array[1] = mbThread;
3276
3277 array[2] = filterGetByG_NotC_PrevAndNext(session, mbThread,
3278 groupId, categoryId, orderByComparator, false);
3279
3280 return array;
3281 }
3282 catch (Exception e) {
3283 throw processException(e);
3284 }
3285 finally {
3286 closeSession(session);
3287 }
3288 }
3289
3290 protected MBThread filterGetByG_NotC_PrevAndNext(Session session,
3291 MBThread mbThread, long groupId, long categoryId,
3292 OrderByComparator orderByComparator, boolean previous) {
3293 StringBundler query = null;
3294
3295 if (orderByComparator != null) {
3296 query = new StringBundler(6 +
3297 (orderByComparator.getOrderByFields().length * 6));
3298 }
3299 else {
3300 query = new StringBundler(3);
3301 }
3302
3303 if (getDB().isSupportsInlineDistinct()) {
3304 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3305 }
3306 else {
3307 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3308 }
3309
3310 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
3311
3312 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
3313
3314 if (!getDB().isSupportsInlineDistinct()) {
3315 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3316 }
3317
3318 if (orderByComparator != null) {
3319 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3320
3321 if (orderByConditionFields.length > 0) {
3322 query.append(WHERE_AND);
3323 }
3324
3325 for (int i = 0; i < orderByConditionFields.length; i++) {
3326 if (getDB().isSupportsInlineDistinct()) {
3327 query.append(_ORDER_BY_ENTITY_ALIAS);
3328 }
3329 else {
3330 query.append(_ORDER_BY_ENTITY_TABLE);
3331 }
3332
3333 query.append(orderByConditionFields[i]);
3334
3335 if ((i + 1) < orderByConditionFields.length) {
3336 if (orderByComparator.isAscending() ^ previous) {
3337 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3338 }
3339 else {
3340 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3341 }
3342 }
3343 else {
3344 if (orderByComparator.isAscending() ^ previous) {
3345 query.append(WHERE_GREATER_THAN);
3346 }
3347 else {
3348 query.append(WHERE_LESSER_THAN);
3349 }
3350 }
3351 }
3352
3353 query.append(ORDER_BY_CLAUSE);
3354
3355 String[] orderByFields = orderByComparator.getOrderByFields();
3356
3357 for (int i = 0; i < orderByFields.length; i++) {
3358 if (getDB().isSupportsInlineDistinct()) {
3359 query.append(_ORDER_BY_ENTITY_ALIAS);
3360 }
3361 else {
3362 query.append(_ORDER_BY_ENTITY_TABLE);
3363 }
3364
3365 query.append(orderByFields[i]);
3366
3367 if ((i + 1) < orderByFields.length) {
3368 if (orderByComparator.isAscending() ^ previous) {
3369 query.append(ORDER_BY_ASC_HAS_NEXT);
3370 }
3371 else {
3372 query.append(ORDER_BY_DESC_HAS_NEXT);
3373 }
3374 }
3375 else {
3376 if (orderByComparator.isAscending() ^ previous) {
3377 query.append(ORDER_BY_ASC);
3378 }
3379 else {
3380 query.append(ORDER_BY_DESC);
3381 }
3382 }
3383 }
3384 }
3385
3386 else {
3387 if (getDB().isSupportsInlineDistinct()) {
3388 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3389 }
3390 else {
3391 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3392 }
3393 }
3394
3395 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3396 MBThread.class.getName(),
3397 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3398
3399 SQLQuery q = session.createSQLQuery(sql);
3400
3401 q.setFirstResult(0);
3402 q.setMaxResults(2);
3403
3404 if (getDB().isSupportsInlineDistinct()) {
3405 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3406 }
3407 else {
3408 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3409 }
3410
3411 QueryPos qPos = QueryPos.getInstance(q);
3412
3413 qPos.add(groupId);
3414
3415 qPos.add(categoryId);
3416
3417 if (orderByComparator != null) {
3418 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3419
3420 for (Object value : values) {
3421 qPos.add(value);
3422 }
3423 }
3424
3425 List<MBThread> list = q.list();
3426
3427 if (list.size() == 2) {
3428 return list.get(1);
3429 }
3430 else {
3431 return null;
3432 }
3433 }
3434
3435
3443 public List<MBThread> findByG_S(long groupId, int status)
3444 throws SystemException {
3445 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3446 null);
3447 }
3448
3449
3463 public List<MBThread> findByG_S(long groupId, int status, int start, int end)
3464 throws SystemException {
3465 return findByG_S(groupId, status, start, end, null);
3466 }
3467
3468
3483 public List<MBThread> findByG_S(long groupId, int status, int start,
3484 int end, OrderByComparator orderByComparator) throws SystemException {
3485 FinderPath finderPath = null;
3486 Object[] finderArgs = null;
3487
3488 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3489 (orderByComparator == null)) {
3490 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
3491 finderArgs = new Object[] { groupId, status };
3492 }
3493 else {
3494 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
3495 finderArgs = new Object[] {
3496 groupId, status,
3497
3498 start, end, orderByComparator
3499 };
3500 }
3501
3502 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
3503 finderArgs, this);
3504
3505 if ((list != null) && !list.isEmpty()) {
3506 for (MBThread mbThread : list) {
3507 if ((groupId != mbThread.getGroupId()) ||
3508 (status != mbThread.getStatus())) {
3509 list = null;
3510
3511 break;
3512 }
3513 }
3514 }
3515
3516 if (list == null) {
3517 StringBundler query = null;
3518
3519 if (orderByComparator != null) {
3520 query = new StringBundler(4 +
3521 (orderByComparator.getOrderByFields().length * 3));
3522 }
3523 else {
3524 query = new StringBundler(4);
3525 }
3526
3527 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3528
3529 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3530
3531 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3532
3533 if (orderByComparator != null) {
3534 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3535 orderByComparator);
3536 }
3537
3538 else {
3539 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3540 }
3541
3542 String sql = query.toString();
3543
3544 Session session = null;
3545
3546 try {
3547 session = openSession();
3548
3549 Query q = session.createQuery(sql);
3550
3551 QueryPos qPos = QueryPos.getInstance(q);
3552
3553 qPos.add(groupId);
3554
3555 qPos.add(status);
3556
3557 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
3558 end);
3559 }
3560 catch (Exception e) {
3561 throw processException(e);
3562 }
3563 finally {
3564 if (list == null) {
3565 FinderCacheUtil.removeResult(finderPath, finderArgs);
3566 }
3567 else {
3568 cacheResult(list);
3569
3570 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3571 }
3572
3573 closeSession(session);
3574 }
3575 }
3576
3577 return list;
3578 }
3579
3580
3590 public MBThread findByG_S_First(long groupId, int status,
3591 OrderByComparator orderByComparator)
3592 throws NoSuchThreadException, SystemException {
3593 MBThread mbThread = fetchByG_S_First(groupId, status, orderByComparator);
3594
3595 if (mbThread != null) {
3596 return mbThread;
3597 }
3598
3599 StringBundler msg = new StringBundler(6);
3600
3601 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3602
3603 msg.append("groupId=");
3604 msg.append(groupId);
3605
3606 msg.append(", status=");
3607 msg.append(status);
3608
3609 msg.append(StringPool.CLOSE_CURLY_BRACE);
3610
3611 throw new NoSuchThreadException(msg.toString());
3612 }
3613
3614
3623 public MBThread fetchByG_S_First(long groupId, int status,
3624 OrderByComparator orderByComparator) throws SystemException {
3625 List<MBThread> list = findByG_S(groupId, status, 0, 1, orderByComparator);
3626
3627 if (!list.isEmpty()) {
3628 return list.get(0);
3629 }
3630
3631 return null;
3632 }
3633
3634
3644 public MBThread findByG_S_Last(long groupId, int status,
3645 OrderByComparator orderByComparator)
3646 throws NoSuchThreadException, SystemException {
3647 MBThread mbThread = fetchByG_S_Last(groupId, status, orderByComparator);
3648
3649 if (mbThread != null) {
3650 return mbThread;
3651 }
3652
3653 StringBundler msg = new StringBundler(6);
3654
3655 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3656
3657 msg.append("groupId=");
3658 msg.append(groupId);
3659
3660 msg.append(", status=");
3661 msg.append(status);
3662
3663 msg.append(StringPool.CLOSE_CURLY_BRACE);
3664
3665 throw new NoSuchThreadException(msg.toString());
3666 }
3667
3668
3677 public MBThread fetchByG_S_Last(long groupId, int status,
3678 OrderByComparator orderByComparator) throws SystemException {
3679 int count = countByG_S(groupId, status);
3680
3681 List<MBThread> list = findByG_S(groupId, status, count - 1, count,
3682 orderByComparator);
3683
3684 if (!list.isEmpty()) {
3685 return list.get(0);
3686 }
3687
3688 return null;
3689 }
3690
3691
3702 public MBThread[] findByG_S_PrevAndNext(long threadId, long groupId,
3703 int status, OrderByComparator orderByComparator)
3704 throws NoSuchThreadException, SystemException {
3705 MBThread mbThread = findByPrimaryKey(threadId);
3706
3707 Session session = null;
3708
3709 try {
3710 session = openSession();
3711
3712 MBThread[] array = new MBThreadImpl[3];
3713
3714 array[0] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
3715 orderByComparator, true);
3716
3717 array[1] = mbThread;
3718
3719 array[2] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
3720 orderByComparator, false);
3721
3722 return array;
3723 }
3724 catch (Exception e) {
3725 throw processException(e);
3726 }
3727 finally {
3728 closeSession(session);
3729 }
3730 }
3731
3732 protected MBThread getByG_S_PrevAndNext(Session session, MBThread mbThread,
3733 long groupId, int status, OrderByComparator orderByComparator,
3734 boolean previous) {
3735 StringBundler query = null;
3736
3737 if (orderByComparator != null) {
3738 query = new StringBundler(6 +
3739 (orderByComparator.getOrderByFields().length * 6));
3740 }
3741 else {
3742 query = new StringBundler(3);
3743 }
3744
3745 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3746
3747 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3748
3749 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3750
3751 if (orderByComparator != null) {
3752 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3753
3754 if (orderByConditionFields.length > 0) {
3755 query.append(WHERE_AND);
3756 }
3757
3758 for (int i = 0; i < orderByConditionFields.length; i++) {
3759 query.append(_ORDER_BY_ENTITY_ALIAS);
3760 query.append(orderByConditionFields[i]);
3761
3762 if ((i + 1) < orderByConditionFields.length) {
3763 if (orderByComparator.isAscending() ^ previous) {
3764 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3765 }
3766 else {
3767 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3768 }
3769 }
3770 else {
3771 if (orderByComparator.isAscending() ^ previous) {
3772 query.append(WHERE_GREATER_THAN);
3773 }
3774 else {
3775 query.append(WHERE_LESSER_THAN);
3776 }
3777 }
3778 }
3779
3780 query.append(ORDER_BY_CLAUSE);
3781
3782 String[] orderByFields = orderByComparator.getOrderByFields();
3783
3784 for (int i = 0; i < orderByFields.length; i++) {
3785 query.append(_ORDER_BY_ENTITY_ALIAS);
3786 query.append(orderByFields[i]);
3787
3788 if ((i + 1) < orderByFields.length) {
3789 if (orderByComparator.isAscending() ^ previous) {
3790 query.append(ORDER_BY_ASC_HAS_NEXT);
3791 }
3792 else {
3793 query.append(ORDER_BY_DESC_HAS_NEXT);
3794 }
3795 }
3796 else {
3797 if (orderByComparator.isAscending() ^ previous) {
3798 query.append(ORDER_BY_ASC);
3799 }
3800 else {
3801 query.append(ORDER_BY_DESC);
3802 }
3803 }
3804 }
3805 }
3806
3807 else {
3808 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3809 }
3810
3811 String sql = query.toString();
3812
3813 Query q = session.createQuery(sql);
3814
3815 q.setFirstResult(0);
3816 q.setMaxResults(2);
3817
3818 QueryPos qPos = QueryPos.getInstance(q);
3819
3820 qPos.add(groupId);
3821
3822 qPos.add(status);
3823
3824 if (orderByComparator != null) {
3825 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3826
3827 for (Object value : values) {
3828 qPos.add(value);
3829 }
3830 }
3831
3832 List<MBThread> list = q.list();
3833
3834 if (list.size() == 2) {
3835 return list.get(1);
3836 }
3837 else {
3838 return null;
3839 }
3840 }
3841
3842
3850 public List<MBThread> filterFindByG_S(long groupId, int status)
3851 throws SystemException {
3852 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
3853 QueryUtil.ALL_POS, null);
3854 }
3855
3856
3870 public List<MBThread> filterFindByG_S(long groupId, int status, int start,
3871 int end) throws SystemException {
3872 return filterFindByG_S(groupId, status, start, end, null);
3873 }
3874
3875
3890 public List<MBThread> filterFindByG_S(long groupId, int status, int start,
3891 int end, OrderByComparator orderByComparator) throws SystemException {
3892 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3893 return findByG_S(groupId, status, start, end, orderByComparator);
3894 }
3895
3896 StringBundler query = null;
3897
3898 if (orderByComparator != null) {
3899 query = new StringBundler(4 +
3900 (orderByComparator.getOrderByFields().length * 3));
3901 }
3902 else {
3903 query = new StringBundler(4);
3904 }
3905
3906 if (getDB().isSupportsInlineDistinct()) {
3907 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3908 }
3909 else {
3910 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3911 }
3912
3913 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3914
3915 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3916
3917 if (!getDB().isSupportsInlineDistinct()) {
3918 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3919 }
3920
3921 if (orderByComparator != null) {
3922 if (getDB().isSupportsInlineDistinct()) {
3923 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3924 orderByComparator);
3925 }
3926 else {
3927 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3928 orderByComparator);
3929 }
3930 }
3931
3932 else {
3933 if (getDB().isSupportsInlineDistinct()) {
3934 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3935 }
3936 else {
3937 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3938 }
3939 }
3940
3941 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3942 MBThread.class.getName(),
3943 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3944
3945 Session session = null;
3946
3947 try {
3948 session = openSession();
3949
3950 SQLQuery q = session.createSQLQuery(sql);
3951
3952 if (getDB().isSupportsInlineDistinct()) {
3953 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3954 }
3955 else {
3956 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3957 }
3958
3959 QueryPos qPos = QueryPos.getInstance(q);
3960
3961 qPos.add(groupId);
3962
3963 qPos.add(status);
3964
3965 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
3966 }
3967 catch (Exception e) {
3968 throw processException(e);
3969 }
3970 finally {
3971 closeSession(session);
3972 }
3973 }
3974
3975
3986 public MBThread[] filterFindByG_S_PrevAndNext(long threadId, long groupId,
3987 int status, OrderByComparator orderByComparator)
3988 throws NoSuchThreadException, SystemException {
3989 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3990 return findByG_S_PrevAndNext(threadId, groupId, status,
3991 orderByComparator);
3992 }
3993
3994 MBThread mbThread = findByPrimaryKey(threadId);
3995
3996 Session session = null;
3997
3998 try {
3999 session = openSession();
4000
4001 MBThread[] array = new MBThreadImpl[3];
4002
4003 array[0] = filterGetByG_S_PrevAndNext(session, mbThread, groupId,
4004 status, orderByComparator, true);
4005
4006 array[1] = mbThread;
4007
4008 array[2] = filterGetByG_S_PrevAndNext(session, mbThread, groupId,
4009 status, orderByComparator, false);
4010
4011 return array;
4012 }
4013 catch (Exception e) {
4014 throw processException(e);
4015 }
4016 finally {
4017 closeSession(session);
4018 }
4019 }
4020
4021 protected MBThread filterGetByG_S_PrevAndNext(Session session,
4022 MBThread mbThread, long groupId, int status,
4023 OrderByComparator orderByComparator, boolean previous) {
4024 StringBundler query = null;
4025
4026 if (orderByComparator != null) {
4027 query = new StringBundler(6 +
4028 (orderByComparator.getOrderByFields().length * 6));
4029 }
4030 else {
4031 query = new StringBundler(3);
4032 }
4033
4034 if (getDB().isSupportsInlineDistinct()) {
4035 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
4036 }
4037 else {
4038 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
4039 }
4040
4041 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4042
4043 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4044
4045 if (!getDB().isSupportsInlineDistinct()) {
4046 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
4047 }
4048
4049 if (orderByComparator != null) {
4050 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4051
4052 if (orderByConditionFields.length > 0) {
4053 query.append(WHERE_AND);
4054 }
4055
4056 for (int i = 0; i < orderByConditionFields.length; i++) {
4057 if (getDB().isSupportsInlineDistinct()) {
4058 query.append(_ORDER_BY_ENTITY_ALIAS);
4059 }
4060 else {
4061 query.append(_ORDER_BY_ENTITY_TABLE);
4062 }
4063
4064 query.append(orderByConditionFields[i]);
4065
4066 if ((i + 1) < orderByConditionFields.length) {
4067 if (orderByComparator.isAscending() ^ previous) {
4068 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4069 }
4070 else {
4071 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4072 }
4073 }
4074 else {
4075 if (orderByComparator.isAscending() ^ previous) {
4076 query.append(WHERE_GREATER_THAN);
4077 }
4078 else {
4079 query.append(WHERE_LESSER_THAN);
4080 }
4081 }
4082 }
4083
4084 query.append(ORDER_BY_CLAUSE);
4085
4086 String[] orderByFields = orderByComparator.getOrderByFields();
4087
4088 for (int i = 0; i < orderByFields.length; i++) {
4089 if (getDB().isSupportsInlineDistinct()) {
4090 query.append(_ORDER_BY_ENTITY_ALIAS);
4091 }
4092 else {
4093 query.append(_ORDER_BY_ENTITY_TABLE);
4094 }
4095
4096 query.append(orderByFields[i]);
4097
4098 if ((i + 1) < orderByFields.length) {
4099 if (orderByComparator.isAscending() ^ previous) {
4100 query.append(ORDER_BY_ASC_HAS_NEXT);
4101 }
4102 else {
4103 query.append(ORDER_BY_DESC_HAS_NEXT);
4104 }
4105 }
4106 else {
4107 if (orderByComparator.isAscending() ^ previous) {
4108 query.append(ORDER_BY_ASC);
4109 }
4110 else {
4111 query.append(ORDER_BY_DESC);
4112 }
4113 }
4114 }
4115 }
4116
4117 else {
4118 if (getDB().isSupportsInlineDistinct()) {
4119 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4120 }
4121 else {
4122 query.append(MBThreadModelImpl.ORDER_BY_SQL);
4123 }
4124 }
4125
4126 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4127 MBThread.class.getName(),
4128 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4129
4130 SQLQuery q = session.createSQLQuery(sql);
4131
4132 q.setFirstResult(0);
4133 q.setMaxResults(2);
4134
4135 if (getDB().isSupportsInlineDistinct()) {
4136 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
4137 }
4138 else {
4139 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
4140 }
4141
4142 QueryPos qPos = QueryPos.getInstance(q);
4143
4144 qPos.add(groupId);
4145
4146 qPos.add(status);
4147
4148 if (orderByComparator != null) {
4149 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4150
4151 for (Object value : values) {
4152 qPos.add(value);
4153 }
4154 }
4155
4156 List<MBThread> list = q.list();
4157
4158 if (list.size() == 2) {
4159 return list.get(1);
4160 }
4161 else {
4162 return null;
4163 }
4164 }
4165
4166
4174 public List<MBThread> findByC_P(long categoryId, double priority)
4175 throws SystemException {
4176 return findByC_P(categoryId, priority, QueryUtil.ALL_POS,
4177 QueryUtil.ALL_POS, null);
4178 }
4179
4180
4194 public List<MBThread> findByC_P(long categoryId, double priority,
4195 int start, int end) throws SystemException {
4196 return findByC_P(categoryId, priority, start, end, null);
4197 }
4198
4199
4214 public List<MBThread> findByC_P(long categoryId, double priority,
4215 int start, int end, OrderByComparator orderByComparator)
4216 throws SystemException {
4217 FinderPath finderPath = null;
4218 Object[] finderArgs = null;
4219
4220 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4221 (orderByComparator == null)) {
4222 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
4223 finderArgs = new Object[] { categoryId, priority };
4224 }
4225 else {
4226 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
4227 finderArgs = new Object[] {
4228 categoryId, priority,
4229
4230 start, end, orderByComparator
4231 };
4232 }
4233
4234 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
4235 finderArgs, this);
4236
4237 if ((list != null) && !list.isEmpty()) {
4238 for (MBThread mbThread : list) {
4239 if ((categoryId != mbThread.getCategoryId()) ||
4240 (priority != mbThread.getPriority())) {
4241 list = null;
4242
4243 break;
4244 }
4245 }
4246 }
4247
4248 if (list == null) {
4249 StringBundler query = null;
4250
4251 if (orderByComparator != null) {
4252 query = new StringBundler(4 +
4253 (orderByComparator.getOrderByFields().length * 3));
4254 }
4255 else {
4256 query = new StringBundler(4);
4257 }
4258
4259 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4260
4261 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
4262
4263 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
4264
4265 if (orderByComparator != null) {
4266 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4267 orderByComparator);
4268 }
4269
4270 else {
4271 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4272 }
4273
4274 String sql = query.toString();
4275
4276 Session session = null;
4277
4278 try {
4279 session = openSession();
4280
4281 Query q = session.createQuery(sql);
4282
4283 QueryPos qPos = QueryPos.getInstance(q);
4284
4285 qPos.add(categoryId);
4286
4287 qPos.add(priority);
4288
4289 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
4290 end);
4291 }
4292 catch (Exception e) {
4293 throw processException(e);
4294 }
4295 finally {
4296 if (list == null) {
4297 FinderCacheUtil.removeResult(finderPath, finderArgs);
4298 }
4299 else {
4300 cacheResult(list);
4301
4302 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4303 }
4304
4305 closeSession(session);
4306 }
4307 }
4308
4309 return list;
4310 }
4311
4312
4322 public MBThread findByC_P_First(long categoryId, double priority,
4323 OrderByComparator orderByComparator)
4324 throws NoSuchThreadException, SystemException {
4325 MBThread mbThread = fetchByC_P_First(categoryId, priority,
4326 orderByComparator);
4327
4328 if (mbThread != null) {
4329 return mbThread;
4330 }
4331
4332 StringBundler msg = new StringBundler(6);
4333
4334 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4335
4336 msg.append("categoryId=");
4337 msg.append(categoryId);
4338
4339 msg.append(", priority=");
4340 msg.append(priority);
4341
4342 msg.append(StringPool.CLOSE_CURLY_BRACE);
4343
4344 throw new NoSuchThreadException(msg.toString());
4345 }
4346
4347
4356 public MBThread fetchByC_P_First(long categoryId, double priority,
4357 OrderByComparator orderByComparator) throws SystemException {
4358 List<MBThread> list = findByC_P(categoryId, priority, 0, 1,
4359 orderByComparator);
4360
4361 if (!list.isEmpty()) {
4362 return list.get(0);
4363 }
4364
4365 return null;
4366 }
4367
4368
4378 public MBThread findByC_P_Last(long categoryId, double priority,
4379 OrderByComparator orderByComparator)
4380 throws NoSuchThreadException, SystemException {
4381 MBThread mbThread = fetchByC_P_Last(categoryId, priority,
4382 orderByComparator);
4383
4384 if (mbThread != null) {
4385 return mbThread;
4386 }
4387
4388 StringBundler msg = new StringBundler(6);
4389
4390 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4391
4392 msg.append("categoryId=");
4393 msg.append(categoryId);
4394
4395 msg.append(", priority=");
4396 msg.append(priority);
4397
4398 msg.append(StringPool.CLOSE_CURLY_BRACE);
4399
4400 throw new NoSuchThreadException(msg.toString());
4401 }
4402
4403
4412 public MBThread fetchByC_P_Last(long categoryId, double priority,
4413 OrderByComparator orderByComparator) throws SystemException {
4414 int count = countByC_P(categoryId, priority);
4415
4416 List<MBThread> list = findByC_P(categoryId, priority, count - 1, count,
4417 orderByComparator);
4418
4419 if (!list.isEmpty()) {
4420 return list.get(0);
4421 }
4422
4423 return null;
4424 }
4425
4426
4437 public MBThread[] findByC_P_PrevAndNext(long threadId, long categoryId,
4438 double priority, OrderByComparator orderByComparator)
4439 throws NoSuchThreadException, SystemException {
4440 MBThread mbThread = findByPrimaryKey(threadId);
4441
4442 Session session = null;
4443
4444 try {
4445 session = openSession();
4446
4447 MBThread[] array = new MBThreadImpl[3];
4448
4449 array[0] = getByC_P_PrevAndNext(session, mbThread, categoryId,
4450 priority, orderByComparator, true);
4451
4452 array[1] = mbThread;
4453
4454 array[2] = getByC_P_PrevAndNext(session, mbThread, categoryId,
4455 priority, orderByComparator, false);
4456
4457 return array;
4458 }
4459 catch (Exception e) {
4460 throw processException(e);
4461 }
4462 finally {
4463 closeSession(session);
4464 }
4465 }
4466
4467 protected MBThread getByC_P_PrevAndNext(Session session, MBThread mbThread,
4468 long categoryId, double priority, OrderByComparator orderByComparator,
4469 boolean previous) {
4470 StringBundler query = null;
4471
4472 if (orderByComparator != null) {
4473 query = new StringBundler(6 +
4474 (orderByComparator.getOrderByFields().length * 6));
4475 }
4476 else {
4477 query = new StringBundler(3);
4478 }
4479
4480 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4481
4482 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
4483
4484 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
4485
4486 if (orderByComparator != null) {
4487 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4488
4489 if (orderByConditionFields.length > 0) {
4490 query.append(WHERE_AND);
4491 }
4492
4493 for (int i = 0; i < orderByConditionFields.length; i++) {
4494 query.append(_ORDER_BY_ENTITY_ALIAS);
4495 query.append(orderByConditionFields[i]);
4496
4497 if ((i + 1) < orderByConditionFields.length) {
4498 if (orderByComparator.isAscending() ^ previous) {
4499 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4500 }
4501 else {
4502 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4503 }
4504 }
4505 else {
4506 if (orderByComparator.isAscending() ^ previous) {
4507 query.append(WHERE_GREATER_THAN);
4508 }
4509 else {
4510 query.append(WHERE_LESSER_THAN);
4511 }
4512 }
4513 }
4514
4515 query.append(ORDER_BY_CLAUSE);
4516
4517 String[] orderByFields = orderByComparator.getOrderByFields();
4518
4519 for (int i = 0; i < orderByFields.length; i++) {
4520 query.append(_ORDER_BY_ENTITY_ALIAS);
4521 query.append(orderByFields[i]);
4522
4523 if ((i + 1) < orderByFields.length) {
4524 if (orderByComparator.isAscending() ^ previous) {
4525 query.append(ORDER_BY_ASC_HAS_NEXT);
4526 }
4527 else {
4528 query.append(ORDER_BY_DESC_HAS_NEXT);
4529 }
4530 }
4531 else {
4532 if (orderByComparator.isAscending() ^ previous) {
4533 query.append(ORDER_BY_ASC);
4534 }
4535 else {
4536 query.append(ORDER_BY_DESC);
4537 }
4538 }
4539 }
4540 }
4541
4542 else {
4543 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4544 }
4545
4546 String sql = query.toString();
4547
4548 Query q = session.createQuery(sql);
4549
4550 q.setFirstResult(0);
4551 q.setMaxResults(2);
4552
4553 QueryPos qPos = QueryPos.getInstance(q);
4554
4555 qPos.add(categoryId);
4556
4557 qPos.add(priority);
4558
4559 if (orderByComparator != null) {
4560 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4561
4562 for (Object value : values) {
4563 qPos.add(value);
4564 }
4565 }
4566
4567 List<MBThread> list = q.list();
4568
4569 if (list.size() == 2) {
4570 return list.get(1);
4571 }
4572 else {
4573 return null;
4574 }
4575 }
4576
4577
4585 public List<MBThread> findByL_P(Date lastPostDate, double priority)
4586 throws SystemException {
4587 return findByL_P(lastPostDate, priority, QueryUtil.ALL_POS,
4588 QueryUtil.ALL_POS, null);
4589 }
4590
4591
4605 public List<MBThread> findByL_P(Date lastPostDate, double priority,
4606 int start, int end) throws SystemException {
4607 return findByL_P(lastPostDate, priority, start, end, null);
4608 }
4609
4610
4625 public List<MBThread> findByL_P(Date lastPostDate, double priority,
4626 int start, int end, OrderByComparator orderByComparator)
4627 throws SystemException {
4628 FinderPath finderPath = null;
4629 Object[] finderArgs = null;
4630
4631 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4632 (orderByComparator == null)) {
4633 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
4634 finderArgs = new Object[] { lastPostDate, priority };
4635 }
4636 else {
4637 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
4638 finderArgs = new Object[] {
4639 lastPostDate, priority,
4640
4641 start, end, orderByComparator
4642 };
4643 }
4644
4645 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
4646 finderArgs, this);
4647
4648 if ((list != null) && !list.isEmpty()) {
4649 for (MBThread mbThread : list) {
4650 if (!Validator.equals(lastPostDate, mbThread.getLastPostDate()) ||
4651 (priority != mbThread.getPriority())) {
4652 list = null;
4653
4654 break;
4655 }
4656 }
4657 }
4658
4659 if (list == null) {
4660 StringBundler query = null;
4661
4662 if (orderByComparator != null) {
4663 query = new StringBundler(4 +
4664 (orderByComparator.getOrderByFields().length * 3));
4665 }
4666 else {
4667 query = new StringBundler(4);
4668 }
4669
4670 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4671
4672 if (lastPostDate == null) {
4673 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
4674 }
4675 else {
4676 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
4677 }
4678
4679 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
4680
4681 if (orderByComparator != null) {
4682 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4683 orderByComparator);
4684 }
4685
4686 else {
4687 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4688 }
4689
4690 String sql = query.toString();
4691
4692 Session session = null;
4693
4694 try {
4695 session = openSession();
4696
4697 Query q = session.createQuery(sql);
4698
4699 QueryPos qPos = QueryPos.getInstance(q);
4700
4701 if (lastPostDate != null) {
4702 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
4703 }
4704
4705 qPos.add(priority);
4706
4707 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
4708 end);
4709 }
4710 catch (Exception e) {
4711 throw processException(e);
4712 }
4713 finally {
4714 if (list == null) {
4715 FinderCacheUtil.removeResult(finderPath, finderArgs);
4716 }
4717 else {
4718 cacheResult(list);
4719
4720 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4721 }
4722
4723 closeSession(session);
4724 }
4725 }
4726
4727 return list;
4728 }
4729
4730
4740 public MBThread findByL_P_First(Date lastPostDate, double priority,
4741 OrderByComparator orderByComparator)
4742 throws NoSuchThreadException, SystemException {
4743 MBThread mbThread = fetchByL_P_First(lastPostDate, priority,
4744 orderByComparator);
4745
4746 if (mbThread != null) {
4747 return mbThread;
4748 }
4749
4750 StringBundler msg = new StringBundler(6);
4751
4752 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4753
4754 msg.append("lastPostDate=");
4755 msg.append(lastPostDate);
4756
4757 msg.append(", priority=");
4758 msg.append(priority);
4759
4760 msg.append(StringPool.CLOSE_CURLY_BRACE);
4761
4762 throw new NoSuchThreadException(msg.toString());
4763 }
4764
4765
4774 public MBThread fetchByL_P_First(Date lastPostDate, double priority,
4775 OrderByComparator orderByComparator) throws SystemException {
4776 List<MBThread> list = findByL_P(lastPostDate, priority, 0, 1,
4777 orderByComparator);
4778
4779 if (!list.isEmpty()) {
4780 return list.get(0);
4781 }
4782
4783 return null;
4784 }
4785
4786
4796 public MBThread findByL_P_Last(Date lastPostDate, double priority,
4797 OrderByComparator orderByComparator)
4798 throws NoSuchThreadException, SystemException {
4799 MBThread mbThread = fetchByL_P_Last(lastPostDate, priority,
4800 orderByComparator);
4801
4802 if (mbThread != null) {
4803 return mbThread;
4804 }
4805
4806 StringBundler msg = new StringBundler(6);
4807
4808 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4809
4810 msg.append("lastPostDate=");
4811 msg.append(lastPostDate);
4812
4813 msg.append(", priority=");
4814 msg.append(priority);
4815
4816 msg.append(StringPool.CLOSE_CURLY_BRACE);
4817
4818 throw new NoSuchThreadException(msg.toString());
4819 }
4820
4821
4830 public MBThread fetchByL_P_Last(Date lastPostDate, double priority,
4831 OrderByComparator orderByComparator) throws SystemException {
4832 int count = countByL_P(lastPostDate, priority);
4833
4834 List<MBThread> list = findByL_P(lastPostDate, priority, count - 1,
4835 count, orderByComparator);
4836
4837 if (!list.isEmpty()) {
4838 return list.get(0);
4839 }
4840
4841 return null;
4842 }
4843
4844
4855 public MBThread[] findByL_P_PrevAndNext(long threadId, Date lastPostDate,
4856 double priority, OrderByComparator orderByComparator)
4857 throws NoSuchThreadException, SystemException {
4858 MBThread mbThread = findByPrimaryKey(threadId);
4859
4860 Session session = null;
4861
4862 try {
4863 session = openSession();
4864
4865 MBThread[] array = new MBThreadImpl[3];
4866
4867 array[0] = getByL_P_PrevAndNext(session, mbThread, lastPostDate,
4868 priority, orderByComparator, true);
4869
4870 array[1] = mbThread;
4871
4872 array[2] = getByL_P_PrevAndNext(session, mbThread, lastPostDate,
4873 priority, orderByComparator, false);
4874
4875 return array;
4876 }
4877 catch (Exception e) {
4878 throw processException(e);
4879 }
4880 finally {
4881 closeSession(session);
4882 }
4883 }
4884
4885 protected MBThread getByL_P_PrevAndNext(Session session, MBThread mbThread,
4886 Date lastPostDate, double priority,
4887 OrderByComparator orderByComparator, boolean previous) {
4888 StringBundler query = null;
4889
4890 if (orderByComparator != null) {
4891 query = new StringBundler(6 +
4892 (orderByComparator.getOrderByFields().length * 6));
4893 }
4894 else {
4895 query = new StringBundler(3);
4896 }
4897
4898 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4899
4900 if (lastPostDate == null) {
4901 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
4902 }
4903 else {
4904 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
4905 }
4906
4907 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
4908
4909 if (orderByComparator != null) {
4910 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4911
4912 if (orderByConditionFields.length > 0) {
4913 query.append(WHERE_AND);
4914 }
4915
4916 for (int i = 0; i < orderByConditionFields.length; i++) {
4917 query.append(_ORDER_BY_ENTITY_ALIAS);
4918 query.append(orderByConditionFields[i]);
4919
4920 if ((i + 1) < orderByConditionFields.length) {
4921 if (orderByComparator.isAscending() ^ previous) {
4922 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4923 }
4924 else {
4925 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4926 }
4927 }
4928 else {
4929 if (orderByComparator.isAscending() ^ previous) {
4930 query.append(WHERE_GREATER_THAN);
4931 }
4932 else {
4933 query.append(WHERE_LESSER_THAN);
4934 }
4935 }
4936 }
4937
4938 query.append(ORDER_BY_CLAUSE);
4939
4940 String[] orderByFields = orderByComparator.getOrderByFields();
4941
4942 for (int i = 0; i < orderByFields.length; i++) {
4943 query.append(_ORDER_BY_ENTITY_ALIAS);
4944 query.append(orderByFields[i]);
4945
4946 if ((i + 1) < orderByFields.length) {
4947 if (orderByComparator.isAscending() ^ previous) {
4948 query.append(ORDER_BY_ASC_HAS_NEXT);
4949 }
4950 else {
4951 query.append(ORDER_BY_DESC_HAS_NEXT);
4952 }
4953 }
4954 else {
4955 if (orderByComparator.isAscending() ^ previous) {
4956 query.append(ORDER_BY_ASC);
4957 }
4958 else {
4959 query.append(ORDER_BY_DESC);
4960 }
4961 }
4962 }
4963 }
4964
4965 else {
4966 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4967 }
4968
4969 String sql = query.toString();
4970
4971 Query q = session.createQuery(sql);
4972
4973 q.setFirstResult(0);
4974 q.setMaxResults(2);
4975
4976 QueryPos qPos = QueryPos.getInstance(q);
4977
4978 if (lastPostDate != null) {
4979 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
4980 }
4981
4982 qPos.add(priority);
4983
4984 if (orderByComparator != null) {
4985 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4986
4987 for (Object value : values) {
4988 qPos.add(value);
4989 }
4990 }
4991
4992 List<MBThread> list = q.list();
4993
4994 if (list.size() == 2) {
4995 return list.get(1);
4996 }
4997 else {
4998 return null;
4999 }
5000 }
5001
5002
5011 public List<MBThread> findByG_C_L(long groupId, long categoryId,
5012 Date lastPostDate) throws SystemException {
5013 return findByG_C_L(groupId, categoryId, lastPostDate,
5014 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5015 }
5016
5017
5032 public List<MBThread> findByG_C_L(long groupId, long categoryId,
5033 Date lastPostDate, int start, int end) throws SystemException {
5034 return findByG_C_L(groupId, categoryId, lastPostDate, start, end, null);
5035 }
5036
5037
5053 public List<MBThread> findByG_C_L(long groupId, long categoryId,
5054 Date lastPostDate, int start, int end,
5055 OrderByComparator orderByComparator) throws SystemException {
5056 FinderPath finderPath = null;
5057 Object[] finderArgs = null;
5058
5059 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5060 (orderByComparator == null)) {
5061 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
5062 finderArgs = new Object[] { groupId, categoryId, lastPostDate };
5063 }
5064 else {
5065 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
5066 finderArgs = new Object[] {
5067 groupId, categoryId, lastPostDate,
5068
5069 start, end, orderByComparator
5070 };
5071 }
5072
5073 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
5074 finderArgs, this);
5075
5076 if ((list != null) && !list.isEmpty()) {
5077 for (MBThread mbThread : list) {
5078 if ((groupId != mbThread.getGroupId()) ||
5079 (categoryId != mbThread.getCategoryId()) ||
5080 !Validator.equals(lastPostDate,
5081 mbThread.getLastPostDate())) {
5082 list = null;
5083
5084 break;
5085 }
5086 }
5087 }
5088
5089 if (list == null) {
5090 StringBundler query = null;
5091
5092 if (orderByComparator != null) {
5093 query = new StringBundler(5 +
5094 (orderByComparator.getOrderByFields().length * 3));
5095 }
5096 else {
5097 query = new StringBundler(5);
5098 }
5099
5100 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5101
5102 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
5103
5104 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
5105
5106 if (lastPostDate == null) {
5107 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
5108 }
5109 else {
5110 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
5111 }
5112
5113 if (orderByComparator != null) {
5114 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5115 orderByComparator);
5116 }
5117
5118 else {
5119 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5120 }
5121
5122 String sql = query.toString();
5123
5124 Session session = null;
5125
5126 try {
5127 session = openSession();
5128
5129 Query q = session.createQuery(sql);
5130
5131 QueryPos qPos = QueryPos.getInstance(q);
5132
5133 qPos.add(groupId);
5134
5135 qPos.add(categoryId);
5136
5137 if (lastPostDate != null) {
5138 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5139 }
5140
5141 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
5142 end);
5143 }
5144 catch (Exception e) {
5145 throw processException(e);
5146 }
5147 finally {
5148 if (list == null) {
5149 FinderCacheUtil.removeResult(finderPath, finderArgs);
5150 }
5151 else {
5152 cacheResult(list);
5153
5154 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5155 }
5156
5157 closeSession(session);
5158 }
5159 }
5160
5161 return list;
5162 }
5163
5164
5175 public MBThread findByG_C_L_First(long groupId, long categoryId,
5176 Date lastPostDate, OrderByComparator orderByComparator)
5177 throws NoSuchThreadException, SystemException {
5178 MBThread mbThread = fetchByG_C_L_First(groupId, categoryId,
5179 lastPostDate, orderByComparator);
5180
5181 if (mbThread != null) {
5182 return mbThread;
5183 }
5184
5185 StringBundler msg = new StringBundler(8);
5186
5187 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5188
5189 msg.append("groupId=");
5190 msg.append(groupId);
5191
5192 msg.append(", categoryId=");
5193 msg.append(categoryId);
5194
5195 msg.append(", lastPostDate=");
5196 msg.append(lastPostDate);
5197
5198 msg.append(StringPool.CLOSE_CURLY_BRACE);
5199
5200 throw new NoSuchThreadException(msg.toString());
5201 }
5202
5203
5213 public MBThread fetchByG_C_L_First(long groupId, long categoryId,
5214 Date lastPostDate, OrderByComparator orderByComparator)
5215 throws SystemException {
5216 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate, 0,
5217 1, orderByComparator);
5218
5219 if (!list.isEmpty()) {
5220 return list.get(0);
5221 }
5222
5223 return null;
5224 }
5225
5226
5237 public MBThread findByG_C_L_Last(long groupId, long categoryId,
5238 Date lastPostDate, OrderByComparator orderByComparator)
5239 throws NoSuchThreadException, SystemException {
5240 MBThread mbThread = fetchByG_C_L_Last(groupId, categoryId,
5241 lastPostDate, orderByComparator);
5242
5243 if (mbThread != null) {
5244 return mbThread;
5245 }
5246
5247 StringBundler msg = new StringBundler(8);
5248
5249 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5250
5251 msg.append("groupId=");
5252 msg.append(groupId);
5253
5254 msg.append(", categoryId=");
5255 msg.append(categoryId);
5256
5257 msg.append(", lastPostDate=");
5258 msg.append(lastPostDate);
5259
5260 msg.append(StringPool.CLOSE_CURLY_BRACE);
5261
5262 throw new NoSuchThreadException(msg.toString());
5263 }
5264
5265
5275 public MBThread fetchByG_C_L_Last(long groupId, long categoryId,
5276 Date lastPostDate, OrderByComparator orderByComparator)
5277 throws SystemException {
5278 int count = countByG_C_L(groupId, categoryId, lastPostDate);
5279
5280 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate,
5281 count - 1, count, orderByComparator);
5282
5283 if (!list.isEmpty()) {
5284 return list.get(0);
5285 }
5286
5287 return null;
5288 }
5289
5290
5302 public MBThread[] findByG_C_L_PrevAndNext(long threadId, long groupId,
5303 long categoryId, Date lastPostDate, OrderByComparator orderByComparator)
5304 throws NoSuchThreadException, SystemException {
5305 MBThread mbThread = findByPrimaryKey(threadId);
5306
5307 Session session = null;
5308
5309 try {
5310 session = openSession();
5311
5312 MBThread[] array = new MBThreadImpl[3];
5313
5314 array[0] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
5315 categoryId, lastPostDate, orderByComparator, true);
5316
5317 array[1] = mbThread;
5318
5319 array[2] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
5320 categoryId, lastPostDate, orderByComparator, false);
5321
5322 return array;
5323 }
5324 catch (Exception e) {
5325 throw processException(e);
5326 }
5327 finally {
5328 closeSession(session);
5329 }
5330 }
5331
5332 protected MBThread getByG_C_L_PrevAndNext(Session session,
5333 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
5334 OrderByComparator orderByComparator, boolean previous) {
5335 StringBundler query = null;
5336
5337 if (orderByComparator != null) {
5338 query = new StringBundler(6 +
5339 (orderByComparator.getOrderByFields().length * 6));
5340 }
5341 else {
5342 query = new StringBundler(3);
5343 }
5344
5345 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5346
5347 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
5348
5349 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
5350
5351 if (lastPostDate == null) {
5352 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
5353 }
5354 else {
5355 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
5356 }
5357
5358 if (orderByComparator != null) {
5359 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5360
5361 if (orderByConditionFields.length > 0) {
5362 query.append(WHERE_AND);
5363 }
5364
5365 for (int i = 0; i < orderByConditionFields.length; i++) {
5366 query.append(_ORDER_BY_ENTITY_ALIAS);
5367 query.append(orderByConditionFields[i]);
5368
5369 if ((i + 1) < orderByConditionFields.length) {
5370 if (orderByComparator.isAscending() ^ previous) {
5371 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5372 }
5373 else {
5374 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5375 }
5376 }
5377 else {
5378 if (orderByComparator.isAscending() ^ previous) {
5379 query.append(WHERE_GREATER_THAN);
5380 }
5381 else {
5382 query.append(WHERE_LESSER_THAN);
5383 }
5384 }
5385 }
5386
5387 query.append(ORDER_BY_CLAUSE);
5388
5389 String[] orderByFields = orderByComparator.getOrderByFields();
5390
5391 for (int i = 0; i < orderByFields.length; i++) {
5392 query.append(_ORDER_BY_ENTITY_ALIAS);
5393 query.append(orderByFields[i]);
5394
5395 if ((i + 1) < orderByFields.length) {
5396 if (orderByComparator.isAscending() ^ previous) {
5397 query.append(ORDER_BY_ASC_HAS_NEXT);
5398 }
5399 else {
5400 query.append(ORDER_BY_DESC_HAS_NEXT);
5401 }
5402 }
5403 else {
5404 if (orderByComparator.isAscending() ^ previous) {
5405 query.append(ORDER_BY_ASC);
5406 }
5407 else {
5408 query.append(ORDER_BY_DESC);
5409 }
5410 }
5411 }
5412 }
5413
5414 else {
5415 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5416 }
5417
5418 String sql = query.toString();
5419
5420 Query q = session.createQuery(sql);
5421
5422 q.setFirstResult(0);
5423 q.setMaxResults(2);
5424
5425 QueryPos qPos = QueryPos.getInstance(q);
5426
5427 qPos.add(groupId);
5428
5429 qPos.add(categoryId);
5430
5431 if (lastPostDate != null) {
5432 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5433 }
5434
5435 if (orderByComparator != null) {
5436 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5437
5438 for (Object value : values) {
5439 qPos.add(value);
5440 }
5441 }
5442
5443 List<MBThread> list = q.list();
5444
5445 if (list.size() == 2) {
5446 return list.get(1);
5447 }
5448 else {
5449 return null;
5450 }
5451 }
5452
5453
5462 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
5463 Date lastPostDate) throws SystemException {
5464 return filterFindByG_C_L(groupId, categoryId, lastPostDate,
5465 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5466 }
5467
5468
5483 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
5484 Date lastPostDate, int start, int end) throws SystemException {
5485 return filterFindByG_C_L(groupId, categoryId, lastPostDate, start, end,
5486 null);
5487 }
5488
5489
5505 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
5506 Date lastPostDate, int start, int end,
5507 OrderByComparator orderByComparator) throws SystemException {
5508 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5509 return findByG_C_L(groupId, categoryId, lastPostDate, start, end,
5510 orderByComparator);
5511 }
5512
5513 StringBundler query = null;
5514
5515 if (orderByComparator != null) {
5516 query = new StringBundler(5 +
5517 (orderByComparator.getOrderByFields().length * 3));
5518 }
5519 else {
5520 query = new StringBundler(5);
5521 }
5522
5523 if (getDB().isSupportsInlineDistinct()) {
5524 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
5525 }
5526 else {
5527 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
5528 }
5529
5530 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
5531
5532 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
5533
5534 if (lastPostDate == null) {
5535 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
5536 }
5537 else {
5538 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
5539 }
5540
5541 if (!getDB().isSupportsInlineDistinct()) {
5542 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
5543 }
5544
5545 if (orderByComparator != null) {
5546 if (getDB().isSupportsInlineDistinct()) {
5547 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5548 orderByComparator);
5549 }
5550 else {
5551 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5552 orderByComparator);
5553 }
5554 }
5555
5556 else {
5557 if (getDB().isSupportsInlineDistinct()) {
5558 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5559 }
5560 else {
5561 query.append(MBThreadModelImpl.ORDER_BY_SQL);
5562 }
5563 }
5564
5565 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5566 MBThread.class.getName(),
5567 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5568
5569 Session session = null;
5570
5571 try {
5572 session = openSession();
5573
5574 SQLQuery q = session.createSQLQuery(sql);
5575
5576 if (getDB().isSupportsInlineDistinct()) {
5577 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
5578 }
5579 else {
5580 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
5581 }
5582
5583 QueryPos qPos = QueryPos.getInstance(q);
5584
5585 qPos.add(groupId);
5586
5587 qPos.add(categoryId);
5588
5589 if (lastPostDate != null) {
5590 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5591 }
5592
5593 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
5594 }
5595 catch (Exception e) {
5596 throw processException(e);
5597 }
5598 finally {
5599 closeSession(session);
5600 }
5601 }
5602
5603
5615 public MBThread[] filterFindByG_C_L_PrevAndNext(long threadId,
5616 long groupId, long categoryId, Date lastPostDate,
5617 OrderByComparator orderByComparator)
5618 throws NoSuchThreadException, SystemException {
5619 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5620 return findByG_C_L_PrevAndNext(threadId, groupId, categoryId,
5621 lastPostDate, orderByComparator);
5622 }
5623
5624 MBThread mbThread = findByPrimaryKey(threadId);
5625
5626 Session session = null;
5627
5628 try {
5629 session = openSession();
5630
5631 MBThread[] array = new MBThreadImpl[3];
5632
5633 array[0] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId,
5634 categoryId, lastPostDate, orderByComparator, true);
5635
5636 array[1] = mbThread;
5637
5638 array[2] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId,
5639 categoryId, lastPostDate, orderByComparator, false);
5640
5641 return array;
5642 }
5643 catch (Exception e) {
5644 throw processException(e);
5645 }
5646 finally {
5647 closeSession(session);
5648 }
5649 }
5650
5651 protected MBThread filterGetByG_C_L_PrevAndNext(Session session,
5652 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
5653 OrderByComparator orderByComparator, boolean previous) {
5654 StringBundler query = null;
5655
5656 if (orderByComparator != null) {
5657 query = new StringBundler(6 +
5658 (orderByComparator.getOrderByFields().length * 6));
5659 }
5660 else {
5661 query = new StringBundler(3);
5662 }
5663
5664 if (getDB().isSupportsInlineDistinct()) {
5665 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
5666 }
5667 else {
5668 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
5669 }
5670
5671 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
5672
5673 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
5674
5675 if (lastPostDate == null) {
5676 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
5677 }
5678 else {
5679 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
5680 }
5681
5682 if (!getDB().isSupportsInlineDistinct()) {
5683 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
5684 }
5685
5686 if (orderByComparator != null) {
5687 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5688
5689 if (orderByConditionFields.length > 0) {
5690 query.append(WHERE_AND);
5691 }
5692
5693 for (int i = 0; i < orderByConditionFields.length; i++) {
5694 if (getDB().isSupportsInlineDistinct()) {
5695 query.append(_ORDER_BY_ENTITY_ALIAS);
5696 }
5697 else {
5698 query.append(_ORDER_BY_ENTITY_TABLE);
5699 }
5700
5701 query.append(orderByConditionFields[i]);
5702
5703 if ((i + 1) < orderByConditionFields.length) {
5704 if (orderByComparator.isAscending() ^ previous) {
5705 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5706 }
5707 else {
5708 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5709 }
5710 }
5711 else {
5712 if (orderByComparator.isAscending() ^ previous) {
5713 query.append(WHERE_GREATER_THAN);
5714 }
5715 else {
5716 query.append(WHERE_LESSER_THAN);
5717 }
5718 }
5719 }
5720
5721 query.append(ORDER_BY_CLAUSE);
5722
5723 String[] orderByFields = orderByComparator.getOrderByFields();
5724
5725 for (int i = 0; i < orderByFields.length; i++) {
5726 if (getDB().isSupportsInlineDistinct()) {
5727 query.append(_ORDER_BY_ENTITY_ALIAS);
5728 }
5729 else {
5730 query.append(_ORDER_BY_ENTITY_TABLE);
5731 }
5732
5733 query.append(orderByFields[i]);
5734
5735 if ((i + 1) < orderByFields.length) {
5736 if (orderByComparator.isAscending() ^ previous) {
5737 query.append(ORDER_BY_ASC_HAS_NEXT);
5738 }
5739 else {
5740 query.append(ORDER_BY_DESC_HAS_NEXT);
5741 }
5742 }
5743 else {
5744 if (orderByComparator.isAscending() ^ previous) {
5745 query.append(ORDER_BY_ASC);
5746 }
5747 else {
5748 query.append(ORDER_BY_DESC);
5749 }
5750 }
5751 }
5752 }
5753
5754 else {
5755 if (getDB().isSupportsInlineDistinct()) {
5756 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5757 }
5758 else {
5759 query.append(MBThreadModelImpl.ORDER_BY_SQL);
5760 }
5761 }
5762
5763 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5764 MBThread.class.getName(),
5765 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5766
5767 SQLQuery q = session.createSQLQuery(sql);
5768
5769 q.setFirstResult(0);
5770 q.setMaxResults(2);
5771
5772 if (getDB().isSupportsInlineDistinct()) {
5773 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
5774 }
5775 else {
5776 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
5777 }
5778
5779 QueryPos qPos = QueryPos.getInstance(q);
5780
5781 qPos.add(groupId);
5782
5783 qPos.add(categoryId);
5784
5785 if (lastPostDate != null) {
5786 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5787 }
5788
5789 if (orderByComparator != null) {
5790 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5791
5792 for (Object value : values) {
5793 qPos.add(value);
5794 }
5795 }
5796
5797 List<MBThread> list = q.list();
5798
5799 if (list.size() == 2) {
5800 return list.get(1);
5801 }
5802 else {
5803 return null;
5804 }
5805 }
5806
5807
5816 public List<MBThread> findByG_C_S(long groupId, long categoryId, int status)
5817 throws SystemException {
5818 return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS,
5819 QueryUtil.ALL_POS, null);
5820 }
5821
5822
5837 public List<MBThread> findByG_C_S(long groupId, long categoryId,
5838 int status, int start, int end) throws SystemException {
5839 return findByG_C_S(groupId, categoryId, status, start, end, null);
5840 }
5841
5842
5858 public List<MBThread> findByG_C_S(long groupId, long categoryId,
5859 int status, int start, int end, OrderByComparator orderByComparator)
5860 throws SystemException {
5861 FinderPath finderPath = null;
5862 Object[] finderArgs = null;
5863
5864 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5865 (orderByComparator == null)) {
5866 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S;
5867 finderArgs = new Object[] { groupId, categoryId, status };
5868 }
5869 else {
5870 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S;
5871 finderArgs = new Object[] {
5872 groupId, categoryId, status,
5873
5874 start, end, orderByComparator
5875 };
5876 }
5877
5878 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
5879 finderArgs, this);
5880
5881 if ((list != null) && !list.isEmpty()) {
5882 for (MBThread mbThread : list) {
5883 if ((groupId != mbThread.getGroupId()) ||
5884 (categoryId != mbThread.getCategoryId()) ||
5885 (status != mbThread.getStatus())) {
5886 list = null;
5887
5888 break;
5889 }
5890 }
5891 }
5892
5893 if (list == null) {
5894 StringBundler query = null;
5895
5896 if (orderByComparator != null) {
5897 query = new StringBundler(5 +
5898 (orderByComparator.getOrderByFields().length * 3));
5899 }
5900 else {
5901 query = new StringBundler(5);
5902 }
5903
5904 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5905
5906 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
5907
5908 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
5909
5910 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
5911
5912 if (orderByComparator != null) {
5913 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5914 orderByComparator);
5915 }
5916
5917 else {
5918 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5919 }
5920
5921 String sql = query.toString();
5922
5923 Session session = null;
5924
5925 try {
5926 session = openSession();
5927
5928 Query q = session.createQuery(sql);
5929
5930 QueryPos qPos = QueryPos.getInstance(q);
5931
5932 qPos.add(groupId);
5933
5934 qPos.add(categoryId);
5935
5936 qPos.add(status);
5937
5938 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
5939 end);
5940 }
5941 catch (Exception e) {
5942 throw processException(e);
5943 }
5944 finally {
5945 if (list == null) {
5946 FinderCacheUtil.removeResult(finderPath, finderArgs);
5947 }
5948 else {
5949 cacheResult(list);
5950
5951 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5952 }
5953
5954 closeSession(session);
5955 }
5956 }
5957
5958 return list;
5959 }
5960
5961
5972 public MBThread findByG_C_S_First(long groupId, long categoryId,
5973 int status, OrderByComparator orderByComparator)
5974 throws NoSuchThreadException, SystemException {
5975 MBThread mbThread = fetchByG_C_S_First(groupId, categoryId, status,
5976 orderByComparator);
5977
5978 if (mbThread != null) {
5979 return mbThread;
5980 }
5981
5982 StringBundler msg = new StringBundler(8);
5983
5984 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5985
5986 msg.append("groupId=");
5987 msg.append(groupId);
5988
5989 msg.append(", categoryId=");
5990 msg.append(categoryId);
5991
5992 msg.append(", status=");
5993 msg.append(status);
5994
5995 msg.append(StringPool.CLOSE_CURLY_BRACE);
5996
5997 throw new NoSuchThreadException(msg.toString());
5998 }
5999
6000
6010 public MBThread fetchByG_C_S_First(long groupId, long categoryId,
6011 int status, OrderByComparator orderByComparator)
6012 throws SystemException {
6013 List<MBThread> list = findByG_C_S(groupId, categoryId, status, 0, 1,
6014 orderByComparator);
6015
6016 if (!list.isEmpty()) {
6017 return list.get(0);
6018 }
6019
6020 return null;
6021 }
6022
6023
6034 public MBThread findByG_C_S_Last(long groupId, long categoryId, int status,
6035 OrderByComparator orderByComparator)
6036 throws NoSuchThreadException, SystemException {
6037 MBThread mbThread = fetchByG_C_S_Last(groupId, categoryId, status,
6038 orderByComparator);
6039
6040 if (mbThread != null) {
6041 return mbThread;
6042 }
6043
6044 StringBundler msg = new StringBundler(8);
6045
6046 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6047
6048 msg.append("groupId=");
6049 msg.append(groupId);
6050
6051 msg.append(", categoryId=");
6052 msg.append(categoryId);
6053
6054 msg.append(", status=");
6055 msg.append(status);
6056
6057 msg.append(StringPool.CLOSE_CURLY_BRACE);
6058
6059 throw new NoSuchThreadException(msg.toString());
6060 }
6061
6062
6072 public MBThread fetchByG_C_S_Last(long groupId, long categoryId,
6073 int status, OrderByComparator orderByComparator)
6074 throws SystemException {
6075 int count = countByG_C_S(groupId, categoryId, status);
6076
6077 List<MBThread> list = findByG_C_S(groupId, categoryId, status,
6078 count - 1, count, orderByComparator);
6079
6080 if (!list.isEmpty()) {
6081 return list.get(0);
6082 }
6083
6084 return null;
6085 }
6086
6087
6099 public MBThread[] findByG_C_S_PrevAndNext(long threadId, long groupId,
6100 long categoryId, int status, OrderByComparator orderByComparator)
6101 throws NoSuchThreadException, SystemException {
6102 MBThread mbThread = findByPrimaryKey(threadId);
6103
6104 Session session = null;
6105
6106 try {
6107 session = openSession();
6108
6109 MBThread[] array = new MBThreadImpl[3];
6110
6111 array[0] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
6112 categoryId, status, orderByComparator, true);
6113
6114 array[1] = mbThread;
6115
6116 array[2] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
6117 categoryId, status, orderByComparator, false);
6118
6119 return array;
6120 }
6121 catch (Exception e) {
6122 throw processException(e);
6123 }
6124 finally {
6125 closeSession(session);
6126 }
6127 }
6128
6129 protected MBThread getByG_C_S_PrevAndNext(Session session,
6130 MBThread mbThread, long groupId, long categoryId, int status,
6131 OrderByComparator orderByComparator, boolean previous) {
6132 StringBundler query = null;
6133
6134 if (orderByComparator != null) {
6135 query = new StringBundler(6 +
6136 (orderByComparator.getOrderByFields().length * 6));
6137 }
6138 else {
6139 query = new StringBundler(3);
6140 }
6141
6142 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6143
6144 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
6145
6146 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
6147
6148 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
6149
6150 if (orderByComparator != null) {
6151 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6152
6153 if (orderByConditionFields.length > 0) {
6154 query.append(WHERE_AND);
6155 }
6156
6157 for (int i = 0; i < orderByConditionFields.length; i++) {
6158 query.append(_ORDER_BY_ENTITY_ALIAS);
6159 query.append(orderByConditionFields[i]);
6160
6161 if ((i + 1) < orderByConditionFields.length) {
6162 if (orderByComparator.isAscending() ^ previous) {
6163 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6164 }
6165 else {
6166 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6167 }
6168 }
6169 else {
6170 if (orderByComparator.isAscending() ^ previous) {
6171 query.append(WHERE_GREATER_THAN);
6172 }
6173 else {
6174 query.append(WHERE_LESSER_THAN);
6175 }
6176 }
6177 }
6178
6179 query.append(ORDER_BY_CLAUSE);
6180
6181 String[] orderByFields = orderByComparator.getOrderByFields();
6182
6183 for (int i = 0; i < orderByFields.length; i++) {
6184 query.append(_ORDER_BY_ENTITY_ALIAS);
6185 query.append(orderByFields[i]);
6186
6187 if ((i + 1) < orderByFields.length) {
6188 if (orderByComparator.isAscending() ^ previous) {
6189 query.append(ORDER_BY_ASC_HAS_NEXT);
6190 }
6191 else {
6192 query.append(ORDER_BY_DESC_HAS_NEXT);
6193 }
6194 }
6195 else {
6196 if (orderByComparator.isAscending() ^ previous) {
6197 query.append(ORDER_BY_ASC);
6198 }
6199 else {
6200 query.append(ORDER_BY_DESC);
6201 }
6202 }
6203 }
6204 }
6205
6206 else {
6207 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6208 }
6209
6210 String sql = query.toString();
6211
6212 Query q = session.createQuery(sql);
6213
6214 q.setFirstResult(0);
6215 q.setMaxResults(2);
6216
6217 QueryPos qPos = QueryPos.getInstance(q);
6218
6219 qPos.add(groupId);
6220
6221 qPos.add(categoryId);
6222
6223 qPos.add(status);
6224
6225 if (orderByComparator != null) {
6226 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
6227
6228 for (Object value : values) {
6229 qPos.add(value);
6230 }
6231 }
6232
6233 List<MBThread> list = q.list();
6234
6235 if (list.size() == 2) {
6236 return list.get(1);
6237 }
6238 else {
6239 return null;
6240 }
6241 }
6242
6243
6256 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
6257 int status) throws SystemException {
6258 return findByG_C_S(groupId, categoryIds, status, QueryUtil.ALL_POS,
6259 QueryUtil.ALL_POS, null);
6260 }
6261
6262
6277 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
6278 int status, int start, int end) throws SystemException {
6279 return findByG_C_S(groupId, categoryIds, status, start, end, null);
6280 }
6281
6282
6298 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
6299 int status, int start, int end, OrderByComparator orderByComparator)
6300 throws SystemException {
6301 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S;
6302 Object[] finderArgs = null;
6303
6304 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6305 (orderByComparator == null)) {
6306 finderArgs = new Object[] {
6307 groupId, StringUtil.merge(categoryIds), status
6308 };
6309 }
6310 else {
6311 finderArgs = new Object[] {
6312 groupId, StringUtil.merge(categoryIds), status,
6313
6314 start, end, orderByComparator
6315 };
6316 }
6317
6318 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
6319 finderArgs, this);
6320
6321 if ((list != null) && !list.isEmpty()) {
6322 for (MBThread mbThread : list) {
6323 if ((groupId != mbThread.getGroupId()) ||
6324 !ArrayUtil.contains(categoryIds,
6325 mbThread.getCategoryId()) ||
6326 (status != mbThread.getStatus())) {
6327 list = null;
6328
6329 break;
6330 }
6331 }
6332 }
6333
6334 if (list == null) {
6335 StringBundler query = new StringBundler();
6336
6337 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6338
6339 boolean conjunctionable = false;
6340
6341 if (conjunctionable) {
6342 query.append(WHERE_AND);
6343 }
6344
6345 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
6346
6347 conjunctionable = true;
6348
6349 if ((categoryIds == null) || (categoryIds.length > 0)) {
6350 if (conjunctionable) {
6351 query.append(WHERE_AND);
6352 }
6353
6354 query.append(StringPool.OPEN_PARENTHESIS);
6355
6356 for (int i = 0; i < categoryIds.length; i++) {
6357 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
6358
6359 if ((i + 1) < categoryIds.length) {
6360 query.append(WHERE_OR);
6361 }
6362 }
6363
6364 query.append(StringPool.CLOSE_PARENTHESIS);
6365
6366 conjunctionable = true;
6367 }
6368
6369 if (conjunctionable) {
6370 query.append(WHERE_AND);
6371 }
6372
6373 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
6374
6375 conjunctionable = true;
6376
6377 if (orderByComparator != null) {
6378 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6379 orderByComparator);
6380 }
6381
6382 else {
6383 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6384 }
6385
6386 String sql = query.toString();
6387
6388 Session session = null;
6389
6390 try {
6391 session = openSession();
6392
6393 Query q = session.createQuery(sql);
6394
6395 QueryPos qPos = QueryPos.getInstance(q);
6396
6397 qPos.add(groupId);
6398
6399 if (categoryIds != null) {
6400 qPos.add(categoryIds);
6401 }
6402
6403 qPos.add(status);
6404
6405 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
6406 end);
6407 }
6408 catch (Exception e) {
6409 throw processException(e);
6410 }
6411 finally {
6412 if (list == null) {
6413 FinderCacheUtil.removeResult(finderPath, finderArgs);
6414 }
6415 else {
6416 cacheResult(list);
6417
6418 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6419 }
6420
6421 closeSession(session);
6422 }
6423 }
6424
6425 return list;
6426 }
6427
6428
6437 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
6438 int status) throws SystemException {
6439 return filterFindByG_C_S(groupId, categoryId, status,
6440 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6441 }
6442
6443
6458 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
6459 int status, int start, int end) throws SystemException {
6460 return filterFindByG_C_S(groupId, categoryId, status, start, end, null);
6461 }
6462
6463
6479 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
6480 int status, int start, int end, OrderByComparator orderByComparator)
6481 throws SystemException {
6482 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6483 return findByG_C_S(groupId, categoryId, status, start, end,
6484 orderByComparator);
6485 }
6486
6487 StringBundler query = null;
6488
6489 if (orderByComparator != null) {
6490 query = new StringBundler(5 +
6491 (orderByComparator.getOrderByFields().length * 3));
6492 }
6493 else {
6494 query = new StringBundler(5);
6495 }
6496
6497 if (getDB().isSupportsInlineDistinct()) {
6498 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
6499 }
6500 else {
6501 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
6502 }
6503
6504 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
6505
6506 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
6507
6508 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
6509
6510 if (!getDB().isSupportsInlineDistinct()) {
6511 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
6512 }
6513
6514 if (orderByComparator != null) {
6515 if (getDB().isSupportsInlineDistinct()) {
6516 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6517 orderByComparator);
6518 }
6519 else {
6520 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6521 orderByComparator);
6522 }
6523 }
6524
6525 else {
6526 if (getDB().isSupportsInlineDistinct()) {
6527 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6528 }
6529 else {
6530 query.append(MBThreadModelImpl.ORDER_BY_SQL);
6531 }
6532 }
6533
6534 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6535 MBThread.class.getName(),
6536 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6537
6538 Session session = null;
6539
6540 try {
6541 session = openSession();
6542
6543 SQLQuery q = session.createSQLQuery(sql);
6544
6545 if (getDB().isSupportsInlineDistinct()) {
6546 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
6547 }
6548 else {
6549 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
6550 }
6551
6552 QueryPos qPos = QueryPos.getInstance(q);
6553
6554 qPos.add(groupId);
6555
6556 qPos.add(categoryId);
6557
6558 qPos.add(status);
6559
6560 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
6561 }
6562 catch (Exception e) {
6563 throw processException(e);
6564 }
6565 finally {
6566 closeSession(session);
6567 }
6568 }
6569
6570
6582 public MBThread[] filterFindByG_C_S_PrevAndNext(long threadId,
6583 long groupId, long categoryId, int status,
6584 OrderByComparator orderByComparator)
6585 throws NoSuchThreadException, SystemException {
6586 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6587 return findByG_C_S_PrevAndNext(threadId, groupId, categoryId,
6588 status, orderByComparator);
6589 }
6590
6591 MBThread mbThread = findByPrimaryKey(threadId);
6592
6593 Session session = null;
6594
6595 try {
6596 session = openSession();
6597
6598 MBThread[] array = new MBThreadImpl[3];
6599
6600 array[0] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId,
6601 categoryId, status, orderByComparator, true);
6602
6603 array[1] = mbThread;
6604
6605 array[2] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId,
6606 categoryId, status, orderByComparator, false);
6607
6608 return array;
6609 }
6610 catch (Exception e) {
6611 throw processException(e);
6612 }
6613 finally {
6614 closeSession(session);
6615 }
6616 }
6617
6618 protected MBThread filterGetByG_C_S_PrevAndNext(Session session,
6619 MBThread mbThread, long groupId, long categoryId, int status,
6620 OrderByComparator orderByComparator, boolean previous) {
6621 StringBundler query = null;
6622
6623 if (orderByComparator != null) {
6624 query = new StringBundler(6 +
6625 (orderByComparator.getOrderByFields().length * 6));
6626 }
6627 else {
6628 query = new StringBundler(3);
6629 }
6630
6631 if (getDB().isSupportsInlineDistinct()) {
6632 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
6633 }
6634 else {
6635 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
6636 }
6637
6638 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
6639
6640 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
6641
6642 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
6643
6644 if (!getDB().isSupportsInlineDistinct()) {
6645 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
6646 }
6647
6648 if (orderByComparator != null) {
6649 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6650
6651 if (orderByConditionFields.length > 0) {
6652 query.append(WHERE_AND);
6653 }
6654
6655 for (int i = 0; i < orderByConditionFields.length; i++) {
6656 if (getDB().isSupportsInlineDistinct()) {
6657 query.append(_ORDER_BY_ENTITY_ALIAS);
6658 }
6659 else {
6660 query.append(_ORDER_BY_ENTITY_TABLE);
6661 }
6662
6663 query.append(orderByConditionFields[i]);
6664
6665 if ((i + 1) < orderByConditionFields.length) {
6666 if (orderByComparator.isAscending() ^ previous) {
6667 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6668 }
6669 else {
6670 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6671 }
6672 }
6673 else {
6674 if (orderByComparator.isAscending() ^ previous) {
6675 query.append(WHERE_GREATER_THAN);
6676 }
6677 else {
6678 query.append(WHERE_LESSER_THAN);
6679 }
6680 }
6681 }
6682
6683 query.append(ORDER_BY_CLAUSE);
6684
6685 String[] orderByFields = orderByComparator.getOrderByFields();
6686
6687 for (int i = 0; i < orderByFields.length; i++) {
6688 if (getDB().isSupportsInlineDistinct()) {
6689 query.append(_ORDER_BY_ENTITY_ALIAS);
6690 }
6691 else {
6692 query.append(_ORDER_BY_ENTITY_TABLE);
6693 }
6694
6695 query.append(orderByFields[i]);
6696
6697 if ((i + 1) < orderByFields.length) {
6698 if (orderByComparator.isAscending() ^ previous) {
6699 query.append(ORDER_BY_ASC_HAS_NEXT);
6700 }
6701 else {
6702 query.append(ORDER_BY_DESC_HAS_NEXT);
6703 }
6704 }
6705 else {
6706 if (orderByComparator.isAscending() ^ previous) {
6707 query.append(ORDER_BY_ASC);
6708 }
6709 else {
6710 query.append(ORDER_BY_DESC);
6711 }
6712 }
6713 }
6714 }
6715
6716 else {
6717 if (getDB().isSupportsInlineDistinct()) {
6718 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6719 }
6720 else {
6721 query.append(MBThreadModelImpl.ORDER_BY_SQL);
6722 }
6723 }
6724
6725 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6726 MBThread.class.getName(),
6727 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6728
6729 SQLQuery q = session.createSQLQuery(sql);
6730
6731 q.setFirstResult(0);
6732 q.setMaxResults(2);
6733
6734 if (getDB().isSupportsInlineDistinct()) {
6735 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
6736 }
6737 else {
6738 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
6739 }
6740
6741 QueryPos qPos = QueryPos.getInstance(q);
6742
6743 qPos.add(groupId);
6744
6745 qPos.add(categoryId);
6746
6747 qPos.add(status);
6748
6749 if (orderByComparator != null) {
6750 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
6751
6752 for (Object value : values) {
6753 qPos.add(value);
6754 }
6755 }
6756
6757 List<MBThread> list = q.list();
6758
6759 if (list.size() == 2) {
6760 return list.get(1);
6761 }
6762 else {
6763 return null;
6764 }
6765 }
6766
6767
6776 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
6777 int status) throws SystemException {
6778 return filterFindByG_C_S(groupId, categoryIds, status,
6779 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6780 }
6781
6782
6797 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
6798 int status, int start, int end) throws SystemException {
6799 return filterFindByG_C_S(groupId, categoryIds, status, start, end, null);
6800 }
6801
6802
6818 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
6819 int status, int start, int end, OrderByComparator orderByComparator)
6820 throws SystemException {
6821 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6822 return findByG_C_S(groupId, categoryIds, status, start, end,
6823 orderByComparator);
6824 }
6825
6826 StringBundler query = new StringBundler();
6827
6828 if (getDB().isSupportsInlineDistinct()) {
6829 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
6830 }
6831 else {
6832 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
6833 }
6834
6835 boolean conjunctionable = false;
6836
6837 if (conjunctionable) {
6838 query.append(WHERE_AND);
6839 }
6840
6841 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
6842
6843 conjunctionable = true;
6844
6845 if ((categoryIds == null) || (categoryIds.length > 0)) {
6846 if (conjunctionable) {
6847 query.append(WHERE_AND);
6848 }
6849
6850 query.append(StringPool.OPEN_PARENTHESIS);
6851
6852 for (int i = 0; i < categoryIds.length; i++) {
6853 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
6854
6855 if ((i + 1) < categoryIds.length) {
6856 query.append(WHERE_OR);
6857 }
6858 }
6859
6860 query.append(StringPool.CLOSE_PARENTHESIS);
6861
6862 conjunctionable = true;
6863 }
6864
6865 if (conjunctionable) {
6866 query.append(WHERE_AND);
6867 }
6868
6869 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
6870
6871 conjunctionable = true;
6872
6873 if (!getDB().isSupportsInlineDistinct()) {
6874 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
6875 }
6876
6877 if (orderByComparator != null) {
6878 if (getDB().isSupportsInlineDistinct()) {
6879 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6880 orderByComparator);
6881 }
6882 else {
6883 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6884 orderByComparator);
6885 }
6886 }
6887
6888 else {
6889 if (getDB().isSupportsInlineDistinct()) {
6890 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6891 }
6892 else {
6893 query.append(MBThreadModelImpl.ORDER_BY_SQL);
6894 }
6895 }
6896
6897 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6898 MBThread.class.getName(),
6899 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6900
6901 Session session = null;
6902
6903 try {
6904 session = openSession();
6905
6906 SQLQuery q = session.createSQLQuery(sql);
6907
6908 if (getDB().isSupportsInlineDistinct()) {
6909 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
6910 }
6911 else {
6912 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
6913 }
6914
6915 QueryPos qPos = QueryPos.getInstance(q);
6916
6917 qPos.add(groupId);
6918
6919 if (categoryIds != null) {
6920 qPos.add(categoryIds);
6921 }
6922
6923 qPos.add(status);
6924
6925 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
6926 }
6927 catch (Exception e) {
6928 throw processException(e);
6929 }
6930 finally {
6931 closeSession(session);
6932 }
6933 }
6934
6935
6944 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
6945 int status) throws SystemException {
6946 return findByG_NotC_S(groupId, categoryId, status, QueryUtil.ALL_POS,
6947 QueryUtil.ALL_POS, null);
6948 }
6949
6950
6965 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
6966 int status, int start, int end) throws SystemException {
6967 return findByG_NotC_S(groupId, categoryId, status, start, end, null);
6968 }
6969
6970
6986 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
6987 int status, int start, int end, OrderByComparator orderByComparator)
6988 throws SystemException {
6989 FinderPath finderPath = null;
6990 Object[] finderArgs = null;
6991
6992 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S;
6993 finderArgs = new Object[] {
6994 groupId, categoryId, status,
6995
6996 start, end, orderByComparator
6997 };
6998
6999 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
7000 finderArgs, this);
7001
7002 if ((list != null) && !list.isEmpty()) {
7003 for (MBThread mbThread : list) {
7004 if ((groupId != mbThread.getGroupId()) ||
7005 (categoryId != mbThread.getCategoryId()) ||
7006 (status != mbThread.getStatus())) {
7007 list = null;
7008
7009 break;
7010 }
7011 }
7012 }
7013
7014 if (list == null) {
7015 StringBundler query = null;
7016
7017 if (orderByComparator != null) {
7018 query = new StringBundler(5 +
7019 (orderByComparator.getOrderByFields().length * 3));
7020 }
7021 else {
7022 query = new StringBundler(5);
7023 }
7024
7025 query.append(_SQL_SELECT_MBTHREAD_WHERE);
7026
7027 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
7028
7029 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
7030
7031 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
7032
7033 if (orderByComparator != null) {
7034 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7035 orderByComparator);
7036 }
7037
7038 else {
7039 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7040 }
7041
7042 String sql = query.toString();
7043
7044 Session session = null;
7045
7046 try {
7047 session = openSession();
7048
7049 Query q = session.createQuery(sql);
7050
7051 QueryPos qPos = QueryPos.getInstance(q);
7052
7053 qPos.add(groupId);
7054
7055 qPos.add(categoryId);
7056
7057 qPos.add(status);
7058
7059 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
7060 end);
7061 }
7062 catch (Exception e) {
7063 throw processException(e);
7064 }
7065 finally {
7066 if (list == null) {
7067 FinderCacheUtil.removeResult(finderPath, finderArgs);
7068 }
7069 else {
7070 cacheResult(list);
7071
7072 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7073 }
7074
7075 closeSession(session);
7076 }
7077 }
7078
7079 return list;
7080 }
7081
7082
7093 public MBThread findByG_NotC_S_First(long groupId, long categoryId,
7094 int status, OrderByComparator orderByComparator)
7095 throws NoSuchThreadException, SystemException {
7096 MBThread mbThread = fetchByG_NotC_S_First(groupId, categoryId, status,
7097 orderByComparator);
7098
7099 if (mbThread != null) {
7100 return mbThread;
7101 }
7102
7103 StringBundler msg = new StringBundler(8);
7104
7105 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7106
7107 msg.append("groupId=");
7108 msg.append(groupId);
7109
7110 msg.append(", categoryId=");
7111 msg.append(categoryId);
7112
7113 msg.append(", status=");
7114 msg.append(status);
7115
7116 msg.append(StringPool.CLOSE_CURLY_BRACE);
7117
7118 throw new NoSuchThreadException(msg.toString());
7119 }
7120
7121
7131 public MBThread fetchByG_NotC_S_First(long groupId, long categoryId,
7132 int status, OrderByComparator orderByComparator)
7133 throws SystemException {
7134 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status, 0, 1,
7135 orderByComparator);
7136
7137 if (!list.isEmpty()) {
7138 return list.get(0);
7139 }
7140
7141 return null;
7142 }
7143
7144
7155 public MBThread findByG_NotC_S_Last(long groupId, long categoryId,
7156 int status, OrderByComparator orderByComparator)
7157 throws NoSuchThreadException, SystemException {
7158 MBThread mbThread = fetchByG_NotC_S_Last(groupId, categoryId, status,
7159 orderByComparator);
7160
7161 if (mbThread != null) {
7162 return mbThread;
7163 }
7164
7165 StringBundler msg = new StringBundler(8);
7166
7167 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7168
7169 msg.append("groupId=");
7170 msg.append(groupId);
7171
7172 msg.append(", categoryId=");
7173 msg.append(categoryId);
7174
7175 msg.append(", status=");
7176 msg.append(status);
7177
7178 msg.append(StringPool.CLOSE_CURLY_BRACE);
7179
7180 throw new NoSuchThreadException(msg.toString());
7181 }
7182
7183
7193 public MBThread fetchByG_NotC_S_Last(long groupId, long categoryId,
7194 int status, OrderByComparator orderByComparator)
7195 throws SystemException {
7196 int count = countByG_NotC_S(groupId, categoryId, status);
7197
7198 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status,
7199 count - 1, count, orderByComparator);
7200
7201 if (!list.isEmpty()) {
7202 return list.get(0);
7203 }
7204
7205 return null;
7206 }
7207
7208
7220 public MBThread[] findByG_NotC_S_PrevAndNext(long threadId, long groupId,
7221 long categoryId, int status, OrderByComparator orderByComparator)
7222 throws NoSuchThreadException, SystemException {
7223 MBThread mbThread = findByPrimaryKey(threadId);
7224
7225 Session session = null;
7226
7227 try {
7228 session = openSession();
7229
7230 MBThread[] array = new MBThreadImpl[3];
7231
7232 array[0] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
7233 categoryId, status, orderByComparator, true);
7234
7235 array[1] = mbThread;
7236
7237 array[2] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
7238 categoryId, status, orderByComparator, false);
7239
7240 return array;
7241 }
7242 catch (Exception e) {
7243 throw processException(e);
7244 }
7245 finally {
7246 closeSession(session);
7247 }
7248 }
7249
7250 protected MBThread getByG_NotC_S_PrevAndNext(Session session,
7251 MBThread mbThread, long groupId, long categoryId, int status,
7252 OrderByComparator orderByComparator, boolean previous) {
7253 StringBundler query = null;
7254
7255 if (orderByComparator != null) {
7256 query = new StringBundler(6 +
7257 (orderByComparator.getOrderByFields().length * 6));
7258 }
7259 else {
7260 query = new StringBundler(3);
7261 }
7262
7263 query.append(_SQL_SELECT_MBTHREAD_WHERE);
7264
7265 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
7266
7267 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
7268
7269 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
7270
7271 if (orderByComparator != null) {
7272 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7273
7274 if (orderByConditionFields.length > 0) {
7275 query.append(WHERE_AND);
7276 }
7277
7278 for (int i = 0; i < orderByConditionFields.length; i++) {
7279 query.append(_ORDER_BY_ENTITY_ALIAS);
7280 query.append(orderByConditionFields[i]);
7281
7282 if ((i + 1) < orderByConditionFields.length) {
7283 if (orderByComparator.isAscending() ^ previous) {
7284 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7285 }
7286 else {
7287 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7288 }
7289 }
7290 else {
7291 if (orderByComparator.isAscending() ^ previous) {
7292 query.append(WHERE_GREATER_THAN);
7293 }
7294 else {
7295 query.append(WHERE_LESSER_THAN);
7296 }
7297 }
7298 }
7299
7300 query.append(ORDER_BY_CLAUSE);
7301
7302 String[] orderByFields = orderByComparator.getOrderByFields();
7303
7304 for (int i = 0; i < orderByFields.length; i++) {
7305 query.append(_ORDER_BY_ENTITY_ALIAS);
7306 query.append(orderByFields[i]);
7307
7308 if ((i + 1) < orderByFields.length) {
7309 if (orderByComparator.isAscending() ^ previous) {
7310 query.append(ORDER_BY_ASC_HAS_NEXT);
7311 }
7312 else {
7313 query.append(ORDER_BY_DESC_HAS_NEXT);
7314 }
7315 }
7316 else {
7317 if (orderByComparator.isAscending() ^ previous) {
7318 query.append(ORDER_BY_ASC);
7319 }
7320 else {
7321 query.append(ORDER_BY_DESC);
7322 }
7323 }
7324 }
7325 }
7326
7327 else {
7328 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7329 }
7330
7331 String sql = query.toString();
7332
7333 Query q = session.createQuery(sql);
7334
7335 q.setFirstResult(0);
7336 q.setMaxResults(2);
7337
7338 QueryPos qPos = QueryPos.getInstance(q);
7339
7340 qPos.add(groupId);
7341
7342 qPos.add(categoryId);
7343
7344 qPos.add(status);
7345
7346 if (orderByComparator != null) {
7347 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
7348
7349 for (Object value : values) {
7350 qPos.add(value);
7351 }
7352 }
7353
7354 List<MBThread> list = q.list();
7355
7356 if (list.size() == 2) {
7357 return list.get(1);
7358 }
7359 else {
7360 return null;
7361 }
7362 }
7363
7364
7373 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
7374 int status) throws SystemException {
7375 return filterFindByG_NotC_S(groupId, categoryId, status,
7376 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7377 }
7378
7379
7394 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
7395 int status, int start, int end) throws SystemException {
7396 return filterFindByG_NotC_S(groupId, categoryId, status, start, end,
7397 null);
7398 }
7399
7400
7416 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
7417 int status, int start, int end, OrderByComparator orderByComparator)
7418 throws SystemException {
7419 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7420 return findByG_NotC_S(groupId, categoryId, status, start, end,
7421 orderByComparator);
7422 }
7423
7424 StringBundler query = null;
7425
7426 if (orderByComparator != null) {
7427 query = new StringBundler(5 +
7428 (orderByComparator.getOrderByFields().length * 3));
7429 }
7430 else {
7431 query = new StringBundler(5);
7432 }
7433
7434 if (getDB().isSupportsInlineDistinct()) {
7435 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
7436 }
7437 else {
7438 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
7439 }
7440
7441 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
7442
7443 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
7444
7445 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
7446
7447 if (!getDB().isSupportsInlineDistinct()) {
7448 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
7449 }
7450
7451 if (orderByComparator != null) {
7452 if (getDB().isSupportsInlineDistinct()) {
7453 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7454 orderByComparator);
7455 }
7456 else {
7457 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7458 orderByComparator);
7459 }
7460 }
7461
7462 else {
7463 if (getDB().isSupportsInlineDistinct()) {
7464 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7465 }
7466 else {
7467 query.append(MBThreadModelImpl.ORDER_BY_SQL);
7468 }
7469 }
7470
7471 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7472 MBThread.class.getName(),
7473 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7474
7475 Session session = null;
7476
7477 try {
7478 session = openSession();
7479
7480 SQLQuery q = session.createSQLQuery(sql);
7481
7482 if (getDB().isSupportsInlineDistinct()) {
7483 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
7484 }
7485 else {
7486 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
7487 }
7488
7489 QueryPos qPos = QueryPos.getInstance(q);
7490
7491 qPos.add(groupId);
7492
7493 qPos.add(categoryId);
7494
7495 qPos.add(status);
7496
7497 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
7498 }
7499 catch (Exception e) {
7500 throw processException(e);
7501 }
7502 finally {
7503 closeSession(session);
7504 }
7505 }
7506
7507
7519 public MBThread[] filterFindByG_NotC_S_PrevAndNext(long threadId,
7520 long groupId, long categoryId, int status,
7521 OrderByComparator orderByComparator)
7522 throws NoSuchThreadException, SystemException {
7523 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7524 return findByG_NotC_S_PrevAndNext(threadId, groupId, categoryId,
7525 status, orderByComparator);
7526 }
7527
7528 MBThread mbThread = findByPrimaryKey(threadId);
7529
7530 Session session = null;
7531
7532 try {
7533 session = openSession();
7534
7535 MBThread[] array = new MBThreadImpl[3];
7536
7537 array[0] = filterGetByG_NotC_S_PrevAndNext(session, mbThread,
7538 groupId, categoryId, status, orderByComparator, true);
7539
7540 array[1] = mbThread;
7541
7542 array[2] = filterGetByG_NotC_S_PrevAndNext(session, mbThread,
7543 groupId, categoryId, status, orderByComparator, false);
7544
7545 return array;
7546 }
7547 catch (Exception e) {
7548 throw processException(e);
7549 }
7550 finally {
7551 closeSession(session);
7552 }
7553 }
7554
7555 protected MBThread filterGetByG_NotC_S_PrevAndNext(Session session,
7556 MBThread mbThread, long groupId, long categoryId, int status,
7557 OrderByComparator orderByComparator, boolean previous) {
7558 StringBundler query = null;
7559
7560 if (orderByComparator != null) {
7561 query = new StringBundler(6 +
7562 (orderByComparator.getOrderByFields().length * 6));
7563 }
7564 else {
7565 query = new StringBundler(3);
7566 }
7567
7568 if (getDB().isSupportsInlineDistinct()) {
7569 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
7570 }
7571 else {
7572 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
7573 }
7574
7575 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
7576
7577 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
7578
7579 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
7580
7581 if (!getDB().isSupportsInlineDistinct()) {
7582 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
7583 }
7584
7585 if (orderByComparator != null) {
7586 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7587
7588 if (orderByConditionFields.length > 0) {
7589 query.append(WHERE_AND);
7590 }
7591
7592 for (int i = 0; i < orderByConditionFields.length; i++) {
7593 if (getDB().isSupportsInlineDistinct()) {
7594 query.append(_ORDER_BY_ENTITY_ALIAS);
7595 }
7596 else {
7597 query.append(_ORDER_BY_ENTITY_TABLE);
7598 }
7599
7600 query.append(orderByConditionFields[i]);
7601
7602 if ((i + 1) < orderByConditionFields.length) {
7603 if (orderByComparator.isAscending() ^ previous) {
7604 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7605 }
7606 else {
7607 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7608 }
7609 }
7610 else {
7611 if (orderByComparator.isAscending() ^ previous) {
7612 query.append(WHERE_GREATER_THAN);
7613 }
7614 else {
7615 query.append(WHERE_LESSER_THAN);
7616 }
7617 }
7618 }
7619
7620 query.append(ORDER_BY_CLAUSE);
7621
7622 String[] orderByFields = orderByComparator.getOrderByFields();
7623
7624 for (int i = 0; i < orderByFields.length; i++) {
7625 if (getDB().isSupportsInlineDistinct()) {
7626 query.append(_ORDER_BY_ENTITY_ALIAS);
7627 }
7628 else {
7629 query.append(_ORDER_BY_ENTITY_TABLE);
7630 }
7631
7632 query.append(orderByFields[i]);
7633
7634 if ((i + 1) < orderByFields.length) {
7635 if (orderByComparator.isAscending() ^ previous) {
7636 query.append(ORDER_BY_ASC_HAS_NEXT);
7637 }
7638 else {
7639 query.append(ORDER_BY_DESC_HAS_NEXT);
7640 }
7641 }
7642 else {
7643 if (orderByComparator.isAscending() ^ previous) {
7644 query.append(ORDER_BY_ASC);
7645 }
7646 else {
7647 query.append(ORDER_BY_DESC);
7648 }
7649 }
7650 }
7651 }
7652
7653 else {
7654 if (getDB().isSupportsInlineDistinct()) {
7655 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7656 }
7657 else {
7658 query.append(MBThreadModelImpl.ORDER_BY_SQL);
7659 }
7660 }
7661
7662 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7663 MBThread.class.getName(),
7664 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7665
7666 SQLQuery q = session.createSQLQuery(sql);
7667
7668 q.setFirstResult(0);
7669 q.setMaxResults(2);
7670
7671 if (getDB().isSupportsInlineDistinct()) {
7672 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
7673 }
7674 else {
7675 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
7676 }
7677
7678 QueryPos qPos = QueryPos.getInstance(q);
7679
7680 qPos.add(groupId);
7681
7682 qPos.add(categoryId);
7683
7684 qPos.add(status);
7685
7686 if (orderByComparator != null) {
7687 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
7688
7689 for (Object value : values) {
7690 qPos.add(value);
7691 }
7692 }
7693
7694 List<MBThread> list = q.list();
7695
7696 if (list.size() == 2) {
7697 return list.get(1);
7698 }
7699 else {
7700 return null;
7701 }
7702 }
7703
7704
7710 public List<MBThread> findAll() throws SystemException {
7711 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7712 }
7713
7714
7726 public List<MBThread> findAll(int start, int end) throws SystemException {
7727 return findAll(start, end, null);
7728 }
7729
7730
7743 public List<MBThread> findAll(int start, int end,
7744 OrderByComparator orderByComparator) throws SystemException {
7745 FinderPath finderPath = null;
7746 Object[] finderArgs = new Object[] { start, end, orderByComparator };
7747
7748 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7749 (orderByComparator == null)) {
7750 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
7751 finderArgs = FINDER_ARGS_EMPTY;
7752 }
7753 else {
7754 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
7755 finderArgs = new Object[] { start, end, orderByComparator };
7756 }
7757
7758 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
7759 finderArgs, this);
7760
7761 if (list == null) {
7762 StringBundler query = null;
7763 String sql = null;
7764
7765 if (orderByComparator != null) {
7766 query = new StringBundler(2 +
7767 (orderByComparator.getOrderByFields().length * 3));
7768
7769 query.append(_SQL_SELECT_MBTHREAD);
7770
7771 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7772 orderByComparator);
7773
7774 sql = query.toString();
7775 }
7776 else {
7777 sql = _SQL_SELECT_MBTHREAD.concat(MBThreadModelImpl.ORDER_BY_JPQL);
7778 }
7779
7780 Session session = null;
7781
7782 try {
7783 session = openSession();
7784
7785 Query q = session.createQuery(sql);
7786
7787 if (orderByComparator == null) {
7788 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
7789 start, end, false);
7790
7791 Collections.sort(list);
7792 }
7793 else {
7794 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
7795 start, end);
7796 }
7797 }
7798 catch (Exception e) {
7799 throw processException(e);
7800 }
7801 finally {
7802 if (list == null) {
7803 FinderCacheUtil.removeResult(finderPath, finderArgs);
7804 }
7805 else {
7806 cacheResult(list);
7807
7808 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7809 }
7810
7811 closeSession(session);
7812 }
7813 }
7814
7815 return list;
7816 }
7817
7818
7824 public void removeByGroupId(long groupId) throws SystemException {
7825 for (MBThread mbThread : findByGroupId(groupId)) {
7826 remove(mbThread);
7827 }
7828 }
7829
7830
7837 public MBThread removeByRootMessageId(long rootMessageId)
7838 throws NoSuchThreadException, SystemException {
7839 MBThread mbThread = findByRootMessageId(rootMessageId);
7840
7841 return remove(mbThread);
7842 }
7843
7844
7851 public void removeByG_C(long groupId, long categoryId)
7852 throws SystemException {
7853 for (MBThread mbThread : findByG_C(groupId, categoryId)) {
7854 remove(mbThread);
7855 }
7856 }
7857
7858
7865 public void removeByG_NotC(long groupId, long categoryId)
7866 throws SystemException {
7867 for (MBThread mbThread : findByG_NotC(groupId, categoryId)) {
7868 remove(mbThread);
7869 }
7870 }
7871
7872
7879 public void removeByG_S(long groupId, int status) throws SystemException {
7880 for (MBThread mbThread : findByG_S(groupId, status)) {
7881 remove(mbThread);
7882 }
7883 }
7884
7885
7892 public void removeByC_P(long categoryId, double priority)
7893 throws SystemException {
7894 for (MBThread mbThread : findByC_P(categoryId, priority)) {
7895 remove(mbThread);
7896 }
7897 }
7898
7899
7906 public void removeByL_P(Date lastPostDate, double priority)
7907 throws SystemException {
7908 for (MBThread mbThread : findByL_P(lastPostDate, priority)) {
7909 remove(mbThread);
7910 }
7911 }
7912
7913
7921 public void removeByG_C_L(long groupId, long categoryId, Date lastPostDate)
7922 throws SystemException {
7923 for (MBThread mbThread : findByG_C_L(groupId, categoryId, lastPostDate)) {
7924 remove(mbThread);
7925 }
7926 }
7927
7928
7936 public void removeByG_C_S(long groupId, long categoryId, int status)
7937 throws SystemException {
7938 for (MBThread mbThread : findByG_C_S(groupId, categoryId, status)) {
7939 remove(mbThread);
7940 }
7941 }
7942
7943
7951 public void removeByG_NotC_S(long groupId, long categoryId, int status)
7952 throws SystemException {
7953 for (MBThread mbThread : findByG_NotC_S(groupId, categoryId, status)) {
7954 remove(mbThread);
7955 }
7956 }
7957
7958
7963 public void removeAll() throws SystemException {
7964 for (MBThread mbThread : findAll()) {
7965 remove(mbThread);
7966 }
7967 }
7968
7969
7976 public int countByGroupId(long groupId) throws SystemException {
7977 Object[] finderArgs = new Object[] { groupId };
7978
7979 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
7980 finderArgs, this);
7981
7982 if (count == null) {
7983 StringBundler query = new StringBundler(2);
7984
7985 query.append(_SQL_COUNT_MBTHREAD_WHERE);
7986
7987 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7988
7989 String sql = query.toString();
7990
7991 Session session = null;
7992
7993 try {
7994 session = openSession();
7995
7996 Query q = session.createQuery(sql);
7997
7998 QueryPos qPos = QueryPos.getInstance(q);
7999
8000 qPos.add(groupId);
8001
8002 count = (Long)q.uniqueResult();
8003 }
8004 catch (Exception e) {
8005 throw processException(e);
8006 }
8007 finally {
8008 if (count == null) {
8009 count = Long.valueOf(0);
8010 }
8011
8012 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
8013 finderArgs, count);
8014
8015 closeSession(session);
8016 }
8017 }
8018
8019 return count.intValue();
8020 }
8021
8022
8029 public int filterCountByGroupId(long groupId) throws SystemException {
8030 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8031 return countByGroupId(groupId);
8032 }
8033
8034 StringBundler query = new StringBundler(2);
8035
8036 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8037
8038 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
8039
8040 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8041 MBThread.class.getName(),
8042 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8043
8044 Session session = null;
8045
8046 try {
8047 session = openSession();
8048
8049 SQLQuery q = session.createSQLQuery(sql);
8050
8051 q.addScalar(COUNT_COLUMN_NAME,
8052 com.liferay.portal.kernel.dao.orm.Type.LONG);
8053
8054 QueryPos qPos = QueryPos.getInstance(q);
8055
8056 qPos.add(groupId);
8057
8058 Long count = (Long)q.uniqueResult();
8059
8060 return count.intValue();
8061 }
8062 catch (Exception e) {
8063 throw processException(e);
8064 }
8065 finally {
8066 closeSession(session);
8067 }
8068 }
8069
8070
8077 public int countByRootMessageId(long rootMessageId)
8078 throws SystemException {
8079 Object[] finderArgs = new Object[] { rootMessageId };
8080
8081 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID,
8082 finderArgs, this);
8083
8084 if (count == null) {
8085 StringBundler query = new StringBundler(2);
8086
8087 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8088
8089 query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2);
8090
8091 String sql = query.toString();
8092
8093 Session session = null;
8094
8095 try {
8096 session = openSession();
8097
8098 Query q = session.createQuery(sql);
8099
8100 QueryPos qPos = QueryPos.getInstance(q);
8101
8102 qPos.add(rootMessageId);
8103
8104 count = (Long)q.uniqueResult();
8105 }
8106 catch (Exception e) {
8107 throw processException(e);
8108 }
8109 finally {
8110 if (count == null) {
8111 count = Long.valueOf(0);
8112 }
8113
8114 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID,
8115 finderArgs, count);
8116
8117 closeSession(session);
8118 }
8119 }
8120
8121 return count.intValue();
8122 }
8123
8124
8132 public int countByG_C(long groupId, long categoryId)
8133 throws SystemException {
8134 Object[] finderArgs = new Object[] { groupId, categoryId };
8135
8136 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
8137 finderArgs, this);
8138
8139 if (count == null) {
8140 StringBundler query = new StringBundler(3);
8141
8142 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8143
8144 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
8145
8146 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
8147
8148 String sql = query.toString();
8149
8150 Session session = null;
8151
8152 try {
8153 session = openSession();
8154
8155 Query q = session.createQuery(sql);
8156
8157 QueryPos qPos = QueryPos.getInstance(q);
8158
8159 qPos.add(groupId);
8160
8161 qPos.add(categoryId);
8162
8163 count = (Long)q.uniqueResult();
8164 }
8165 catch (Exception e) {
8166 throw processException(e);
8167 }
8168 finally {
8169 if (count == null) {
8170 count = Long.valueOf(0);
8171 }
8172
8173 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
8174 count);
8175
8176 closeSession(session);
8177 }
8178 }
8179
8180 return count.intValue();
8181 }
8182
8183
8191 public int countByG_C(long groupId, long[] categoryIds)
8192 throws SystemException {
8193 Object[] finderArgs = new Object[] {
8194 groupId, StringUtil.merge(categoryIds)
8195 };
8196
8197 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
8198 finderArgs, this);
8199
8200 if (count == null) {
8201 StringBundler query = new StringBundler();
8202
8203 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8204
8205 boolean conjunctionable = false;
8206
8207 if (conjunctionable) {
8208 query.append(WHERE_AND);
8209 }
8210
8211 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
8212
8213 conjunctionable = true;
8214
8215 if ((categoryIds == null) || (categoryIds.length > 0)) {
8216 if (conjunctionable) {
8217 query.append(WHERE_AND);
8218 }
8219
8220 query.append(StringPool.OPEN_PARENTHESIS);
8221
8222 for (int i = 0; i < categoryIds.length; i++) {
8223 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
8224
8225 if ((i + 1) < categoryIds.length) {
8226 query.append(WHERE_OR);
8227 }
8228 }
8229
8230 query.append(StringPool.CLOSE_PARENTHESIS);
8231
8232 conjunctionable = true;
8233 }
8234
8235 String sql = query.toString();
8236
8237 Session session = null;
8238
8239 try {
8240 session = openSession();
8241
8242 Query q = session.createQuery(sql);
8243
8244 QueryPos qPos = QueryPos.getInstance(q);
8245
8246 qPos.add(groupId);
8247
8248 if (categoryIds != null) {
8249 qPos.add(categoryIds);
8250 }
8251
8252 count = (Long)q.uniqueResult();
8253 }
8254 catch (Exception e) {
8255 throw processException(e);
8256 }
8257 finally {
8258 if (count == null) {
8259 count = Long.valueOf(0);
8260 }
8261
8262 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
8263 finderArgs, count);
8264
8265 closeSession(session);
8266 }
8267 }
8268
8269 return count.intValue();
8270 }
8271
8272
8280 public int filterCountByG_C(long groupId, long categoryId)
8281 throws SystemException {
8282 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8283 return countByG_C(groupId, categoryId);
8284 }
8285
8286 StringBundler query = new StringBundler(3);
8287
8288 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8289
8290 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
8291
8292 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
8293
8294 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8295 MBThread.class.getName(),
8296 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8297
8298 Session session = null;
8299
8300 try {
8301 session = openSession();
8302
8303 SQLQuery q = session.createSQLQuery(sql);
8304
8305 q.addScalar(COUNT_COLUMN_NAME,
8306 com.liferay.portal.kernel.dao.orm.Type.LONG);
8307
8308 QueryPos qPos = QueryPos.getInstance(q);
8309
8310 qPos.add(groupId);
8311
8312 qPos.add(categoryId);
8313
8314 Long count = (Long)q.uniqueResult();
8315
8316 return count.intValue();
8317 }
8318 catch (Exception e) {
8319 throw processException(e);
8320 }
8321 finally {
8322 closeSession(session);
8323 }
8324 }
8325
8326
8334 public int filterCountByG_C(long groupId, long[] categoryIds)
8335 throws SystemException {
8336 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8337 return countByG_C(groupId, categoryIds);
8338 }
8339
8340 StringBundler query = new StringBundler();
8341
8342 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8343
8344 boolean conjunctionable = false;
8345
8346 if (conjunctionable) {
8347 query.append(WHERE_AND);
8348 }
8349
8350 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
8351
8352 conjunctionable = true;
8353
8354 if ((categoryIds == null) || (categoryIds.length > 0)) {
8355 if (conjunctionable) {
8356 query.append(WHERE_AND);
8357 }
8358
8359 query.append(StringPool.OPEN_PARENTHESIS);
8360
8361 for (int i = 0; i < categoryIds.length; i++) {
8362 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
8363
8364 if ((i + 1) < categoryIds.length) {
8365 query.append(WHERE_OR);
8366 }
8367 }
8368
8369 query.append(StringPool.CLOSE_PARENTHESIS);
8370
8371 conjunctionable = true;
8372 }
8373
8374 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8375 MBThread.class.getName(),
8376 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8377
8378 Session session = null;
8379
8380 try {
8381 session = openSession();
8382
8383 SQLQuery q = session.createSQLQuery(sql);
8384
8385 q.addScalar(COUNT_COLUMN_NAME,
8386 com.liferay.portal.kernel.dao.orm.Type.LONG);
8387
8388 QueryPos qPos = QueryPos.getInstance(q);
8389
8390 qPos.add(groupId);
8391
8392 if (categoryIds != null) {
8393 qPos.add(categoryIds);
8394 }
8395
8396 Long count = (Long)q.uniqueResult();
8397
8398 return count.intValue();
8399 }
8400 catch (Exception e) {
8401 throw processException(e);
8402 }
8403 finally {
8404 closeSession(session);
8405 }
8406 }
8407
8408
8416 public int countByG_NotC(long groupId, long categoryId)
8417 throws SystemException {
8418 Object[] finderArgs = new Object[] { groupId, categoryId };
8419
8420 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC,
8421 finderArgs, this);
8422
8423 if (count == null) {
8424 StringBundler query = new StringBundler(3);
8425
8426 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8427
8428 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
8429
8430 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
8431
8432 String sql = query.toString();
8433
8434 Session session = null;
8435
8436 try {
8437 session = openSession();
8438
8439 Query q = session.createQuery(sql);
8440
8441 QueryPos qPos = QueryPos.getInstance(q);
8442
8443 qPos.add(groupId);
8444
8445 qPos.add(categoryId);
8446
8447 count = (Long)q.uniqueResult();
8448 }
8449 catch (Exception e) {
8450 throw processException(e);
8451 }
8452 finally {
8453 if (count == null) {
8454 count = Long.valueOf(0);
8455 }
8456
8457 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC,
8458 finderArgs, count);
8459
8460 closeSession(session);
8461 }
8462 }
8463
8464 return count.intValue();
8465 }
8466
8467
8475 public int filterCountByG_NotC(long groupId, long categoryId)
8476 throws SystemException {
8477 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8478 return countByG_NotC(groupId, categoryId);
8479 }
8480
8481 StringBundler query = new StringBundler(3);
8482
8483 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8484
8485 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
8486
8487 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
8488
8489 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8490 MBThread.class.getName(),
8491 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8492
8493 Session session = null;
8494
8495 try {
8496 session = openSession();
8497
8498 SQLQuery q = session.createSQLQuery(sql);
8499
8500 q.addScalar(COUNT_COLUMN_NAME,
8501 com.liferay.portal.kernel.dao.orm.Type.LONG);
8502
8503 QueryPos qPos = QueryPos.getInstance(q);
8504
8505 qPos.add(groupId);
8506
8507 qPos.add(categoryId);
8508
8509 Long count = (Long)q.uniqueResult();
8510
8511 return count.intValue();
8512 }
8513 catch (Exception e) {
8514 throw processException(e);
8515 }
8516 finally {
8517 closeSession(session);
8518 }
8519 }
8520
8521
8529 public int countByG_S(long groupId, int status) throws SystemException {
8530 Object[] finderArgs = new Object[] { groupId, status };
8531
8532 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
8533 finderArgs, this);
8534
8535 if (count == null) {
8536 StringBundler query = new StringBundler(3);
8537
8538 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8539
8540 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
8541
8542 query.append(_FINDER_COLUMN_G_S_STATUS_2);
8543
8544 String sql = query.toString();
8545
8546 Session session = null;
8547
8548 try {
8549 session = openSession();
8550
8551 Query q = session.createQuery(sql);
8552
8553 QueryPos qPos = QueryPos.getInstance(q);
8554
8555 qPos.add(groupId);
8556
8557 qPos.add(status);
8558
8559 count = (Long)q.uniqueResult();
8560 }
8561 catch (Exception e) {
8562 throw processException(e);
8563 }
8564 finally {
8565 if (count == null) {
8566 count = Long.valueOf(0);
8567 }
8568
8569 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
8570 count);
8571
8572 closeSession(session);
8573 }
8574 }
8575
8576 return count.intValue();
8577 }
8578
8579
8587 public int filterCountByG_S(long groupId, int status)
8588 throws SystemException {
8589 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8590 return countByG_S(groupId, status);
8591 }
8592
8593 StringBundler query = new StringBundler(3);
8594
8595 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8596
8597 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
8598
8599 query.append(_FINDER_COLUMN_G_S_STATUS_2);
8600
8601 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8602 MBThread.class.getName(),
8603 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8604
8605 Session session = null;
8606
8607 try {
8608 session = openSession();
8609
8610 SQLQuery q = session.createSQLQuery(sql);
8611
8612 q.addScalar(COUNT_COLUMN_NAME,
8613 com.liferay.portal.kernel.dao.orm.Type.LONG);
8614
8615 QueryPos qPos = QueryPos.getInstance(q);
8616
8617 qPos.add(groupId);
8618
8619 qPos.add(status);
8620
8621 Long count = (Long)q.uniqueResult();
8622
8623 return count.intValue();
8624 }
8625 catch (Exception e) {
8626 throw processException(e);
8627 }
8628 finally {
8629 closeSession(session);
8630 }
8631 }
8632
8633
8641 public int countByC_P(long categoryId, double priority)
8642 throws SystemException {
8643 Object[] finderArgs = new Object[] { categoryId, priority };
8644
8645 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
8646 finderArgs, this);
8647
8648 if (count == null) {
8649 StringBundler query = new StringBundler(3);
8650
8651 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8652
8653 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
8654
8655 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
8656
8657 String sql = query.toString();
8658
8659 Session session = null;
8660
8661 try {
8662 session = openSession();
8663
8664 Query q = session.createQuery(sql);
8665
8666 QueryPos qPos = QueryPos.getInstance(q);
8667
8668 qPos.add(categoryId);
8669
8670 qPos.add(priority);
8671
8672 count = (Long)q.uniqueResult();
8673 }
8674 catch (Exception e) {
8675 throw processException(e);
8676 }
8677 finally {
8678 if (count == null) {
8679 count = Long.valueOf(0);
8680 }
8681
8682 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
8683 count);
8684
8685 closeSession(session);
8686 }
8687 }
8688
8689 return count.intValue();
8690 }
8691
8692
8700 public int countByL_P(Date lastPostDate, double priority)
8701 throws SystemException {
8702 Object[] finderArgs = new Object[] { lastPostDate, priority };
8703
8704 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P,
8705 finderArgs, this);
8706
8707 if (count == null) {
8708 StringBundler query = new StringBundler(3);
8709
8710 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8711
8712 if (lastPostDate == null) {
8713 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
8714 }
8715 else {
8716 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
8717 }
8718
8719 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
8720
8721 String sql = query.toString();
8722
8723 Session session = null;
8724
8725 try {
8726 session = openSession();
8727
8728 Query q = session.createQuery(sql);
8729
8730 QueryPos qPos = QueryPos.getInstance(q);
8731
8732 if (lastPostDate != null) {
8733 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
8734 }
8735
8736 qPos.add(priority);
8737
8738 count = (Long)q.uniqueResult();
8739 }
8740 catch (Exception e) {
8741 throw processException(e);
8742 }
8743 finally {
8744 if (count == null) {
8745 count = Long.valueOf(0);
8746 }
8747
8748 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P, finderArgs,
8749 count);
8750
8751 closeSession(session);
8752 }
8753 }
8754
8755 return count.intValue();
8756 }
8757
8758
8767 public int countByG_C_L(long groupId, long categoryId, Date lastPostDate)
8768 throws SystemException {
8769 Object[] finderArgs = new Object[] { groupId, categoryId, lastPostDate };
8770
8771 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
8772 finderArgs, this);
8773
8774 if (count == null) {
8775 StringBundler query = new StringBundler(4);
8776
8777 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8778
8779 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
8780
8781 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
8782
8783 if (lastPostDate == null) {
8784 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
8785 }
8786 else {
8787 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
8788 }
8789
8790 String sql = query.toString();
8791
8792 Session session = null;
8793
8794 try {
8795 session = openSession();
8796
8797 Query q = session.createQuery(sql);
8798
8799 QueryPos qPos = QueryPos.getInstance(q);
8800
8801 qPos.add(groupId);
8802
8803 qPos.add(categoryId);
8804
8805 if (lastPostDate != null) {
8806 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
8807 }
8808
8809 count = (Long)q.uniqueResult();
8810 }
8811 catch (Exception e) {
8812 throw processException(e);
8813 }
8814 finally {
8815 if (count == null) {
8816 count = Long.valueOf(0);
8817 }
8818
8819 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
8820 finderArgs, count);
8821
8822 closeSession(session);
8823 }
8824 }
8825
8826 return count.intValue();
8827 }
8828
8829
8838 public int filterCountByG_C_L(long groupId, long categoryId,
8839 Date lastPostDate) throws SystemException {
8840 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8841 return countByG_C_L(groupId, categoryId, lastPostDate);
8842 }
8843
8844 StringBundler query = new StringBundler(4);
8845
8846 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8847
8848 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
8849
8850 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
8851
8852 if (lastPostDate == null) {
8853 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
8854 }
8855 else {
8856 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
8857 }
8858
8859 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8860 MBThread.class.getName(),
8861 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8862
8863 Session session = null;
8864
8865 try {
8866 session = openSession();
8867
8868 SQLQuery q = session.createSQLQuery(sql);
8869
8870 q.addScalar(COUNT_COLUMN_NAME,
8871 com.liferay.portal.kernel.dao.orm.Type.LONG);
8872
8873 QueryPos qPos = QueryPos.getInstance(q);
8874
8875 qPos.add(groupId);
8876
8877 qPos.add(categoryId);
8878
8879 if (lastPostDate != null) {
8880 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
8881 }
8882
8883 Long count = (Long)q.uniqueResult();
8884
8885 return count.intValue();
8886 }
8887 catch (Exception e) {
8888 throw processException(e);
8889 }
8890 finally {
8891 closeSession(session);
8892 }
8893 }
8894
8895
8904 public int countByG_C_S(long groupId, long categoryId, int status)
8905 throws SystemException {
8906 Object[] finderArgs = new Object[] { groupId, categoryId, status };
8907
8908 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
8909 finderArgs, this);
8910
8911 if (count == null) {
8912 StringBundler query = new StringBundler(4);
8913
8914 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8915
8916 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8917
8918 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8919
8920 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8921
8922 String sql = query.toString();
8923
8924 Session session = null;
8925
8926 try {
8927 session = openSession();
8928
8929 Query q = session.createQuery(sql);
8930
8931 QueryPos qPos = QueryPos.getInstance(q);
8932
8933 qPos.add(groupId);
8934
8935 qPos.add(categoryId);
8936
8937 qPos.add(status);
8938
8939 count = (Long)q.uniqueResult();
8940 }
8941 catch (Exception e) {
8942 throw processException(e);
8943 }
8944 finally {
8945 if (count == null) {
8946 count = Long.valueOf(0);
8947 }
8948
8949 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
8950 finderArgs, count);
8951
8952 closeSession(session);
8953 }
8954 }
8955
8956 return count.intValue();
8957 }
8958
8959
8968 public int countByG_C_S(long groupId, long[] categoryIds, int status)
8969 throws SystemException {
8970 Object[] finderArgs = new Object[] {
8971 groupId, StringUtil.merge(categoryIds), status
8972 };
8973
8974 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
8975 finderArgs, this);
8976
8977 if (count == null) {
8978 StringBundler query = new StringBundler();
8979
8980 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8981
8982 boolean conjunctionable = false;
8983
8984 if (conjunctionable) {
8985 query.append(WHERE_AND);
8986 }
8987
8988 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
8989
8990 conjunctionable = true;
8991
8992 if ((categoryIds == null) || (categoryIds.length > 0)) {
8993 if (conjunctionable) {
8994 query.append(WHERE_AND);
8995 }
8996
8997 query.append(StringPool.OPEN_PARENTHESIS);
8998
8999 for (int i = 0; i < categoryIds.length; i++) {
9000 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
9001
9002 if ((i + 1) < categoryIds.length) {
9003 query.append(WHERE_OR);
9004 }
9005 }
9006
9007 query.append(StringPool.CLOSE_PARENTHESIS);
9008
9009 conjunctionable = true;
9010 }
9011
9012 if (conjunctionable) {
9013 query.append(WHERE_AND);
9014 }
9015
9016 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
9017
9018 conjunctionable = true;
9019
9020 String sql = query.toString();
9021
9022 Session session = null;
9023
9024 try {
9025 session = openSession();
9026
9027 Query q = session.createQuery(sql);
9028
9029 QueryPos qPos = QueryPos.getInstance(q);
9030
9031 qPos.add(groupId);
9032
9033 if (categoryIds != null) {
9034 qPos.add(categoryIds);
9035 }
9036
9037 qPos.add(status);
9038
9039 count = (Long)q.uniqueResult();
9040 }
9041 catch (Exception e) {
9042 throw processException(e);
9043 }
9044 finally {
9045 if (count == null) {
9046 count = Long.valueOf(0);
9047 }
9048
9049 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
9050 finderArgs, count);
9051
9052 closeSession(session);
9053 }
9054 }
9055
9056 return count.intValue();
9057 }
9058
9059
9068 public int filterCountByG_C_S(long groupId, long categoryId, int status)
9069 throws SystemException {
9070 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9071 return countByG_C_S(groupId, categoryId, status);
9072 }
9073
9074 StringBundler query = new StringBundler(4);
9075
9076 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9077
9078 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9079
9080 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
9081
9082 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9083
9084 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9085 MBThread.class.getName(),
9086 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9087
9088 Session session = null;
9089
9090 try {
9091 session = openSession();
9092
9093 SQLQuery q = session.createSQLQuery(sql);
9094
9095 q.addScalar(COUNT_COLUMN_NAME,
9096 com.liferay.portal.kernel.dao.orm.Type.LONG);
9097
9098 QueryPos qPos = QueryPos.getInstance(q);
9099
9100 qPos.add(groupId);
9101
9102 qPos.add(categoryId);
9103
9104 qPos.add(status);
9105
9106 Long count = (Long)q.uniqueResult();
9107
9108 return count.intValue();
9109 }
9110 catch (Exception e) {
9111 throw processException(e);
9112 }
9113 finally {
9114 closeSession(session);
9115 }
9116 }
9117
9118
9127 public int filterCountByG_C_S(long groupId, long[] categoryIds, int status)
9128 throws SystemException {
9129 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9130 return countByG_C_S(groupId, categoryIds, status);
9131 }
9132
9133 StringBundler query = new StringBundler();
9134
9135 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9136
9137 boolean conjunctionable = false;
9138
9139 if (conjunctionable) {
9140 query.append(WHERE_AND);
9141 }
9142
9143 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
9144
9145 conjunctionable = true;
9146
9147 if ((categoryIds == null) || (categoryIds.length > 0)) {
9148 if (conjunctionable) {
9149 query.append(WHERE_AND);
9150 }
9151
9152 query.append(StringPool.OPEN_PARENTHESIS);
9153
9154 for (int i = 0; i < categoryIds.length; i++) {
9155 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
9156
9157 if ((i + 1) < categoryIds.length) {
9158 query.append(WHERE_OR);
9159 }
9160 }
9161
9162 query.append(StringPool.CLOSE_PARENTHESIS);
9163
9164 conjunctionable = true;
9165 }
9166
9167 if (conjunctionable) {
9168 query.append(WHERE_AND);
9169 }
9170
9171 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
9172
9173 conjunctionable = true;
9174
9175 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9176 MBThread.class.getName(),
9177 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9178
9179 Session session = null;
9180
9181 try {
9182 session = openSession();
9183
9184 SQLQuery q = session.createSQLQuery(sql);
9185
9186 q.addScalar(COUNT_COLUMN_NAME,
9187 com.liferay.portal.kernel.dao.orm.Type.LONG);
9188
9189 QueryPos qPos = QueryPos.getInstance(q);
9190
9191 qPos.add(groupId);
9192
9193 if (categoryIds != null) {
9194 qPos.add(categoryIds);
9195 }
9196
9197 qPos.add(status);
9198
9199 Long count = (Long)q.uniqueResult();
9200
9201 return count.intValue();
9202 }
9203 catch (Exception e) {
9204 throw processException(e);
9205 }
9206 finally {
9207 closeSession(session);
9208 }
9209 }
9210
9211
9220 public int countByG_NotC_S(long groupId, long categoryId, int status)
9221 throws SystemException {
9222 Object[] finderArgs = new Object[] { groupId, categoryId, status };
9223
9224 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S,
9225 finderArgs, this);
9226
9227 if (count == null) {
9228 StringBundler query = new StringBundler(4);
9229
9230 query.append(_SQL_COUNT_MBTHREAD_WHERE);
9231
9232 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
9233
9234 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
9235
9236 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
9237
9238 String sql = query.toString();
9239
9240 Session session = null;
9241
9242 try {
9243 session = openSession();
9244
9245 Query q = session.createQuery(sql);
9246
9247 QueryPos qPos = QueryPos.getInstance(q);
9248
9249 qPos.add(groupId);
9250
9251 qPos.add(categoryId);
9252
9253 qPos.add(status);
9254
9255 count = (Long)q.uniqueResult();
9256 }
9257 catch (Exception e) {
9258 throw processException(e);
9259 }
9260 finally {
9261 if (count == null) {
9262 count = Long.valueOf(0);
9263 }
9264
9265 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S,
9266 finderArgs, count);
9267
9268 closeSession(session);
9269 }
9270 }
9271
9272 return count.intValue();
9273 }
9274
9275
9284 public int filterCountByG_NotC_S(long groupId, long categoryId, int status)
9285 throws SystemException {
9286 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9287 return countByG_NotC_S(groupId, categoryId, status);
9288 }
9289
9290 StringBundler query = new StringBundler(4);
9291
9292 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9293
9294 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
9295
9296 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
9297
9298 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
9299
9300 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9301 MBThread.class.getName(),
9302 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9303
9304 Session session = null;
9305
9306 try {
9307 session = openSession();
9308
9309 SQLQuery q = session.createSQLQuery(sql);
9310
9311 q.addScalar(COUNT_COLUMN_NAME,
9312 com.liferay.portal.kernel.dao.orm.Type.LONG);
9313
9314 QueryPos qPos = QueryPos.getInstance(q);
9315
9316 qPos.add(groupId);
9317
9318 qPos.add(categoryId);
9319
9320 qPos.add(status);
9321
9322 Long count = (Long)q.uniqueResult();
9323
9324 return count.intValue();
9325 }
9326 catch (Exception e) {
9327 throw processException(e);
9328 }
9329 finally {
9330 closeSession(session);
9331 }
9332 }
9333
9334
9340 public int countAll() throws SystemException {
9341 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
9342 FINDER_ARGS_EMPTY, this);
9343
9344 if (count == null) {
9345 Session session = null;
9346
9347 try {
9348 session = openSession();
9349
9350 Query q = session.createQuery(_SQL_COUNT_MBTHREAD);
9351
9352 count = (Long)q.uniqueResult();
9353 }
9354 catch (Exception e) {
9355 throw processException(e);
9356 }
9357 finally {
9358 if (count == null) {
9359 count = Long.valueOf(0);
9360 }
9361
9362 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
9363 FINDER_ARGS_EMPTY, count);
9364
9365 closeSession(session);
9366 }
9367 }
9368
9369 return count.intValue();
9370 }
9371
9372
9375 public void afterPropertiesSet() {
9376 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
9377 com.liferay.portal.util.PropsUtil.get(
9378 "value.object.listener.com.liferay.portlet.messageboards.model.MBThread")));
9379
9380 if (listenerClassNames.length > 0) {
9381 try {
9382 List<ModelListener<MBThread>> listenersList = new ArrayList<ModelListener<MBThread>>();
9383
9384 for (String listenerClassName : listenerClassNames) {
9385 listenersList.add((ModelListener<MBThread>)InstanceFactory.newInstance(
9386 listenerClassName));
9387 }
9388
9389 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
9390 }
9391 catch (Exception e) {
9392 _log.error(e);
9393 }
9394 }
9395 }
9396
9397 public void destroy() {
9398 EntityCacheUtil.removeCache(MBThreadImpl.class.getName());
9399 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
9400 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9401 }
9402
9403 @BeanReference(type = MBBanPersistence.class)
9404 protected MBBanPersistence mbBanPersistence;
9405 @BeanReference(type = MBCategoryPersistence.class)
9406 protected MBCategoryPersistence mbCategoryPersistence;
9407 @BeanReference(type = MBDiscussionPersistence.class)
9408 protected MBDiscussionPersistence mbDiscussionPersistence;
9409 @BeanReference(type = MBMailingListPersistence.class)
9410 protected MBMailingListPersistence mbMailingListPersistence;
9411 @BeanReference(type = MBMessagePersistence.class)
9412 protected MBMessagePersistence mbMessagePersistence;
9413 @BeanReference(type = MBStatsUserPersistence.class)
9414 protected MBStatsUserPersistence mbStatsUserPersistence;
9415 @BeanReference(type = MBThreadPersistence.class)
9416 protected MBThreadPersistence mbThreadPersistence;
9417 @BeanReference(type = MBThreadFlagPersistence.class)
9418 protected MBThreadFlagPersistence mbThreadFlagPersistence;
9419 @BeanReference(type = LockPersistence.class)
9420 protected LockPersistence lockPersistence;
9421 @BeanReference(type = ResourcePersistence.class)
9422 protected ResourcePersistence resourcePersistence;
9423 @BeanReference(type = SubscriptionPersistence.class)
9424 protected SubscriptionPersistence subscriptionPersistence;
9425 @BeanReference(type = UserPersistence.class)
9426 protected UserPersistence userPersistence;
9427 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
9428 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
9429 @BeanReference(type = AssetEntryPersistence.class)
9430 protected AssetEntryPersistence assetEntryPersistence;
9431 @BeanReference(type = RatingsStatsPersistence.class)
9432 protected RatingsStatsPersistence ratingsStatsPersistence;
9433 @BeanReference(type = SocialActivityPersistence.class)
9434 protected SocialActivityPersistence socialActivityPersistence;
9435 private static final String _SQL_SELECT_MBTHREAD = "SELECT mbThread FROM MBThread mbThread";
9436 private static final String _SQL_SELECT_MBTHREAD_WHERE = "SELECT mbThread FROM MBThread mbThread WHERE ";
9437 private static final String _SQL_COUNT_MBTHREAD = "SELECT COUNT(mbThread) FROM MBThread mbThread";
9438 private static final String _SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(mbThread) FROM MBThread mbThread WHERE ";
9439 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbThread.groupId = ? AND mbThread.categoryId != -1";
9440 private static final String _FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2 = "mbThread.rootMessageId = ?";
9441 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbThread.groupId = ? AND ";
9442 private static final String _FINDER_COLUMN_G_C_GROUPID_5 = "(" +
9443 _removeConjunction(_FINDER_COLUMN_G_C_GROUPID_2) + ")";
9444 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbThread.categoryId = ?";
9445 private static final String _FINDER_COLUMN_G_C_CATEGORYID_5 = "(" +
9446 _removeConjunction(_FINDER_COLUMN_G_C_CATEGORYID_2) + ")";
9447 private static final String _FINDER_COLUMN_G_NOTC_GROUPID_2 = "mbThread.groupId = ? AND ";
9448 private static final String _FINDER_COLUMN_G_NOTC_CATEGORYID_2 = "mbThread.categoryId != ?";
9449 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbThread.groupId = ? AND ";
9450 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbThread.status = ? AND mbThread.categoryId != -1";
9451 private static final String _FINDER_COLUMN_C_P_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
9452 private static final String _FINDER_COLUMN_C_P_PRIORITY_2 = "mbThread.priority = ?";
9453 private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL AND ";
9454 private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_2 = "mbThread.lastPostDate = ? AND ";
9455 private static final String _FINDER_COLUMN_L_P_PRIORITY_2 = "mbThread.priority = ? AND mbThread.categoryId != -1";
9456 private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "mbThread.groupId = ? AND ";
9457 private static final String _FINDER_COLUMN_G_C_L_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
9458 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL";
9459 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_2 = "mbThread.lastPostDate = ?";
9460 private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "mbThread.groupId = ? AND ";
9461 private static final String _FINDER_COLUMN_G_C_S_GROUPID_5 = "(" +
9462 _removeConjunction(_FINDER_COLUMN_G_C_S_GROUPID_2) + ")";
9463 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
9464 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_5 = "(" +
9465 _removeConjunction(_FINDER_COLUMN_G_C_S_CATEGORYID_2) + ")";
9466 private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbThread.status = ?";
9467 private static final String _FINDER_COLUMN_G_C_S_STATUS_5 = "(" +
9468 _removeConjunction(_FINDER_COLUMN_G_C_S_STATUS_2) + ")";
9469 private static final String _FINDER_COLUMN_G_NOTC_S_GROUPID_2 = "mbThread.groupId = ? AND ";
9470 private static final String _FINDER_COLUMN_G_NOTC_S_CATEGORYID_2 = "mbThread.categoryId != ? AND ";
9471 private static final String _FINDER_COLUMN_G_NOTC_S_STATUS_2 = "mbThread.status = ?";
9472
9473 private static String _removeConjunction(String sql) {
9474 int pos = sql.indexOf(" AND ");
9475
9476 if (pos != -1) {
9477 sql = sql.substring(0, pos);
9478 }
9479
9480 return sql;
9481 }
9482
9483 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbThread.threadId";
9484 private static final String _FILTER_SQL_SELECT_MBTHREAD_WHERE = "SELECT DISTINCT {mbThread.*} FROM MBThread mbThread WHERE ";
9485 private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1 =
9486 "SELECT {MBThread.*} FROM (SELECT DISTINCT mbThread.threadId FROM MBThread mbThread WHERE ";
9487 private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2 =
9488 ") TEMP_TABLE INNER JOIN MBThread ON TEMP_TABLE.threadId = MBThread.threadId";
9489 private static final String _FILTER_SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(DISTINCT mbThread.threadId) AS COUNT_VALUE FROM MBThread mbThread WHERE ";
9490 private static final String _FILTER_ENTITY_ALIAS = "mbThread";
9491 private static final String _FILTER_ENTITY_TABLE = "MBThread";
9492 private static final String _ORDER_BY_ENTITY_ALIAS = "mbThread.";
9493 private static final String _ORDER_BY_ENTITY_TABLE = "MBThread.";
9494 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBThread exists with the primary key ";
9495 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBThread exists with the key {";
9496 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
9497 private static Log _log = LogFactoryUtil.getLog(MBThreadPersistenceImpl.class);
9498 private static MBThread _nullMBThread = new MBThreadImpl() {
9499 @Override
9500 public Object clone() {
9501 return this;
9502 }
9503
9504 @Override
9505 public CacheModel<MBThread> toCacheModel() {
9506 return _nullMBThreadCacheModel;
9507 }
9508 };
9509
9510 private static CacheModel<MBThread> _nullMBThreadCacheModel = new CacheModel<MBThread>() {
9511 public MBThread toEntityModel() {
9512 return _nullMBThread;
9513 }
9514 };
9515 }